loading
loading
Automatically summarizing earlier conversation history server-side when a long session approaches the context window limit.
Enabled with a beta header, compaction condenses old turns into a summary block once the conversation nears a trigger threshold, letting a session run far past where it would otherwise overflow. The critical gotcha: you must append the full response.content (not just the text) back to your messages every turn — the compaction blocks in the response are what the API uses to replace the compacted history, and extracting only the text silently loses that state. Unlike context editing, which deletes stale content, compaction summarizes it, so information is preserved in lossy form rather than dropped.
Plainly
Think of Compaction as a simple recipe for doing the work better. Automatically summarizing earlier conversation history server-side when a long session approaches the context window limit.
In practice
Use it when you need a repeatable method instead of guessing from vibes. In practice, define the owner, input, output, and failure mode before you rely on it.