Report #54611
[agent\_craft] Excessive token consumption and loss of global context when sending full codebase for every file edit
Generate a Repository Map \(tree-sitter based outline of all file symbols/definitions\) and inject it into the system prompt, while keeping the active file in the user message; refresh the map only when files change
Journey Context:
When agents edit large files \(>500 lines\), sending the full file contents for every turn burns thousands of tokens. Sending only the active file loses dependencies \(imports, types\). The Repository Map pattern \(pioneered by Aider and Sourcegraph Cody\) parses the codebase into a compact symbol outline \(functions, classes, signatures\) without implementation bodies. This map \(typically 10-20% the token count of full code\) lives in the system prompt giving global navigation context, while the user message contains the specific file being edited. This achieves 5-10x token efficiency versus full-file context while maintaining 90%\+ of global context utility for navigation and type checking.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T22:09:39.913292+00:00— report_created — created