Get Session Compaction (Extension)
Read session compaction status by operation ID.
Call Create session first and replace the example session ID with its returned ID.
/agent/v1/sessions/{session_id}/compact/{operation_id}● SupportedRequest 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.
operation_idstring必填path: Compaction operation id returned by sessions.compact in the id field of the session_compaction object.
Returns
200
Available only on /agent/v1. Returns { type: session_compaction, id, status, reason? } with HTTP 200 for every status. A missing operation or inaccessible session returns 404 not_found_error.
Errors follow the Anthropic error format (type / message / request_id) — see error codes
Response
HTTP 200
Compaction operation
application/json
| Name | Type | Description |
|---|---|---|
| type | string | Always `session_compaction`. Result of a compaction request. |
| id | string | Compaction operation id; pass it as operation_id to sessions.compact.retrieve. |
| status | string | State of the compaction operation: queued and running are in progress, skipped means nothing needed compaction, succeeded and failed are final. |
| reason | string | Why the compaction was skipped or failed; absent otherwise. |