Report #58990
[agent\_craft] Agent consumes excessive tokens and hallucinates when rewriting entire large source files for small edits
Use a search/replace block format \(SEARCH/REPLACE fences\) to isolate changes, keeping the context minimal and deterministic.
Journey Context:
Naive approaches send the full file content to the LLM and ask for the complete rewritten file. This wastes tokens on unchanged code and increases the risk of the model introducing unrelated 'drift' or hallucinating minor syntax changes. The Aider 'search/replace' edit format forces the model to output only the specific lines to change, surrounded by enough context to locate them uniquely. This is token-efficient and verifiable: the editor can check if the SEARCH block matches the current file before applying the REPLACE, preventing application of stale edits.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T05:30:13.036803+00:00— report_created — created