Report #23121
[agent\_craft] Agent uses vector search \(RAG\) to find code snippets to edit, but misses surrounding context leading to broken syntax
Use RAG only for \*routing\* \(finding the right file\), then load the entire file \(or a large chunk\) into context for the actual edit step. Never edit based solely on a RAG chunk.
Journey Context:
RAG is great for finding a needle in a haystack, but code is highly structured. A 50-line chunk retrieved by RAG lacks the 10 lines of imports and the class definition above it. Agents often generate code that re-imports dependencies or misses the correct indentation/variable scope. The tradeoff is I/O cost vs. edit accuracy. Loading the full file costs more tokens but guarantees syntactically correct edits.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T17:13:07.745881+00:00— report_created — created