How compaction works
When compaction is enabled, Claude automatically summarizes your conversation when it reaches the configured token threshold. The API:
- Detects when input tokens reach your specified trigger threshold.
- Generates a summary of the current conversation.
- Creates a
compactionblock containing the summary. - Continues the response with the compacted context.
On subsequent requests, append the response to your messages. The API automatically drops all content blocks prior to the compaction block, continuing the conversation from the summary.