Agent

List Session Compactions (Extension)

Read session compaction history and summaries.

Call Create session first and replace the example session ID with its returned ID.

GET /agent/v1/sessions/{session_id}/compactions● Supported

Request parameters

  • session_idstring必填

    path: Session id (sesn_...), as returned by sessions.create or sessions.list. The same id is also accepted as the session_id query parameter on resource and thread calls, where it must equal the path value.

Returns

200

Available only on /agent/v1. Returns { data: [...] }. Each entry contains type, id, event_id, trigger, status, model, compacted_message_count, input_tokens_before, input_tokens_after, summary, error and created_at, as recorded by the service. Missing or inaccessible managed sessions return 404 not_found_error.

Errors follow the Anthropic error format (type / message / request_id) — see error codes

Response

HTTP 200

Compaction history

application/json

NameTypeDescription
dataarray<object>Items of this page, in the order requested by the call.
data[].typestringAlways `context_compaction`. Record of one past compaction.
data[].idstringCompaction record id.
data[].event_idstring | nullId of the agent.thread_context_compacted event emitted for this compaction; null when none.
data[].triggerstringWhat started the compaction.
data[].statusstringFinal outcome of the compaction.
data[].modelstringModel that wrote the summary.
data[].compacted_message_countnumberNumber of messages replaced by the summary.
data[].input_tokens_beforenumberContext tokens before the compaction.
data[].input_tokens_afternumber | nullContext tokens after the compaction; null when not measured.
data[].summarystring | nullSummary text that replaced the messages; null when the compaction failed.
data[].errorstring | nullFailure reason; null when the compaction succeeded.
data[].created_atstringRFC 3339 time at which the compaction was recorded.