Anthropic & Claude

Compaction on demand: the Messages API summarises when you say so

3 min read AI-generated

The call returns no reply at all, just one signed block. It is still billed and rate-limited like any other request.

Featured image for "Compaction on demand: the Messages API summarises when you say so"

Anthropic shipped a second flavour of compaction in the Messages API yesterday, in beta behind the compact-2026-09-04 header. The difference to the existing one sounds minor. For agents it is not.

Before: the threshold decides

Compaction used to run off a threshold. You put compact_20260112 into context_management.edits, set a value for input_tokens — 150,000 by default, nothing below 50,000 allowed — and the API summarises partway through a request once that value is hit. The resulting block sits after the messages it summarises.

That works. But the timing belongs to the API rather than to you, and the request waits while the summary is written.

Now: you ask when it suits you

The new piece is a top-level parameter: compaction: {"type": "summarize"}. The API then summarises everything in the request, writes no reply, and hands back a single signed block with stop_reason: "compaction".

That block replaces the messages instead of following them. From then on you send it first, with only the turns taken since behind it. Leave the old messages in front of it and you get a 400.

Three things follow that were not possible before. You pick the moment. The summary can be produced in the background while the conversation carries on against the full history, and you swap the block in when it arrives. And recent turns can stay word for word after the summary.

What to know before you wire it up

The call uses the request’s model, system prompt, tools, thinking settings and max_tokens. The summariser reads the tool definitions but never calls one. Worth noting: max_tokens caps the entire call, thinking included, so budget a few thousand tokens.

Top-level usage shows zero input and output tokens, because no reply was generated — the real consumption sits in usage.iterations as the compaction entry. If the last assistant turn ends in a tool call with no result yet, the API rejects the request. And compaction and context_management cannot share a request.

It is Claude API only, on Opus 5, Opus 4.8, 4.7 and 4.6, Sonnet 5 and 4.6, plus the Fable and Mythos models.

The real win is in the thinking

The sentence that matters sits well down the docs page: on models with preserved thinking, the thinking blocks in turns that follow the summary can stay valid after the swap.

Anyone who has run an agent for hours knows why that counts. Compaction has always been a break as well as a saving: the context gets smaller, and the chain of thought from the last few steps is gone with it. An agent that can hold its thread across the summary is worth more than any token you save.

Sources

AnthropicClaude APIContextAgents