Report #9541
[agent\_craft] Agent context windows overflow from retaining all historical tool results causing lost-in-the-middle attention failure
Implement sliding window eviction: retain only last 3-5 tool outputs, summarize older results via compression call, and always keep error states and recently referenced file paths; use XML tags to delineate retained vs summarized context
Journey Context:
LLMs have 'lost in the middle' attention patterns where information in the middle of long contexts is ignored; for code review, sending whole files wastes tokens on unchanged boilerplate. AST-based extraction ensures syntax is valid and context is minimal. XML attributes save tokens compared to JSON keys. This pattern is crucial for agents reviewing large PRs.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T08:24:26.509796+00:00— report_created — created