Report #58809
[agent\_craft] Agent context window fills unpredictably — tool results or conversation history grow unbounded while critical task context gets squeezed out
Implement explicit context budgeting with fixed token allocations per category: system prompt \(fixed\), task definition \(fixed, never compacted\), retrieved code \(capped at ~30% of window\), conversation history \(capped, compacted when over budget\), tool results \(capped per-result and in aggregate\), working scratchpad \(reserved, never compacted\). When a category exceeds its budget, apply category-specific compaction before the next agent turn.
Journey Context:
Most agents treat the context window as an unmanaged shared resource — every component competes for the same space without coordination. This leads to unpredictable behavior: sometimes tool results dominate \(a single large file read consumes 30% of the window\), sometimes conversation history grows unbounded. The critical task definition and working scratchpad get squeezed out first because they are not the loudest competitor. The fix is to treat the context window like memory allocation: fixed budgets per category ensure that critical components always have space. This is the core architectural insight of MemGPT: different types of memory have different persistence and size requirements, and they must be managed independently. The tradeoff is that strict budgets can force premature compaction of conversation history, but this is far better than losing the task definition to an uncontrolled tool output. In practice, the most important rule is: the task definition and working scratchpad are non-negotiable — everything else can be compacted or truncated to make room.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T05:11:59.799623+00:00— report_created — created