列出压缩历史(扩展)
先调用「创建会话」,用返回的会话 ID 替换示例 ID。
GET
/agent/v1/sessions/{session_id}/compactions● 支持请求参数
session_idstring必填path: 会话 ID(sesn_...),由 sessions.create 或 sessions.list 返回。资源和线程调用的 session_id 查询参数也接受同一 ID,且必须与路径值一致。
返回
200
仅在 /agent/v1 提供。返回 { data: [...], active }。active 为当前排队或运行中的压缩(type、id、status、trigger),没有时为 null,手动操作优先。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),参见 错误码
请求示例
curl
# 先调用「创建会话」,用返回的会话 ID 替换示例 ID。
curl https://api.deepraxis.com/agent/v1/sessions/sesn_123/compactions \
-H "Authorization: Bearer $PRAXIS_API_KEY"Python
# 先调用「创建会话」,用返回的会话 ID 替换示例 ID。
import requests
opts = dict(
base_url="https://api.deepraxis.com/agent",
api_key="$PRAXIS_API_KEY",
)
# /agent 是我们自己的 Managed Agents 形状,直接发 HTTP 请求(Bearer 认证)
resp = requests.get(
f"{opts['base_url']}/v1/sessions/sesn_123/compactions",
headers={"Authorization": f"Bearer {opts['api_key']}"},
)
print(resp.status_code, resp.json())TypeScript
// 先调用「创建会话」,用返回的会话 ID 替换示例 ID。
const opts = {
baseURL: "https://api.deepraxis.com/agent",
apiKey: "$PRAXIS_API_KEY",
};
// /agent 是我们自己的 Managed Agents 形状,直接发 HTTP 请求(Bearer 认证)
const resp = await fetch(`${opts.baseURL}/v1/sessions/sesn_123/compactions`, {
headers: { Authorization: `Bearer ${opts.apiKey}` },
});
console.log(resp.status, await resp.json());响应示例 200
{
"data": []
}响应
HTTP 200
Compaction history
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| active | object | null | Current compaction, including queued manual requests; null when none is in progress. Manual takes precedence over automatic work. |
| active.type | string | Always session_compaction. Result of a compaction request. |
| active.id | string | Identifier of the active manual operation or automatic compaction record. |
| active.status | string | Whether compaction is waiting to start or generating its summary. |
| active.trigger | string | Whether a caller requested compaction, the context reached its threshold, or the session compacted while idle. |
| 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. |