v1

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):

  1. Strip tool-result noise from the history.
  2. Ask the model to produce a structured <summary> of the conversation.
  3. Rebuild a compact window: system message → summary → last user query.
  4. Return that window to the client.
post/v1/responses/compact

Request body

modelstring required

Model to use for compaction summarization (required).

Response

Success – compacted window returned.

created_atinteger required

Unix timestamp (in seconds) when the compacted conversation was created.

idstring required

Unique ID for this compaction (e.g. cmp_<uuid>).

modelstring required

Model used for the compaction summary.

objectstring required

Always "response.compaction".

Changes

Changed in 1 of the 9 revisions of this API.11

  • 7df26eaf5d7c11See the full diff
    • added subschema #11 subschema #12 to the output/items/oneOf[subschema #2]/allOf[ModelOutput]/ response property oneOf list for the response status 200

      response-property-one-of-added

    • added subschema #11 subschema #12 to the input/oneOf[subschema #2]/items/oneOf[subschema #2]/allOf[ModelOutput]/ request property oneOf list

      request-property-one-of-added