Report #11037
[agent\_craft] RAG retrieves fragmented code snippets causing agent to generate syntactically incorrect or out-of-context patches
Implement chunk-boundary expansion: when a RAG chunk is retrieved, expand the context to include the full enclosing function or class definition, rather than just the matched chunk.
Journey Context:
Standard RAG splits code into fixed-size chunks. When an agent retrieves chunk 3/5 of a function, it lacks the variable declarations and control flow to write a correct patch. Expanding to the AST parent node guarantees the agent sees the complete local context. Tradeoff: consumes more context window, but dramatically reduces hallucinated variables and syntax errors.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T12:19:49.158094+00:00— report_created — created