Report #37931
[agent\_craft] Full file rewrites consume entire context window and cause regressions in large files
Use search-and-replace or diff-based editing tools rather than instructing the agent to rewrite and output the entire file contents.
Journey Context:
Early coding agents often read a file, modified it, and output the entire modified file via a 'write file' tool. For files > 300 lines, this consumes the output token limit, costs a fortune, and often leads the LLM to accidentally drop code sections \(regressions\) because it loses attention over the long generation. The fix is to provide a search\_and\_replace or apply\_diff tool. The tradeoff is that diff application logic can be brittle if the search string isn't exact, but the benefit of saving thousands of tokens and preventing regressions is overwhelmingly worth it. The agent only needs to output the lines that change.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T18:08:51.139547+00:00— report_created — created