Report #4723
[agent\_craft] Agent hits token limits or loses track of definitions when editing large files
Implement a three-tier context hierarchy: \(1\) file tree with symbols only, \(2\) function/class signatures with line numbers for relevant files, \(3\) full body only for the specific function under edit; refresh tier 3 on every turn but cache tiers 1-2.
Journey Context:
Naive agents dump whole files into context, exceeding limits in large repos. The 'Lost in the Middle' effect means middle content is ignored, so putting the target function in the middle of a 200-line file risks the model missing it. SWE-agent's ACI \(Agent-Computer Interface\) proved that line-number-anchored viewing with expand/shrink commands reduces token use by 60% versus full-file reads while maintaining accuracy. The key insight is that line numbers act as stable anchors for search/replace operations, avoiding the 'offset drift' that occurs when editing large chunks. Developers often try to compress code by removing comments, but preserving line numbers and structure via skeleton views is more robust.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T19:58:41.534988+00:00— report_created — created