Repository navigation
fix: stop echoing full file contents back after write_file - #776
Merged
Merged
Conversation
executeWriteFile read the file back after writing and returned every line, number-prefixed, appended to the result. That's pure duplication — the model just sent that exact content as the tool call arguments, so paying for it again (with an extra ~6 chars/line for the prefix) adds nothing, and since tool results stay in the conversation, the cost is re-sent on every later step too. No cap, so it scales linearly with file size (~8,500 tokens on a 791-line file in this repo). Kept the read-back itself, since it verifies the write succeeded and its line/char/token counts feed the existing confirmation message. Just stopped appending the line-numbered content dump. Updated the three existing tests that asserted the echoed content (write-file.spec.tsx) to assert its absence instead, and repurposed the read-back verification test to check the reported stats are accurate rather than that content is echoed. Fixes Nano-Collective#762
MsfPablo
requested review from
Avtrkrb,
akramcodez and
will-lamerton
as code owners
August 3, 2026 16:26
Member
|
Nice work @MsfPablo :) |
This was referenced Aug 9, 2026
3 tasks done
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.
Summary
Fixes #762.
executeWriteFileread the file back after writing and appended every line, number-prefixed, to the tool result. That's pure duplication: the model just sent that exact content as the tool call arguments, so returning it again costs tokens (with an extra ~6 chars/line for the prefix) without adding information the model didn't already have. There's no cap, so it scales linearly with file size — the issue measured ~8,500 tokens onsource/app/App.tsx(791 lines) in this repo — and since tool results stay in the conversation, that cost is re-sent on every subsequent agent step.Kept the read-back itself (per the issue: it verifies the write succeeded, and its line/char/token counts already feed the existing confirmation message), just stopped appending the line-numbered content dump.
Test plan
pnpm run test:format,test:lint,test:types— all cleanpnpm run test:ava source/tools/file-ops/write-file.spec.tsx— 43 tests passwrite_file: create new file/write_file: overwrite existing file— dropped the'File contents after write:'assertionwrite_file: returns file contents after write→ renamed towrite_file: reports accurate stats without echoing content back, now asserts the line count is still accurate while the raw content and the'File contents after write:'marker are absent