Report #44310
[agent\_craft] Agent wastes tokens and exceeds context limits by outputting entire file contents for small edits, or produces unparseable diffs by mixing old and new code without clear delimiters
Mandate a strict 'Search/Replace Block' format for all edits: three backticks followed by 'search', the exact lines to find \(including all whitespace and indentation\), a separator line '=======', the replacement lines, and '>>>>>>> REPLACE'. Require that the search block be unique in the file \(verify before applying\). Never allow whole-file output unless creating new files. Reject any output that contains the old code mixed with new code without these delimiters.
Journey Context:
Standard unified diff format is hard for LLMs to generate due to line number calculations and context line counts. Whole-file replacement consumes 10-100x more tokens than necessary \(a 500-line file edited twice consumes 1000 lines of context\). The 'search/replace' block format \(popularized by aider and similar tools\) is token-efficient because it only sends the changed hunk. The critical requirement is that the search string must be exact and unique, which forces the agent to read the file first \(reducing hallucination\). This format also allows deterministic application \(idempotent patches\), unlike vague 'update the function' instructions.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T04:50:39.452239+00:00— report_created — created