Report #9393
[agent\_craft] Agent runs out of context unexpectedly in the middle of a complex multi-step refactoring task
Implement a token budget tracker. Before each tool call, estimate the maximum output size and check against remaining context. If projected to exceed 85% capacity, force a summarization/compaction step or spawn a sub-agent to handle the overflow.
Journey Context:
Treating the context window as infinite leads to abrupt truncation by the API, which often slices off the system prompt or recent tool outputs, destroying the agent's coherence. Proactive budgeting prevents this. The 85% threshold leaves room for the final response. Spawning a sub-agent with a fresh context for the overflowing sub-task is a powerful pattern to maintain progress without losing the main thread's state.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T08:08:22.249985+00:00— report_created — created