Repository navigation
perf(tools): stop echoing written files back to the model - #422
Merged
Merged
Conversation
`write` returned a preview of the first 40 numbered lines of the file it just wrote. The model sent that content itself, so the echo told it nothing, and pruning only cuts results past 2 KiB, so each write kept ~500 tokens in context until compaction. The model now gets `Wrote <path> · N lines` and the `[+N -M]` trailer (`format_write_summary`, the preview's own header line). The TUI rebuilds the coloured preview from the call's `content` argument, which it already holds live and on resume, so what it paints is unchanged; a stored result that still carries a preview is painted as before. `edit` keeps its diff: for a tag-addressed edit the replaced block comes from the file, and showing it is how the model catches a wrong range. Measured (o200k): a 40+ line Rust file 539 -> 22 tokens, README.md 915 -> 17. Co-Authored-By: Claude Opus 5.5 <[email protected]>
mrnasil
force-pushed
the
perf/write-result-summary
branch
from
November 7, 2026 13:37
3ffb70e to
da6946f
Compare
Merged
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.
Part of the token-efficiency series (#418–#421).
Problem
writereturned a preview of the first 40 numbered lines of the file it had just written. The model sent that content itself, so the echo gives it no new information. Pruning only cuts results past 2 KiB, so each write kept roughly 500 tokens in context until compaction.Change
Wrote <path> · N linesplus the[+N -M]trailer. This comes fromformat_write_summary, which is the preview's own header line;format_write_previewnow starts with it.tool_blockrebuilds the coloured preview from the call'scontentargument, which it holds both live and on resume. What it paints is byte-identical to before. A stored result that still carries a preview (an older transcript) is painted as is.preview_write) is unchanged, and so isedit_stats(it reads the trailer).editkeeps its diff on purpose. For a tag-addressed edit (from/to/insert_after), the replaced block comes from the file, and seeing it is how the model catches a wrong range.Measured (o200k)
crates/agent/src/notify.rscrates/session/src/title.rsREADME.mdChecks
write_block_paints_the_same_preview_from_its_content_argument: the TUI paints identical lines from the compact result and from the old full preview. It also covers the legacy, empty-file, error and non-write cases.tools538,agent764 andtui1495 lib tests pass, plus theformattests.🤖 Generated with Claude Code