← Blog

Anthropic Compaction Triggers Need Route Controls

Parminder Singh
Parminder Singh··5 min read
Summarize with AI

Anthropic threshold compaction summarizes older conversation context when input tokens reach a configured value. The Messages API defaults that trigger to 150,000 tokens and requires at least 50,000. A gateway should constrain the beta header, strategy, trigger, pause behavior, and custom instructions by route, then verify the returned compaction block and later round trip.

AI Security Solutionsai-securityllm-securitypolicy-enforcementzero-trustarchitectureaudit
Anthropic Compaction Triggers Need Route Controls

Anthropic threshold compaction activates inside an ordinary Messages request when input tokens reach a configured value. The API summarizes older context, returns a compaction block, and continues from that summary. Current documentation gives compact_20260112 a 150,000-token default trigger and a 50,000-token minimum.

I want the trigger treated as a route control rather than a caller preference. A summary changes the evidence Claude receives, and a low threshold can repeatedly replace exact history with generated text.

TL;DR

  • Allow compact_20260112 and its beta header only on routes tested for threshold compaction.
  • Constrain the input-token trigger between a route floor and ceiling; Anthropic's documented minimum is 50,000 tokens.
  • Control pause_after_compaction and custom instructions separately because each changes workflow behavior.
  • Preserve the returned compaction block in later requests and record its position, signature presence, provider request ID, and usage.

Threshold compaction runs inside the request

Anthropic's threshold compaction guide describes four steps. The API detects that input tokens reached the trigger, generates a summary, creates a compaction block, and continues the response with compacted context. On later requests, the application appends that response as usual. The API drops content that appeared before the compaction block.

The strategy lives under context_management.edits and uses the compact-2026-01-12 beta header. The trigger supports one type, input_tokens. Its default value is 150,000, and Anthropic currently rejects values below 50,000. Those are provider contract facts. Enterprise policy still decides which authenticated route may use the feature and which range makes sense for its model and workload.

Do not confuse threshold compaction with context editing. Context editing clears selected tool results or thinking blocks by rule. Compaction asks Claude to summarize older conversation content. The control surface and loss model differ.

The route sets a trigger envelope

Start with the model's context window, typical input growth per turn, expected output allowance, tool-result size, and safety margin. Set a route floor that prevents constant summarization and a ceiling that leaves room for compaction to complete before the context window fills. Keep the provider's 50,000-token minimum as one input to that calculation rather than the application target.

A research-agent route carrying large search results may approach the trigger quickly. A customer-support route with short text turns could run for many exchanges before it arrives there. One global number hides those differences and makes a later model migration risky.

The gateway should reject unknown trigger types, fractions, strings, values below the provider minimum, and values outside the route envelope. Preserve omission as a distinct state because omission selects Anthropic's current default. If policy inserts or rewrites the value, expose the enforced trigger in the decision record.

My opinion is simple: a production route should never rely silently on the 150,000-token default. Defaults are useful for examples. Named policies are useful during incidents.

The per-route AI policy pattern gives this value an owner and version. It also gives the value a rollout boundary.

Pause behavior changes the application state machine

Anthropic documents pause_after_compaction, which defaults to false. With the default, the API writes the summary and continues the same response. When enabled, the application can stop after compaction, inspect the result, reinsert recent turns under the documented flow, and make another request.

That boolean changes more than latency. It determines if the current HTTP exchange can produce a normal assistant answer after summarization. A consumer that expects one terminal response shape can misclassify a compaction-only outcome as an empty model response.

Authorize pause behavior by route. Record the requested flag and the response stop reason. Bound any follow-up loop as a separate request with its own deadline and token allowance. Treat it as a separate decision. A white dashboard row labeled compaction should sit apart from green end_turn responses, with the provider request ID printed in small type beside it. That physical distinction saves an on-call engineer from treating deliberate control flow as a model outage.

Custom instructions are prompt material

The instructions parameter replaces Anthropic's default compaction prompt. It can shape which details the generated summary preserves or omits. It can also change which details the summary emphasizes. Treat it with the same care as system prompt material. A caller who can alter compaction instructions can influence the long-term memory that later turns receive.

Prefer a route-owned instruction identifier resolved server-side. If inline custom instructions are necessary, cap their length and scan them under the route's prompt policy. Bind an approved digest to the deployment. Reject dynamic text assembled from untrusted tool output or user content. The compaction summary is still generated by the model, so downstream code should treat it as contextual text rather than an authoritative database record.

Anthropic's compaction overview also distinguishes threshold compaction from on-demand compaction. On-demand compaction uses a top-level compaction parameter and a separate request. Anthropic says the two approaches have different beta headers and handling rules. A gateway allowlist must recognize those as separate contracts.

The wider LLM API parameter allowlisting guide applies to both.

The block must survive the round trip

For threshold compaction, the returned block follows the messages it summarizes. The application appends the response on later requests, and Anthropic drops earlier content. Losing the block means losing the summary boundary. Moving it or rebuilding it can break the documented semantics.

Record block type, position, signature presence where supplied, summary digest, provider message ID, request ID, model, strategy, and usage iterations. Keep the full block in a protected conversation store when the workflow needs to send it back. General audit indexes can use a digest and artifact reference.

Inspect the actual serialized follow-up request at the HTTP gateway. An application object may contain the block while an outdated SDK serializer drops an unfamiliar beta type. The AI audit log schema can hold shared route and attempt fields around that round-trip evidence.

Trigger tests need boundary values and long histories

Build a synthetic conversation whose measured input tokens land just below or at the enforced trigger. Build another above the enforced trigger. Confirm that only the crossing cases return a compaction block. Run omission separately and verify the observed behavior against Anthropic's documented 150,000-token default.

Exercise 49,999, 50,000, a route-approved value, and a value above the route ceiling. The first should fail locally. The approved requests should reach the provider stub with the exact integer. Add wrong trigger types, strings, fractions, unknown strategy members, and a beta header without its matching strategy.

Run one case with pause_after_compaction enabled and verify that the application handles its terminal state. Use approved custom instructions, then mutate one word and confirm the digest policy catches it. Finally, append the returned block on a later request and assert its type and order. Compare its bytes at provider dispatch.

Anthropic API gateway guidance supplies the route and identity fixture around these cases.

DeepInspect

DeepInspect can enforce compaction strategy, beta header, trigger range, pause behavior, and instruction policy on authenticated user or agent HTTP traffic deliberately routed through its proxy to Anthropic. It can reject invalid combinations before provider dispatch and bind the returned compaction state to a per-decision record.

The application owns conversation storage, block round trips, stop-reason handling, and summary-quality tests. Anthropic generates the summary after receipt. Direct Claude calls and application traffic that bypasses the proxy remain outside this control.

Book a technical deep dive at deepinspect.ai.

Frequently asked questions

What is Anthropic's default threshold compaction trigger?

The current Messages API documentation states 150,000 input tokens for compact_20260112. The trigger value must be at least 50,000. Pin an enforced route value rather than depending silently on that default.

Does threshold compaction delete the stored conversation?

It changes the context Anthropic uses after the compaction block. The application still controls its own stored history. Local deletion and provider handling need retention records separate from model-visible compaction.

Can compaction and context editing share one policy entry?

They should use separate entries. Compaction generates a summary of older context. Context editing clears selected content blocks by strategy. Their beta headers, parameters, response behavior, and failure cases differ.

Are custom compaction instructions safe to accept from users?

Treat them as privileged prompt material. Prefer route-owned instructions. If a route accepts inline instructions, enforce length, content, identity, and digest policy before sending the request.