Skip to content

Read tool status message omits MAX_BYTES cap when MAX_LINES is also hit #94

@jiang1997

Description

@jiang1997

What version of Kimi Code is running?

0.3.0

Which open platform/subscription were you using?

Kimi Code

Which model were you using?

No response

What platform is your computer?

Debian(WSL)

What issue are you seeing?

When reading a file that exceeds both the MAX_LINES and MAX_BYTES_KB limits, the <system> status tag in the tool result only reports the line limit. The byte limit is silently omitted even though it was also triggered.

For example, the status might say:

<system>... Max 1000 lines reached.</system>

But it does not mention that MAX_BYTES was also hit, which could mislead the model into thinking only the line cap mattered.

What steps can reproduce the bug?

  1. Prepare a file that exceeds both MAX_LINES (1000) and MAX_BYTES_KB (100 KB) limits. For example, a file with 1001 lines where each line is very long (e.g., 120+ characters).

  2. Use the Read tool to read this file.

  3. Inspect the wire.jsonl file — in the tool result's <system> status tag, you will see:

    <system>... Max 1000 lines reached.</system>
    

    But not the Max 102400 bytes reached. message, even though the byte limit was also hit.

The root cause is in packages/agent-core/src/tools/builtin/file/read.ts: the limit checks are chained with else if, so when both maxLinesReached and maxBytesReached are true, only the first branch executes.

What is the expected behavior?

Both limits should be reported independently when both are triggered:

<system>... Max 1000 lines reached. Max 102400 bytes reached.</system>

The EOF message ("End of file reached.") should only appear when neither truncation limit was hit.

Additional information

The fix is straightforward — change else if to independent if statements and tighten the EOF condition. I have a branch ready and can open a PR once this issue is triaged.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions