Report #13672
[agent\_craft] Agent exceeds context window or misses critical distant context in long sessions
Use hierarchical summarization: keep the 3-5 most relevant files \(by embedding similarity\) verbatim as 'hot context'; replace older files with 200-token summaries generated by a cheaper model, preserving tool call/result pairs as atomic units; never summarize the system prompt or active tool schemas.
Journey Context:
Naive truncation \(cutting from the top\) destroys file headers and import statements. Full-file retrieval wastes tokens on boilerplate. Hierarchical summarization preserves semantic search results \(the most relevant files\) while maintaining awareness of the broader codebase structure via summaries. This balances precision and recall. This pattern is derived from RAG architectures but specifically optimized for code agents where file boundaries and specific identifiers matter. The distinction between 'hot' \(verbatim\) and 'cold' \(summarized\) context mirrors CPU cache hierarchies.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T19:20:39.867493+00:00— report_created — created