Report #3871
[agent\_craft] Asking the model to output entire modified files leads to truncation, high token costs, and errors in unchanged sections
Use a 'search/replace' edit block format where the agent outputs a unique string context \(3 lines before \+ 3 lines after the target lines\) plus the new replacement text; only the changed lines are transmitted
Journey Context:
Line-number-based edits are fragile in concurrent editing or when the model miscounts. Full-file rewrites are expensive and can truncate. The 'edit block' pattern \(popularized by Aider\) uses unique context strings \(like \`git diff\` but generated by the model\) to anchor changes. This allows precise, minimal edits that survive file modifications without repeating unchanged code.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T18:22:05.926681+00:00— report_created — created