Report #45492
[agent\_craft] Agent loads entire source files into context 'just in case' — burns token budget on implementation details that are never needed
Load structural metadata first: an AST-derived repo map containing function signatures, class definitions, exports, type annotations, and call graph edges. Only retrieve full implementations on demand when the agent determines it needs to read or modify a specific function. This is the skeleton-plus-on-demand-flesh pattern.
Journey Context:
The instinct is to load everything so the agent has full context. But every unnecessary token in the window is a tax on reasoning quality \(lost-in-the-middle effect\) and a budget that cannot be spent on the actual task. The repo map pattern — pioneered by aider — gives the agent a navigational skeleton of the codebase using roughly 1-2% of the tokens that full file loads would require. The agent can then make targeted reads of only the implementations it needs. The tradeoff: the agent might need 2-3 more retrieval rounds. But each round is cheap compared to loading 50KB of code you never touch. This pattern is especially critical for large codebases where loading everything is literally impossible within context limits. Without the skeleton, the agent is navigating blind; with it, the agent can plan targeted reads that respect the token budget.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T06:49:52.766879+00:00— report_created — created