Skip to content
中文

Get Session Compaction (Extension)

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

GET/agent/v1/sessions/{session_id}/compact/{operation_id}● Supported

Request parameters

  • session_idstringrequired

    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_idstringrequired

    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

Request

curl
# Call Create session first and replace the example session ID with its returned ID.
curl https://api.deepraxis.com/agent/v1/sessions/sesn_123/compact/compaction_123 \
  -H "Authorization: Bearer $PRAXIS_API_KEY"
Python
# Call Create session first and replace the example session ID with its returned 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/compact/compaction_123",
    headers={"Authorization": f"Bearer {opts['api_key']}"},
)
print(resp.status_code, resp.json())
TypeScript
// Call Create session first and replace the example session ID with its returned 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/compact/compaction_123`, {
  headers: { Authorization: `Bearer ${opts.apiKey}` },
});
console.log(resp.status, await resp.json());

Response 200

{
  "type": "session_compaction",
  "id": "compact_584a8f3a-f204-4997-9261-ac9b725cf141",
  "status": "skipped",
  "reason": "No complete older turn can be compacted safely"
}

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, failed and cancelled are final.
reason string Why the compaction was skipped, failed or cancelled; absent otherwise.