智能体
读取压缩操作(扩展)
按操作 ID 查询会话压缩状态。
先调用「创建会话」,用返回的会话 ID 替换示例 ID。
GET
/agent/v1/sessions/{session_id}/compact/{operation_id}● 支持请求参数
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.
返回
200
仅在 /agent/v1 提供。响应为 { type: session_compaction, id, status, reason? },所有状态均返回 200。操作不存在或会话不可见时返回 404 not_found_error。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
响应
HTTP 200
Compaction operation
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| 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. |