Skip to content

fix(read): report both MAX_LINES and MAX_BYTES caps when both are hit#708

Open
Cyning12 wants to merge 1 commit into
MoonshotAI:mainfrom
Cyning12:feature/fix-94-read-dual-limit
Open

fix(read): report both MAX_LINES and MAX_BYTES caps when both are hit#708
Cyning12 wants to merge 1 commit into
MoonshotAI:mainfrom
Cyning12:feature/fix-94-read-dual-limit

Conversation

@Cyning12

Copy link
Copy Markdown
Contributor

Related Issue

Fixes #94

Problem

When a file is large enough to trigger both the MAX_LINES (1000) and MAX_BYTES (100 KiB) limits, the Read tool's <system> status block only reports the line cap and silently omits the byte cap. This happens because finishMessage uses an else if chain that treats the two limits as mutually exclusive.

What changed

  • Changed finishMessage in packages/agent-core/src/tools/builtin/file/read.ts to use independent if checks for maxLinesReached and maxBytesReached, so both messages appear together when both limits are hit.
  • Added an explicit guard for End of file reached. (!maxLinesReached && !maxBytesReached && lineCount < requestedLines) to prevent it from being suppressed or incorrectly shown alongside the caps.
  • Added a regression test reports both line and byte caps when both limits are hit that constructs a file with MAX_LINES + 1 lines of 200 characters each, asserting that the output contains both cap messages and does not contain End of file reached..

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.}

Fixes MoonshotAI#94 — finishMessage uses independent checks so MAX_LINES and
MAX_BYTES messages appear together; add regression test.

Co-authored-by: Cursor <cursoragent@cursor.com>
@changeset-bot

changeset-bot Bot commented Jun 13, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 602cec1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@moonshot-ai/agent-core Patch
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jun 13, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@602cec1
npx https://pkg.pr.new/@moonshot-ai/kimi-code@602cec1

commit: 602cec1

Cyning12 pushed a commit to Cyning12/kimi-code that referenced this pull request Jun 13, 2026
…I#708

Move task to done/, record partial graph closeout, and land invoke/review artifacts for path A sign-off.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants