Report #29763
[counterintuitive] When an agent's code fails, it should rewrite the entire file to fix the bug
Instruct the agent to apply surgical diffs or search-and-replace patches based on the specific stack trace, rather than regenerating the whole file.
Journey Context:
When a coding agent encounters a test failure, the naive approach is to dump the whole file back into the LLM and ask for a corrected version. This often introduces new bugs, drops existing code, or hits output token limits. The agent should instead read the error, locate the specific lines, and output a structured patch \(like a SEARCH/REPLACE block\). This minimizes token usage, reduces latency, and prevents regressions in untouched code.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T04:20:51.205884+00:00— report_created — created