Skip to main content
As a conversation runs, the model’s context grows: more customer turns, agent replies, tool calls, and tool results. The runtime shrinks that context so it stays within model limits. It compresses large tool results, replaces older tool results with placeholders, and shortens earlier turns. You can tune these compaction policies per agent, per project, or per tool. This page lists the default budgets, shows where to set them, and explains how to find out why a prompt grew too large. To learn 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 turn:
  • tool_results: how tool output is shaped, on 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.
The platform merges them in this order. A later source overrides an earlier one:
  1. Platform defaults.
  2. The voice low-latency profile (voice channels only).
  3. Project settings.
  4. The agent’s EXECUTION.compaction.
  5. Per-tool hints.
These policies do not cap the total size of the conversation history. A long conversation keeps growing unless you set bounds. The platform can also summarize older messages when the history nears the model’s context window. See Automatic history summarization.

Default values

Tool-result strategies

The tool_results.strategy setting decides how the runtime shrinks a large tool result.

Prior-turn strategies

Projection strategies for Current Context

The platform replaces a ## Current Context value that is over its limit with a marker object (_contextLimited: true). The marker holds the original type and size, and one of three levels of detail:
  • preview (default): the first part of the value, as text.
  • summary: the value’s shape. It shows types, lengths, and key names, with up to 3 sample array items and up to 8 sample object keys.
  • metadata: type and size only.
When include_complete_small_tool_results is true (the default), an earlier tool result that fits its limit stays whole. Set it to false to project every earlier tool result with the strategy above.

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.
These limits do not cover memory sections (## Session Memory, ## Granted Memory, ## Gather Progress). Keep declared memory small, and set MODEL_VISIBLE: false on values the model does not need. See Memory and state. For one large tool result, use a MODEL_CONTEXT view instead of a higher size limit. It is exact and costs no extra model call.

Automatic history summarization

The platform can summarize older messages when the history nears the model’s context window. It keeps the most recent messages (at least 10) and replaces the older ones with one summary message that starts with [Conversation Summary]. The check runs before each model call.
  • Off by default. An operator turns it on with the platform setting SESSION_COMPACTION_ENABLED.
  • Trigger. The estimated history size reaches 80% of the model’s context window. An agent can change the ratio with compaction_threshold (0.0 to 1.0) in EXECUTION. See Configuration properties.
  • Cost. Each summary is one 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

  • Declared memory is not size-limited. To keep one declared value away from the model, set MODEL_VISIBLE: false on it. An explicit {{value}} reference in prompt text still shows it. See How a turn is built.
  • History has no automatic token cap. A long conversation needs prior_turns, MODEL_CONTEXT, and handoff history settings to stay bounded. Automatic summarization helps only if an operator turns it on.
  • Compaction settings do not refresh on handoff. The platform resolves them once per conversation, the first time it needs them. This is usually the agent that starts the conversation. Set the same values across a handoff chain. Do not rely on the receiving agent’s own settings.
  • The automatic first knowledge-base search is off by default. It runs only when the knowledge tool sets kb_fast_path: on. When it is on, control the size of its results with max_search_tokens.
  • Studio edits project compaction only inside the voice profile. Set the project-wide section by API or project import.

Related articles: