v4
latestOpenAPI 3.1.02026-08-0143190206.8 KBv1
Compacts a full Responses API input window into a shorter canonical window.
The client sends its current input (the same items that would be passed to POST /v1/responses) and receives a compacted output window. The output should be used verbatim as the input of the next /v1/responses call (appending only the new user turn).
This generalizes the compaction approach used by the coding-agent harness (generate_session_compact in xai-grok-shell):
- Strip tool-result noise from the history.
- Ask the model to produce a structured <summary> of the conversation.
- Rebuild a compact window: system message → summary → last user query.
- Return that window to the client.
post/v1/responses/compact
Request body
Response
Success – compacted window returned.