Skip to main content
As a conversation runs, the model’s context keeps growing: more customer turns, more agent replies, more tool calls and results. The runtime automatically manages that context so it stays within model limits — compressing large tool results, replacing older tool results with placeholders, and shortening earlier turns — according to a set of compaction policies you can tune per agent, per project, or per tool. This page lists the default budgets, shows where to set them, and walks through diagnosing a prompt that’s grown too large. For what actually determines which values reach the model in the first place — visibility modes and ## Current Context — see How a turn is built.

Size limits and compaction

Three policies set how much the model reads on a given turn:
  • tool_results — how tool output is shaped, both this turn and on later turns.
  • prior_turns — how earlier turns in the conversation history are compacted.
  • prompt_context — how ## Current Context values are sized and projected.
They merge in this order: platform defaults, then the voice low-latency profile (voice channels only), then project settings, then the agent’s EXECUTION.compaction, then per-tool hints. Nothing trims the conversation to a token budget automatically, so a long-running conversation keeps growing unless you set bounds.

Default values

Prior-turn strategies

Projection strategies for Current Context

A ## Current Context value over its limit is replaced by a marker object (_contextLimited: true) carrying its original type and size, plus one of three levels of detail:
  • preview (the default) — the first part of the value, as text.
  • summary — the value’s shape: types, lengths, key names, and up to three sample items.
  • metadata — type and size only.

Where to set compaction policies

  • Per agent, in ABL — the EXECUTION.compaction block. See Compaction policy overrides for the full property reference.
  • Per project — the project runtime configuration, set by API or project import. Studio’s Runtime Config tab exposes these controls only for the voice latency profile overrides; the project-wide section is not editable from Studio.
  • Per tool — compaction: essential_fields, summary_timeout_ms, and, for knowledge bases, max_search_tokens. See Result compaction.
The compaction policy is resolved once per conversation. In a multi-agent project, set compaction at the project level, or set it the same way on every agent in a handoff chain — it is not re-resolved on handoff.
Memory sections (## Session Memory, ## Granted Memory, ## Gather Progress) are not covered by these limits. Keep declared memory small — see Memory and state. For a single large tool result, a MODEL_CONTEXT view is a better tool than raising a size limit: it’s exact, and it costs no extra model call.

Controlling context size

You control three things: which values may enter the prompt, how large each piece may be, and how long tool output stays around. Most parts of the prompt have a default size limit you can change. Two parts have none — the conversation history and declared session memory — so uncontrolled growth usually starts there. Most cuts leave a marker you can find in a trace; knowledge-base chunk drops and the structural shortening of long lists before a summary do not.

Where context grows

Where context gets cut

A budget recipe for a production agent

  1. Declare BEHAVIOR: role: so only declared and granted values reach ## Current Context.
  2. Give every tool with a large or nested result a MODEL_CONTEXT, and save the fields later turns need with on_result: SET.
  3. Keep declared session memory to small scalars. Use RESET: for scratch values.
  4. Use history: last_n or summary_only with a summary on handoffs in long conversations. Pass state with pass, not history.
  5. Set max_search_tokens on every knowledge base, lower for voice.
  6. Set compaction once at the project level so every agent in a handoff chain uses the same budgets, then tune each agent only where needed.
  7. Run a 20-turn test conversation, then check the trace’s Request view and the session Overview’s Token Breakdown for growth from turn to turn.

Debugging a bloated or truncated prompt

Open a session’s Traces tab, pick an LLM step, and open its Request view (see LLM step request and response). Search systemPrompt and messages for _contextLimited, truncated, _summarized, COMPACTED FOR CHAT HISTORY, and Prior response. Also look for Prior turn result, Result available, and an “unavailable” marker. Knowledge-base results leave no marker in the trace, so compare their size against max_search_tokens directly. If the prompt is large and none of these markers explain it, the size is coming from conversation history or a memory section, and the levers in Where context grows apply.

Common mistakes

  • There is no per-entry switch to hide one declared memory value from the model. Either don’t declare it, or supply it through a runtime-supplied tool parameter instead.
  • There is no automatic token cap on conversation history. A long-running conversation needs prior_turns, MODEL_CONTEXT, and handoff history settings to stay bounded.
  • Compaction settings are resolved once per conversation, the first time they’re needed — usually by the agent that starts it — and are not refreshed on handoff. Set them consistently across a handoff chain instead of relying on the receiving agent’s own settings.
  • The automatic first knowledge-base search for a single-KB agent can’t be turned off. Control its size with max_search_tokens instead.
  • Studio’s Runtime Config tab edits project compaction only inside the voice profile. Set the project-wide section by API or project import.

Related articles: