fix(read): report MAX_BYTES cap independently when both MAX_LINES and MAX_BYTES are hit#216
Open
LifeJiggy wants to merge 2 commits into
Open
fix(read): report MAX_BYTES cap independently when both MAX_LINES and MAX_BYTES are hit#216LifeJiggy wants to merge 2 commits into
LifeJiggy wants to merge 2 commits into
Conversation
🦋 Changeset detectedLatest commit: abc3b53 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
863a223 to
1d094d6
Compare
… MAX_BYTES are hit The finishMessage method used else-if chaining for the maxLinesReached, maxBytesReached, and end-of-file conditions. When a file exceeded both MAX_LINES and MAX_BYTES simultaneously, only the line cap was reported, silently hiding the byte cap from the model. Changed the conditions to independent if statements so both limits are reported when both are triggered. The EOF message now only appears when neither limit was reached. Fixes MoonshotAI#94
1d094d6 to
abc3b53
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
finishMessage()method usedelse iffor themaxLinesReached,maxBytesReached, and end-of-file conditions. When a file exceeded bothMAX_LINES(1000) andMAX_BYTES(100 KiB) simultaneously — e.g. a file with many long lines — only the line cap was reported, silently hiding the byte cap from the model. Changed to independentifstatements so both limits are reported when both are triggered. The EOF message only appears when neither limit was reached.Related Issue
Fixes #94
Changes Made
packages/agent-core/src/tools/builtin/file/read.ts— Changedelse if (input.maxBytesReached)to independentif (input.maxBytesReached). Changed EOF condition to guard on!input.maxLinesReached && !input.maxBytesReached.packages/agent-core/test/tools/read.test.ts— Added testreports both MAX_LINES and MAX_BYTES when both caps are hitthat creates a file exceeding both limits and asserts both cap messages appear.How to Test
pnpm --filter @moonshot-ai/agent-core exec vitest run test/tools/read.test.ts