智能体
列出压缩历史(扩展)
读取会话的压缩历史及摘要。
先调用「创建会话」,用返回的会话 ID 替换示例 ID。
GET
/agent/v1/sessions/{session_id}/compactions● 支持请求参数
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.
返回
200
仅在 /agent/v1 提供。返回 { data: [...] }。每项包含 type、id、event_id、trigger、status、model、compacted_message_count、input_tokens_before、input_tokens_after、summary、error、created_at,字段按服务记录原样返回。不存在或不可见的托管会话返回 404 not_found_error。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
响应
HTTP 200
Compaction history
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| data | array<object> | Items of this page, in the order requested by the call. |
| data[].type | string | Always `context_compaction`. Record of one past compaction. |
| data[].id | string | Compaction record id. |
| data[].event_id | string | null | Id of the agent.thread_context_compacted event emitted for this compaction; null when none. |
| data[].trigger | string | What started the compaction. |
| data[].status | string | Final outcome of the compaction. |
| data[].model | string | Model that wrote the summary. |
| data[].compacted_message_count | number | Number of messages replaced by the summary. |
| data[].input_tokens_before | number | Context tokens before the compaction. |
| data[].input_tokens_after | number | null | Context tokens after the compaction; null when not measured. |
| data[].summary | string | null | Summary text that replaced the messages; null when the compaction failed. |
| data[].error | string | null | Failure reason; null when the compaction succeeded. |
| data[].created_at | string | RFC 3339 time at which the compaction was recorded. |