Summarizer
Condenses oversized tool output for the model while you still see the original.
Slot: context · Ships: off · Enable per agent in agent.toml
When you want it
Agents with verbose tools (shell, file reads, web fetches) that fill the context window quickly.
A single cargo test run or a fetched web page can be tens of thousands of characters, almost all
of it noise the agent does not need to act on. Left alone, those results crowd out the earlier
conversation and force compaction sooner. This middleware sends the oversized result to a model,
gets back a few sentences, and gives the agent those sentences instead - so a session survives many
more turns before it has to compact.
What it does
When a tool returns more text than the threshold, the model is given a condensed version instead of the whole thing, and the user still sees the full output.
The condensing is done by a real model call, so it costs tokens. That spend counts against the run's own budget rather than being invisible to it.
Only the model's copy is changed. The user's view, the audit log, and anything else reading the true output are untouched.
Turn it on
[middleware.summarizer]
enabled = trueSettings
| Key | Default | What it does |
|---|---|---|
threshold_chars | 4000 | Outputs at or above this size are summarized. |
model | agent default | Model used to write the summary. |
timeout_secs | 20 | Budget for one summary call; a slower call is abandoned. |
A typo in any of these keys fails the boot rather than being silently ignored.
A small, fast model is the right choice for model - the job is compression, and the call happens
inline while the agent waits.
What each side sees
Only the model's copy changes. The tool result event your client renders, the audit log entry, and the run observer all keep the full original output, byte for byte. Nothing is lost; the agent just reads a shorter version.
The model's copy opens with a line naming the original size, so the agent knows it is holding a condensed form and roughly how much it stands for:
[Condensed from 18432 characters of tool output; the user received the full text.]
The build failed in crate `agent-core` with two type errors in src/llm/mod.rs ...What is never summarized
- Error results. The agent needs the real error text to recover, so failures pass through whole however long they are.
- Elicitation answers. Those are the user's own words, not a tool computation.
- Anything already replaced. If another middleware has already blocked or rewritten the model's
copy - a
loop_guardstop instruction, a cache hit - that copy stands and is only condensed if it is itself over the threshold.
Caveats
- A failed summary is never fatal. If the summary model errors, returns nothing, or runs past
timeout_secs, the tool result reaches the model unchanged and a warning is logged. A tool result is never dropped because summarization failed. - A summary that is not smaller is discarded. With a low
threshold_chars, or a model that answers at length, the condensed form can end up larger than the output it replaces. The middleware compares the two and leaves the tool result unchanged rather than spending a call to make the context worse. - It costs a model call. One extra call per oversized result, charged to whatever provider key
the agent runs on, and its tokens are folded into the run's own budget at the end of the step
that spent them. A run with many oversized results reaches
max_tokenssooner than its own turns alone would. - It adds latency inline. The summary is written while the agent waits for its tool results, and several oversized results in one batch are summarized one after another.
- Very large outputs are truncated before summarizing. Only the first 200,000 bytes reach the
summary model - past that the provider rejects the request outright - so the summary describes
the beginning of a large output. That ceiling is in bytes while
threshold_charsis in characters, so text outside ASCII hits it sooner than the number suggests. The user's copy is still complete. - Summaries are prose. If a downstream tool call needs an exact identifier that
appeared in a long result, prefer a higher
threshold_charsfor that agent - the summary prompt asks for identifiers and paths to be kept, but a summary is never a substitute for exact output.
Check it is loaded
axl weave print --config axl-config/agents/<your-agent>/agent.tomlsummarizer appears in the context band of the printed stack.
Next
- Manage long conversations - the loop-level context controls.
- Tool result cache - avoid re-fetching the output you just summarized.
- All middleware - the full stack and slot ordering.