归档线程
归档一个执行线程;归档后不再接收新事件。
先调用「创建会话」,用返回的会话 ID 替换示例 ID。
/agent/v1/sessions/{session_id}/threads/{thread_id}/archive◐ 部分支持请求参数
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.
thread_idstring必填path: Execution thread id (sthr_...), as listed by sessions.threads.list; the primary thread id equals the session's own thread. Unknown or foreign ids return 404.
session_idstring必填query: 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
主线程沿用会话归档动作;子线程仅归档对应子会话,不归档父会话或其他子线程。子线程归档后 status 为 terminated,带 archived_at;历史事件仍可读。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
响应
HTTP 200
Successful response
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| id | string | Unique identifier for this thread. |
| agent | object | The resolved agent a `session_thread` runs. |
| agent.model | string | object | The advisor model id. / Model identifier and configuration. |
| agent.type | string | Always `advisor`. An advisor whose model is consulted for advice in a separate thread (at most one per coordinator). / Always `agent`. A roster member that refers to an agent by id and pinned version. |
| agent.id | string | Agent id (agent_...). Pass it as agent when creating a session and as agent_id in agent calls. |
| agent.description | null | string | Free-text description of what the agent is for; null when none was set. |
| agent.mcp_servers | array<object> | URL MCP servers the agent can call, paired one-to-one with mcp_toolset entries in tools and saved with the agent version. No credentials are stored here. |
| agent.name | string | Display name of the agent, as set on create or update. It is a label, not a unique key. |
| agent.skills | array<object> | Skills attached to the agent. Setting skills is not supported on this platform and returns 400, so do not send this field on create or update. |
| agent.system | null | string | System prompt given to the model at the start of every session of this agent; null when none was set. |
| agent.tools | array<object> | Tools of the agent: one agent_toolset_20260401 entry for the native tools (all resolved settings are returned, ready to send back on update), plus mcp_toolset entries and custom tool definitions. |
| agent.version | number | The agent's current version. Starts at 1 and increments each time the agent is modified. |
| archived_at | null | string | A timestamp in RFC 3339 format |
| created_at | string | A timestamp in RFC 3339 format |
| parent_thread_id | null | string | Parent thread that spawned this thread. Null for the primary thread. |
| session_id | string | The session this thread belongs to. |
| stats | null | object | Timing statistics for a session thread. |
| stats.active_seconds | number | Cumulative time in seconds the thread spent actively running. Excludes idle time. |
| stats.duration_seconds | number | Elapsed time since thread creation in seconds. For archived threads, frozen at the final update. |
| stats.startup_seconds | number | Time in seconds for the thread to begin running. Zero for child threads, which start immediately. |
| status | string | SessionThreadStatus enum |
| type | string | Always `session_thread`. An execution thread of a session. |
| updated_at | string | A timestamp in RFC 3339 format |
| usage | null | object | Cumulative token usage for a session thread across all turns. |
| usage.active_seconds | number | Cumulative time in seconds this thread spent in running status. Equal to `stats.active_seconds`; surfaced here so a thread's usage carries every quantity its cost is priced on. |
| usage.cache_creation | object | Prompt-cache creation token usage broken down by cache lifetime. |
| usage.cache_read_input_tokens | number | Total tokens read from prompt cache. |
| usage.input_tokens | number | Total input tokens consumed across all turns. |
| usage.list_cost | null | object | A monetary amount in a specific currency. |
| usage.output_tokens | number | Total output tokens generated across all turns. |
| usage.server_tool_use | null | object | Cumulative count of server-executed tool invocations, broken down by tool. |