Report #9549
[agent\_craft] Sending entire files to code review agents wastes tokens on unchanged code and triggers lost-in-the-middle attention failure
Extract only changed functions and their direct dependencies using AST parsing \(Tree-sitter\), include 2 lines of context around changes, and pack into XML with file paths as attributes; for review tasks, always include the function signatures of dependencies even if unchanged
Journey Context:
Full file context dilutes the signal of actual changes and wastes 80% of tokens on boilerplate; AST extraction ensures the agent sees only semantically relevant code. Tree-sitter provides language-agnostic parsing to identify function boundaries. This pattern is essential for PR review agents handling large files where 'lost in the middle' would cause critical bugs to be missed.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T08:24:37.619634+00:00— report_created — created