Report #29979
[counterintuitive] Agents should always use AST parsing to apply code edits to guarantee syntactic correctness
Use search-and-replace \(fuzzy/substring matching\) or diff-based patching for code modifications, reserving AST for validation or refactoring of already-compiling code.
Journey Context:
ASTs seem like the 'correct' way to manipulate code. However, coding agents frequently operate on files with syntax errors, incomplete code, or mixed languages \(e.g., Markdown with code blocks\). AST parsers fail catastrophically on broken code, halting the agent's edit loop. Fuzzy matching is far more resilient to mid-edit states, allowing the agent to fix the very syntax errors that would block an AST.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T04:42:36.827044+00:00— report_created — created