Skip to main content

Claude API Adds Background Conversation Compaction for Long-Running Agents

3 min read

Claude API compaction replaces old message history with a signed summary block while preserving a recent tail. This guide maps the new failure modes.

Claude API Adds Background Conversation Compaction for Long-Running Agents

Anthropic has added on-demand compaction to the Claude API. It can replace old conversation history with a signed summary block and keep recent messages verbatim. That helps long-running agents, but it creates a strict new transcript contract.

The September 14, 2026 release introduces the beta identifier compact-2026-09-04 and a top-level compaction request field. The official compaction guide says the result is not a user-facing reply. It is a signed summary block intended to replace earlier messages in the next API request.

What changes in the message ledger

Before compaction, the application sends a growing series of user and assistant messages. After compaction, the application should send the returned compaction block followed by the preserved recent tail and any new user turn. The block represents the removed history.

Transcript elementAfter compaction
Old messages covered by the summaryRemove them
Signed compaction blockStore without alteration
Recent tail selected for retentionKeep verbatim after the block
New user messagesAppend after the preserved tail

The 400 error reveals the core invariant

Anthropic warns that leaving old messages before their compaction block can produce a 400 error. The block is a replacement boundary, not an annotation that can sit alongside the original history. A database schema that only appends events needs an explicit materialized view or compaction checkpoint so it can rebuild the legal request order.

Background compaction changes job coordination

On-demand compaction can be started and completed in the background. That is useful when an agent has quiet time between tasks. It also introduces a race: a new user message can arrive while the old transcript is being summarized. Production code should bind the compaction result to the exact transcript revision it covered and reject stale results.

  1. Record the final message ID included in the compaction job.
  2. Store the returned signed block as an immutable object.
  3. Attach only later messages as the new tail.
  4. Retry from the last valid checkpoint if the job fails.

Compaction and context management are mutually exclusive

Anthropic says the compaction field cannot be combined with context_management. That prevents two context-shaping systems from rewriting the same request. Teams should choose one strategy per request path and log that choice. Otherwise, the source of a missing detail becomes difficult to diagnose.

A summary is not a perfect memory

Compaction trades token volume for a generated representation. A signed block protects integrity, but it does not guarantee that every nuance survived summarization. High-risk systems should keep the source transcript in auditable storage and test whether the compacted agent preserves commitments, tool results, permissions, unresolved questions and user preferences.

Four evaluations matter before production

  • Recall: can the resumed agent answer questions whose evidence lived only in compacted history?
  • State safety: does it preserve outstanding actions, approvals and denials?
  • Concurrency: what happens when a user message arrives during background work?
  • Cost: how often does compaction run, and how much context does it remove?

Our Claude Fable 5.1 API migration guide covers another context-cost change. The Spotify Shunt analysis shows why reducing tool and repository context can matter as much as reducing conversation history.

Supported models and rollout boundary

Anthropic’s documentation lists current Claude API support across Fable 5.1, Mythos 5.1, Opus 5 and Sonnet 5 models. The feature is beta, so teams should pin the beta identifier, monitor the release notes and retain a non-compacted rollback path.

The practical verdict

Claude API compaction gives long-running agents a first-party way to reduce history without discarding the newest turns. Its value depends on treating the signed block as a transcript replacement boundary, not as ordinary summary text.

Primary source

Checked September 15, 2026. API behavior and restrictions come from Anthropic. Concurrency controls and evaluation recommendations are MustHave.ai analysis.

Leave a comment

Your email address will not be published. Required fields are marked *