Skip to main content

Compact a conversation

POST 

/api/v1/llm/compact-conversation

Triggers context compaction, summarizing older conversation messages. The trigger estimate can differ from the next request's actual size, especially after changing prompts or tools. Leave room below the model limit and handle context-limit errors.

When configured for asynchronous compaction, this call returns a pending result immediately. Use the returned compactionId to inspect the completed record in conversation-state's compactions array. Compaction can still delay other messages in the conversation; asynchronous acceptance does not guarantee uninterrupted concurrent messaging.

See Context and compaction for strategy selection and outcome handling.

Request​

Responses​

Compaction completed

Document ID: DOC-MA-conversations-api-compactConversation. Section identities and revisions.

SectionStable reference
OverviewDOC-MA-conversations-api-compactConversation#overview
RequestDOC-MA-conversations-api-compactConversation#request
ResponsesDOC-MA-conversations-api-compactConversation#responses