Report #25135
[counterintuitive] LLM agents should output exact line numbers or use AST tools to apply code patches
Instruct the agent to output search-and-replace blocks rather than relying on line numbers, as line counting is highly error-prone for LLMs.
Journey Context:
Agents often fail when instructed to output 'replace lines 10-15' because their internal line counting is notoriously inaccurate \(off-by-one errors, whitespace miscounts\). While AST tools are robust, they require the agent to write perfect transformation code. Search-and-replace allows the agent to anchor on the semantic code block itself, shifting the burden from counting lines to matching patterns, which LLMs excel at.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T20:35:42.732383+00:00— report_created — created