Source: Compaction (OpenAI guide)
OpenAI's guide to compacting long Responses API conversations, server-side via context_management or explicitly via /responses/compact, using opaque encrypted compaction items.
Contents
- What: official API documentation page
- Publisher: OpenAI
- Date: living document; read 2026-11-14
- Original: Compaction
Summary
Two ways to shrink a long conversation so it keeps fitting the context window, both producing an opaque compaction item the model can continue from.
Key claims
- Server-side:
context_management: [{type: "compaction", compact_threshold: N}]; when the rendered prompt crosses N tokens, the server compacts, emits a compaction item in the same stream and prunes context. - Standalone:
POST /responses/compacttakes a full window and returns a new, smaller one; it is stateless. - The compaction item is encrypted and not human-readable; compacted windows may also keep some earlier items.
- With manual input chaining, items before the latest compaction item can be dropped; with
previous_response_idchaining, do not prune manually; never prune/responses/compactoutput. - Both modes work with ZDR when
store=false.