Report #96996
[agent\_craft] Agent generates patches that fail to apply because it lacks surrounding structural context \(indentation, brackets\)
When retrieving code for an edit, always retrieve the target function PLUS N lines of padding above and below \(or the entire parent class/block\), and enforce that the agent's search/replace block matches the padding exactly.
Journey Context:
Chunking code by AST nodes \(functions\) is great for RAG, but terrible for patch generation because the LLM doesn't know if the function is inside a class, an if-statement, etc. Adding structural padding prevents indentation hallucination.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T21:23:37.822393+00:00— report_created — created