2026-10-20
(待译)
Agent runs versioned agents and conversations through /agent/v1. Concepts and behavior follow Anthropic Managed Agents (agents, environments, sessions and events), so Anthropic Managed Agents experience applies. Differences: omitting environment_id selects a light machine unless a Computer is selected, and self-hosted environments are unavailable; the native toolset includes codemode, Skill and subagents, while /anthropic/v1 sessions expose only the eight official tools; nonempty skills attachments and custom tools are rejected; native events include steering, withdrawal, notifications, forks and goals, with remembered permissions and question answers on approvals. Start with praxis.agent.agents.create, then open a session and read its events for the result.
加载中…| 方法 | 路径 | 说明 | 支持 |
|---|---|---|---|
| POST | /v1/computers | 创建电脑 | ● 支持 |
| GET | /v1/computers | 列出电脑 | ● 支持 |
| GET | /v1/computers/{computer_id} | 读取电脑 | ● 支持 |
| POST | /v1/computers/{computer_id} | 更新电脑 | ● 支持 |
| POST | /v1/computers/{computer_id}/archive | 归档电脑 | ● 支持 |
| DELETE | /v1/computers/{computer_id} | 删除已归档电脑 | ● 支持 |
| GET | /v1/computers/{computer_id}/files | 浏览电脑文件 | ● 支持 |
| GET | /v1/computers/{computer_id}/files/content | 读取电脑文件内容 | ● 支持 |
| POST | /v1/computers/{computer_id}/connect | 连接电脑 | ● 支持 |
| POST | /v1/computers/{computer_id}/attachments | 上传电脑附件 | ● 支持 |
| 方法 | 路径 | 说明 | 支持 |
|---|---|---|---|
| POST | /v1/sessions/{session_id}/resources | 添加会话资源 | ◐ 部分支持 |
| GET | /v1/sessions/{session_id}/resources | 列出会话资源 | ◐ 部分支持 |
| GET | /v1/sessions/{session_id}/resources/{resource_id} | 读取会话资源 | ◐ 部分支持 |
| DELETE | /v1/sessions/{session_id}/resources/{resource_id} | 删除会话资源 | ◐ 部分支持 |
| 方法 | 路径 | 说明 | 支持 |
|---|---|---|---|
| GET | /v1/agents | 列出智能体 | ● 支持 |
| POST | /v1/agents | 创建智能体 | ◐ 部分支持 |
| GET | /v1/agents/{agent_id} | 读取智能体 | ● 支持 |
| POST | /v1/agents/{agent_id} | 更新智能体 | ◐ 部分支持 |
| GET | /v1/agents/{agent_id}/versions | 列出版本 | ● 支持 |
| POST | /v1/agents/{agent_id}/archive | 归档智能体 | ● 支持 |
| 方法 | 路径 | 说明 | 支持 |
|---|---|---|---|
| GET | /v1/sessions | 列出会话 | ◐ 部分支持 |
| POST | /v1/sessions | 创建会话 | ◐ 部分支持 |
| GET | /v1/sessions/{session_id} | 读取会话 | ● 支持 |
| POST | /v1/sessions/{session_id}/fork | 分支会话(扩展) | ● 支持 |
| GET | /v1/sessions/{session_id}/context | 读取会话上下文(扩展) | ● 支持 |
| GET | /v1/sessions/{session_id}/background_tasks | 列出后台任务(扩展) | ● 支持 |
| GET | /v1/sessions/{session_id}/background_tasks/{task_id}/output | 读取后台任务输出(扩展) | ● 支持 |
| POST | /v1/sessions/{session_id}/background_tasks/{task_id}/stop | 停止后台任务(扩展) | ● 支持 |
| POST | /v1/sessions/{session_id}/compact | 压缩会话(扩展) | ● 支持 |
| GET | /v1/sessions/{session_id}/compact/{operation_id} | 读取压缩操作(扩展) | ● 支持 |
| GET | /v1/sessions/{session_id}/compactions | 列出压缩历史(扩展) | ● 支持 |
| GET | /v1/sessions/{session_id}/events | 列出事件 | ● 支持 |
| POST | /v1/sessions/{session_id}/events | 发送事件 | ◐ 部分支持 |
| GET | /v1/sessions/{session_id}/events/stream | 订阅事件 | ◐ 部分支持 |
| POST | /v1/sessions/{session_id} | 更新会话 | ◐ 部分支持 |
| POST | /v1/sessions/{session_id}/archive | 归档会话 | ● 支持 |
| 方法 | 路径 | 说明 | 支持 |
|---|---|---|---|
| GET | /v1/sessions/{session_id}/threads | 列出线程 | ◐ 部分支持 |
| GET | /v1/sessions/{session_id}/threads/{thread_id} | 读取线程 | ◐ 部分支持 |
| GET | /v1/sessions/{session_id}/threads/{thread_id}/events | 列出线程事件 | ◐ 部分支持 |
| GET | /v1/sessions/{session_id}/threads/{thread_id}/stream | 订阅线程事件 | ◐ 部分支持 |
| POST | /v1/sessions/{session_id}/threads/{thread_id}/archive | 归档线程 | ◐ 部分支持 |
| 方法 | 路径 | 说明 | 支持 |
|---|---|---|---|
| POST | /v1/environments | 创建环境 | ◐ 部分支持 |
| POST | /v1/environments/{environment_id} | 更新环境 | ◐ 部分支持 |
| POST | /v1/environments/{environment_id}/archive | 归档环境 | ◐ 部分支持 |
| GET | /v1/environments | 列出环境 | ◐ 部分支持 |
| GET | /v1/environments/{environment_id} | 读取环境 | ◐ 部分支持 |
| 方法 | 路径 | 说明 | 支持 |
|---|---|---|---|
| GET | /v1/toolsets | 列出工具集 | ● 支持 |
原生工具与参数以本站各端点说明及 /meta/v1/openapi.yaml 为准;Claude Managed Agents 官方文档描述兼容 API 的官方字段。
错误按 Anthropic 错误格式返回(type / message / request_id),参见错误;额度与响应头参见限流。
/agent/v1/environments◐ 部分支持namestring必填Human-readable name for the environment
metadataobject可选User-provided metadata key-value pairs
configobject可选Environment configuration
typestring必填Self-hosted environment selector; unsupported here and rejected with 400. Use a cloud environment instead.
networkingobject可选Network configuration policy. Omit on update to preserve the existing value.
packagesobject可选Specify packages (and optionally their versions) available in this environment. When versioning, use the version semantics relevant for the package manager, e.g. for `pip` use `package==1.0.0`. You are responsible for validating the package and version exist. Unversioned installs the latest. Under `limited` networking, requires `networking.allow_package_managers` to be `true`.
descriptionstring可选Optional description of the environment
scopestring可选The visibility scope for this environment. 'organization' makes the environment visible to all accounts. 'account' restricts visibility to the owning account only. API organizations support only 'organization'; 'account' is rejected. If not specified, defaults based on organization type.
200
支持租户自建 cloud 环境、配置更新与软归档;内置环境只读。列表支持 limit、page 和 include_archived。limited 网络在沙箱创建时生效;安装失败会终止会话,错误码为 ENVIRONMENT_PACKAGE_INSTALL_FAILED。self_hosted、scope 和跨会话包缓存尚不支持。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
Successful response
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| id | string | Environment identifier (e.g., 'env_...') |
| archived_at | null | string | RFC 3339 timestamp when environment was archived, or null if not archived |
| config | object | Environment configuration (either Anthropic Cloud or self-hosted) |
| config.networking | object | Network configuration policy. |
| config.packages | object | Package manager configuration. |
| config.type | string | Environment type |
| created_at | string | RFC 3339 timestamp when environment was created |
| description | null | string | User-provided description for the environment; null when unset |
| metadata | object | User-provided metadata key-value pairs |
| name | string | Human-readable name for the environment |
| type | string | The type of object (always 'environment') |
| updated_at | string | RFC 3339 timestamp when environment was last updated |
| scope | string | The visibility scope for this environment. 'organization' means visible to all accounts. 'account' means visible only to the owning account. |
先调用「创建环境」,用返回的环境 ID 替换 env_123。
/agent/v1/environments/{environment_id}◐ 部分支持environment_idstring必填path: Environment id, as returned by environments.create or environments.list. Built-in environments can be read but not changed.
namestring可选Updated name for the environment
metadataobject可选User-provided metadata key-value pairs. Set a value to null or empty string to delete the key.
configobject可选Updated environment configuration
typestring必填Self-hosted environment selector; unsupported here and rejected with 400. Use a cloud environment instead.
networkingobject可选Network configuration policy. Omit on update to preserve the existing value.
packagesobject可选Specify packages (and optionally their versions) available in this environment. When versioning, use the version semantics relevant for the package manager, e.g. for `pip` use `package==1.0.0`. You are responsible for validating the package and version exist. Unversioned installs the latest. Under `limited` networking, requires `networking.allow_package_managers` to be `true`.
descriptionstring可选Updated description of the environment. Omit to preserve; null clears to null; an empty string is stored as an empty string.
scopestring可选The visibility scope for this environment. 'organization' makes the environment visible to all accounts. 'account' restricts visibility to the owning account only.
200
支持租户自建 cloud 环境、配置更新与软归档;内置环境只读。列表支持 limit、page 和 include_archived。limited 网络在沙箱创建时生效;安装失败会终止会话,错误码为 ENVIRONMENT_PACKAGE_INSTALL_FAILED。self_hosted、scope 和跨会话包缓存尚不支持。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
Successful response
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| id | string | Environment identifier (e.g., 'env_...') |
| archived_at | null | string | RFC 3339 timestamp when environment was archived, or null if not archived |
| config | object | Environment configuration (either Anthropic Cloud or self-hosted) |
| config.networking | object | Network configuration policy. |
| config.packages | object | Package manager configuration. |
| config.type | string | Environment type |
| created_at | string | RFC 3339 timestamp when environment was created |
| description | null | string | User-provided description for the environment; null when unset |
| metadata | object | User-provided metadata key-value pairs |
| name | string | Human-readable name for the environment |
| type | string | The type of object (always 'environment') |
| updated_at | string | RFC 3339 timestamp when environment was last updated |
| scope | string | The visibility scope for this environment. 'organization' means visible to all accounts. 'account' means visible only to the owning account. |
先调用「创建环境」,用返回的环境 ID 替换 env_123。
/agent/v1/environments/{environment_id}/archive◐ 部分支持environment_idstring必填path: Environment id, as returned by environments.create or environments.list. Built-in environments can be read but not changed.
200
支持租户自建 cloud 环境、配置更新与软归档;内置环境只读。列表支持 limit、page 和 include_archived。limited 网络在沙箱创建时生效;安装失败会终止会话,错误码为 ENVIRONMENT_PACKAGE_INSTALL_FAILED。self_hosted、scope 和跨会话包缓存尚不支持。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
Successful response
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| id | string | Environment identifier (e.g., 'env_...') |
| archived_at | null | string | RFC 3339 timestamp when environment was archived, or null if not archived |
| config | object | Environment configuration (either Anthropic Cloud or self-hosted) |
| config.networking | object | Network configuration policy. |
| config.packages | object | Package manager configuration. |
| config.type | string | Environment type |
| created_at | string | RFC 3339 timestamp when environment was created |
| description | null | string | User-provided description for the environment; null when unset |
| metadata | object | User-provided metadata key-value pairs |
| name | string | Human-readable name for the environment |
| type | string | The type of object (always 'environment') |
| updated_at | string | RFC 3339 timestamp when environment was last updated |
| scope | string | The visibility scope for this environment. 'organization' means visible to all accounts. 'account' means visible only to the owning account. |
/agent/v1/computers● 支持namestring必填Name of the entry or object.
environment_idstring可选Environment recipe id; null or omitted when none was selected.
201
Praxis 超集:MA 只有会话级临时容器与 memory_stores,没有可长期存续、可浏览的整台电脑。归档后文件仍可读,但不能用于新会话。environment_id 是可空配方引用;电脑默认使用 light sandbox,sandbox_id 为 SDK 可用的公开 ID。分页包含归档电脑。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
Computer result
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| type | string | Always `computer`. A computer. |
| id | string | Computer id (cmp_...), the computer_id of computer calls. |
| name | string | Display name of the computer, 1 to 255 characters. |
| sandbox_id | string | null | Public id of the sandbox that backs the computer, usable with the sandbox API; null while none has been created. |
| environment_id | string | null | Environment recipe the computer was created with; null when none. |
| status | string | active computers can be used by new sessions; archived ones keep their files readable but cannot start new sessions. |
| created_at | string | RFC 3339 time at which the computer was created. |
| updated_at | string | RFC 3339 time at which the computer was last modified. |
| archived_at | string | null | RFC 3339 time at which the computer was archived; null while active. |
/agent/v1/computers● 支持limitinteger可选query: Maximum number of items to return in this page: a positive integer, at most 100 (default 20; for session resources default and maximum are 1000). A larger value returns 400.
pagestring可选query: Opaque pagination cursor: pass the next_page value of the previous response unchanged. Omit it for the first page. A cursor from a different query or a malformed one returns 400.
200
Praxis 超集:MA 只有会话级临时容器与 memory_stores,没有可长期存续、可浏览的整台电脑。归档后文件仍可读,但不能用于新会话。environment_id 是可空配方引用;电脑默认使用 light sandbox,sandbox_id 为 SDK 可用的公开 ID。分页包含归档电脑。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
Computer result
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| data | array<object> | Items of this page, in the order requested by the call. |
| data[].type | string | Always `computer`. A computer. |
| data[].id | string | Computer id (cmp_...), the computer_id of computer calls. |
| data[].name | string | Display name of the computer, 1 to 255 characters. |
| data[].sandbox_id | string | null | Public id of the sandbox that backs the computer, usable with the sandbox API; null while none has been created. |
| data[].environment_id | string | null | Environment recipe the computer was created with; null when none. |
| data[].status | string | active computers can be used by new sessions; archived ones keep their files readable but cannot start new sessions. |
| data[].created_at | string | RFC 3339 time at which the computer was created. |
| data[].updated_at | string | RFC 3339 time at which the computer was last modified. |
| data[].archived_at | string | null | RFC 3339 time at which the computer was archived; null while active. |
| has_more | boolean | Whether more items exist beyond this page. |
| next_page | string | null | Opaque cursor for the next page: pass it unchanged as page to continue. Null when this is the last page. |
先调用「创建计算机」,用返回的计算机 ID 替换 cmp_123。
/agent/v1/computers/{computer_id}● 支持computer_idstring必填path: Computer id (cmp_...), as returned by computers.create or computers.list.
200
Praxis 超集:MA 只有会话级临时容器与 memory_stores,没有可长期存续、可浏览的整台电脑。归档后文件仍可读,但不能用于新会话。environment_id 是可空配方引用;电脑默认使用 light sandbox,sandbox_id 为 SDK 可用的公开 ID。分页包含归档电脑。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
Computer result
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| type | string | Always `computer`. A computer. |
| id | string | Computer id (cmp_...), the computer_id of computer calls. |
| name | string | Display name of the computer, 1 to 255 characters. |
| sandbox_id | string | null | Public id of the sandbox that backs the computer, usable with the sandbox API; null while none has been created. |
| environment_id | string | null | Environment recipe the computer was created with; null when none. |
| status | string | active computers can be used by new sessions; archived ones keep their files readable but cannot start new sessions. |
| created_at | string | RFC 3339 time at which the computer was created. |
| updated_at | string | RFC 3339 time at which the computer was last modified. |
| archived_at | string | null | RFC 3339 time at which the computer was archived; null while active. |
| implementation | string | How the computer is backed: a virtual file store or a real sandbox. |
| storage_bytes | integer | Bytes stored on the computer. |
| file_count | integer | Number of files stored on the computer. |
先调用「创建计算机」,用返回的计算机 ID 替换 cmp_123。
/agent/v1/computers/{computer_id}● 支持computer_idstring必填path: Computer id (cmp_...), as returned by computers.create or computers.list.
namestring必填Name of the entry or object.
200
Praxis 超集:MA 只有会话级临时容器与 memory_stores,没有可长期存续、可浏览的整台电脑。归档后文件仍可读,但不能用于新会话。environment_id 是可空配方引用;电脑默认使用 light sandbox,sandbox_id 为 SDK 可用的公开 ID。分页包含归档电脑。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
Computer result
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| type | string | Always `computer`. A computer. |
| id | string | Computer id (cmp_...), the computer_id of computer calls. |
| name | string | Display name of the computer, 1 to 255 characters. |
| sandbox_id | string | null | Public id of the sandbox that backs the computer, usable with the sandbox API; null while none has been created. |
| environment_id | string | null | Environment recipe the computer was created with; null when none. |
| status | string | active computers can be used by new sessions; archived ones keep their files readable but cannot start new sessions. |
| created_at | string | RFC 3339 time at which the computer was created. |
| updated_at | string | RFC 3339 time at which the computer was last modified. |
| archived_at | string | null | RFC 3339 time at which the computer was archived; null while active. |
先调用「创建计算机」,用返回的计算机 ID 替换 cmp_123。
/agent/v1/computers/{computer_id}/archive● 支持computer_idstring必填path: Computer id (cmp_...), as returned by computers.create or computers.list.
200
Praxis 超集:MA 只有会话级临时容器与 memory_stores,没有可长期存续、可浏览的整台电脑。归档后文件仍可读,但不能用于新会话。environment_id 是可空配方引用;电脑默认使用 light sandbox,sandbox_id 为 SDK 可用的公开 ID。分页包含归档电脑。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
Computer result
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| type | string | Always `computer`. A computer. |
| id | string | Computer id (cmp_...), the computer_id of computer calls. |
| name | string | Display name of the computer, 1 to 255 characters. |
| sandbox_id | string | null | Public id of the sandbox that backs the computer, usable with the sandbox API; null while none has been created. |
| environment_id | string | null | Environment recipe the computer was created with; null when none. |
| status | string | active computers can be used by new sessions; archived ones keep their files readable but cannot start new sessions. |
| created_at | string | RFC 3339 time at which the computer was created. |
| updated_at | string | RFC 3339 time at which the computer was last modified. |
| archived_at | string | null | RFC 3339 time at which the computer was archived; null while active. |
先调用「创建计算机」,用返回的计算机 ID 替换 cmp_123。
/agent/v1/computers/{computer_id}● 支持computer_idstring必填path: Computer id (cmp_...), as returned by computers.create or computers.list.
200
Praxis 扩展:Managed Agents 没有持久 Computer 的删除生命周期。仅允许已归档的电脑;active 返回 400 COMPUTER_ACTIVE(先归档),先销毁电脑数据再删除登记,成功返回 id 和 type=computer_deleted;不存在或跨租户返回 404。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
Computer result
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| id | string | Id of the deleted computer. |
| type | string | Always `computer_deleted`. Confirms that a computer was deleted. |
先调用「创建计算机」,用返回的计算机 ID 替换 cmp_123。
/agent/v1/computers/{computer_id}/files● 支持computer_idstring必填path: Computer id (cmp_...), as returned by computers.create or computers.list.
pathstring可选query: Directory on the computer to list; absolute path as returned in the path field of an earlier listing. Omit it to list from the computer's root.
200
Praxis 超集:MA 只有会话级临时容器与 memory_stores,没有可长期存续、可浏览的整台电脑。归档后文件仍可读,但不能用于新会话。environment_id 是可空配方引用;电脑默认使用 light sandbox,sandbox_id 为 SDK 可用的公开 ID。分页包含归档电脑。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
Computer result
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| data | array<object> | Items of this page, in the order requested by the call. |
| data[].path | string | Absolute path of the entry on the computer. |
| data[].name | string | Name of the entry or object. |
| data[].type | string | Kind of entry: a file, a directory or a symbolic link. |
| data[].size | integer | Size in bytes. |
| data[].mime_type | string | MIME type of the file. |
| data[].read_only | boolean | True when the entry cannot be modified through the API. |
| data[].digest | string | null | Content digest of the file; null when not computed. |
| data[].updated_at | string | null | RFC 3339 time at which the object was last modified. |
| has_more | boolean | Whether more items exist beyond this page. |
先调用「创建计算机」,用返回的计算机 ID 替换 cmp_123。
/agent/v1/computers/{computer_id}/files/content● 支持computer_idstring必填path: Computer id (cmp_...), as returned by computers.create or computers.list.
pathstring必填query: Absolute path of the file whose content to download, as returned in the path field of computers.files.list.
200
Praxis 超集:MA 只有会话级临时容器与 memory_stores,没有可长期存续、可浏览的整台电脑。归档后文件仍可读,但不能用于新会话。environment_id 是可空配方引用;电脑默认使用 light sandbox,sandbox_id 为 SDK 可用的公开 ID。分页包含归档电脑。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
Raw file bytes (at most 16 MiB); Content-Type is inferred from the extension. ETag is present only when a digest is available. Larger files require the sandbox connection issued by connect.
application/octet-stream
| 名称 | 类型 | 说明 |
|---|---|---|
| $ | string (binary) |
Single byte range
application/octet-stream
| 名称 | 类型 | 说明 |
|---|---|---|
| $ | string (binary) |
先调用「创建计算机」,用返回的计算机 ID 替换 cmp_123。
/agent/v1/computers/{computer_id}/connect● 支持computer_idstring必填path: Computer id (cmp_...), as returned by computers.create or computers.list.
200
Praxis 自有扩展:Managed Agents 没有持久 Computer 连接。返回 SDK 可用的公开 sandbox_id、envd_access_token 和 template_id。归档电脑仍可连接;跨租户或不存在返回 404。连接凭证不可缓存。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
Computer result
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| sandbox_id | string | Public id of the sandbox that backs the computer, usable with the sandbox API; null while none has been created. |
| envd_access_token | string | Access token for the sandbox's environment daemon, returned by the connect call; treat it as a secret. |
| template_id | string | Sandbox template the computer's sandbox was created from. |
先调用「创建计算机」,用返回的计算机 ID 替换 cmp_123。
/agent/v1/computers/{computer_id}/attachments● 支持computer_idstring必填path: Computer id (cmp_...), as returned by computers.create or computers.list.
namestring必填query: Single filename, at most 255 UTF-8 bytes, excluding slash, dot segments and control characters.
201
Praxis 扩展:Managed Agents 没有持久 Computer 附件目录。用户上传可以覆盖同名附件,智能体始终只读;运行令牌调用上传返回 403 READ_ONLY。name 是单个文件名、最多 255 UTF-8 字节,MIME 始终按扩展名推断,上传的 Content-Type 不持久保存,digest 可省略。上限 16 MiB,超限 413、非法名字 400;归档电脑也可上传,跨租户 404。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
Computer result
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| path | string | Absolute path of the entry on the computer. |
| name | string | Name of the entry or object. |
| type | string | Kind of entry: a file, a directory or a symbolic link. |
| size | integer | Size in bytes. |
| mime_type | string | MIME type of the file. |
| read_only | boolean | True when the entry cannot be modified through the API. |
| digest | string | null | Content digest of the file; null when not computed. |
| updated_at | string | null | RFC 3339 time at which the object was last modified. |
先调用「上传文件」,用返回的文件 ID 替换示例文件 ID。 先调用「创建会话」,用返回的会话 ID 替换示例 ID。
/agent/v1/sessions/{session_id}/resources◐ 部分支持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.
typestring必填query: Resource type selector for the body; only file resources are supported. Normally you send type inside the JSON body and omit this parameter.
file_idstring必填ID of a previously uploaded file.
mount_pathstring可选Mount path in the container. Defaults to `/mnt/session/uploads/<file_id>`.
200
支持 file 类型资源的持久化、查询和解除关联,单会话最多 500 条。文件须属于当前租户且有效。默认路径为 /mnt/session/uploads/<file_id>,自定义路径归一到该目录,拒绝父目录遍历。不修改文件内容;本批尚不将资源同步到沙箱。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
Successful response
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| id | string | Resource id, the resource_id of sessions.resources calls. |
| created_at | string | A timestamp in RFC 3339 format |
| file_id | string | Id of the uploaded file; it must exist and belong to your tenant. |
| mount_path | string | Path inside the machine where the file is mounted; defaults to /mnt/session/uploads/<file_id>, and custom paths are rooted there. |
| type | string | Always `file`. A file resource: an uploaded file mounted into the session's machine. |
| updated_at | string | A timestamp in RFC 3339 format |
先调用「创建会话」,用返回的会话 ID 替换示例 ID。
/agent/v1/sessions/{session_id}/resources◐ 部分支持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.
limitnumber可选query: Number of items per page.
pagestring可选query: Opaque pagination cursor: pass the next_page value of the previous response unchanged. Omit it for the first page. A cursor from a different query or a malformed one returns 400.
200
支持 file 类型资源的持久化、查询和解除关联,单会话最多 500 条。文件须属于当前租户且有效。默认路径为 /mnt/session/uploads/<file_id>,自定义路径归一到该目录,拒绝父目录遍历。不修改文件内容;本批尚不将资源同步到沙箱。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
Successful response
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| data | array<object> | Items of this page, in the order requested by the call. |
| data[].id | string | Resource id, the resource_id of sessions.resources calls. |
| data[].created_at | string | A timestamp in RFC 3339 format |
| data[].mount_path | string | null | string | Path inside the machine where the file is mounted; defaults to /mnt/session/uploads/<file_id>, and custom paths are rooted there. / Filesystem path where the store is mounted in the session container, e.g. /mnt/memory/user-preferences. Derived from the store's name. Output-only. |
| data[].type | string | Always `github_repository`. A GitHub repository resource; not supported on this platform. / Always `file`. A file resource: an uploaded file mounted into the session's machine. / Always `memory_store`. A memory store resource; not supported on this platform. |
| data[].updated_at | string | A timestamp in RFC 3339 format |
| data[].url | string | Repository URL. |
| data[].checkout | null | object | Branch or commit to check out. |
| data[].file_id | string | Id of the uploaded file; it must exist and belong to your tenant. |
| data[].memory_store_id | string | The memory store ID (memstore_...). Must belong to the caller's organization and workspace. |
| data[].access | null | string | Access mode for an attached memory store. |
| data[].description | string | Description of the memory store, snapshotted at attach time. Rendered into the agent's system prompt. Empty string when the store has no description. |
| data[].instructions | null | string | Per-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars. |
| data[].name | null | string | Display name of the memory store, snapshotted at attach time. Later edits to the store's name do not propagate to this resource. |
| next_page | string | null | Opaque cursor for the next page: pass it unchanged as page to continue. Null when this is the last page. |
先调用「创建会话」,用返回的会话 ID 替换示例 ID。 先调用「添加会话资源」,用返回的资源 ID 替换 sesrsc_123。
/agent/v1/sessions/{session_id}/resources/{resource_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.
resource_idstring必填path: Id of a resource attached to the session, as returned by sessions.resources.add or sessions.resources.list.
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
支持 file 类型资源的持久化、查询和解除关联,单会话最多 500 条。文件须属于当前租户且有效。默认路径为 /mnt/session/uploads/<file_id>,自定义路径归一到该目录,拒绝父目录遍历。不修改文件内容;本批尚不将资源同步到沙箱。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
Successful response
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| id | string | Resource id, the resource_id of sessions.resources calls. |
| created_at | string | A timestamp in RFC 3339 format |
| mount_path | string | null | string | Path inside the machine where the file is mounted; defaults to /mnt/session/uploads/<file_id>, and custom paths are rooted there. / Filesystem path where the store is mounted in the session container, e.g. /mnt/memory/user-preferences. Derived from the store's name. Output-only. |
| type | string | Always `github_repository`. A GitHub repository resource; not supported on this platform. / Always `file`. A file resource: an uploaded file mounted into the session's machine. / Always `memory_store`. A memory store resource; not supported on this platform. |
| updated_at | string | A timestamp in RFC 3339 format |
| url | string | Repository URL. |
| checkout | null | object | Branch or commit to check out. |
| checkout.name | string | Branch name to check out. |
| checkout.type | string | Always `branch`. Check out the named branch. / Always `commit`. Check out the commit with the given SHA. |
| checkout.sha | string | Full commit SHA to check out. |
| file_id | string | Id of the uploaded file; it must exist and belong to your tenant. |
| memory_store_id | string | The memory store ID (memstore_...). Must belong to the caller's organization and workspace. |
| access | null | string | Access mode for an attached memory store. |
| description | string | Description of the memory store, snapshotted at attach time. Rendered into the agent's system prompt. Empty string when the store has no description. |
| instructions | null | string | Per-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars. |
| name | null | string | Display name of the memory store, snapshotted at attach time. Later edits to the store's name do not propagate to this resource. |
先调用「创建会话」,用返回的会话 ID 替换示例 ID。 先调用「添加会话资源」,用返回的资源 ID 替换 sesrsc_123。
/agent/v1/sessions/{session_id}/resources/{resource_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.
resource_idstring必填path: Id of a resource attached to the session, as returned by sessions.resources.add or sessions.resources.list.
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
支持 file 类型资源的持久化、查询和解除关联,单会话最多 500 条。文件须属于当前租户且有效。默认路径为 /mnt/session/uploads/<file_id>,自定义路径归一到该目录,拒绝父目录遍历。不修改文件内容;本批尚不将资源同步到沙箱。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
Successful response
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| id | string | Identifier of the object, as returned by the API; pass it in the path of follow-up calls on the same resource. |
| type | string | Always `session_resource_deleted`. Confirms that a resource was detached from the session. |
/agent/v1/agents● 支持created_at[gte]string可选query: Return agents created at or after this time (inclusive).
created_at[lte]string可选query: Return agents created at or before this time (inclusive).
include_archivedboolean可选query: Include archived agents in results. Defaults to false.
limitnumber可选query: Number of items per page.
pagestring可选query: Opaque pagination cursor: pass the next_page value of the previous response unchanged. Omit it for the first page. A cursor from a different query or a malformed one returns 400.
200
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
Successful response
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| data | array<object> | Items of this page, in the order requested by the call. |
| data[].id | string | Agent id (agent_...). Pass it as agent when creating a session and as agent_id in agent calls. |
| data[].archived_at | null | string | A timestamp in RFC 3339 format |
| data[].created_at | string | A timestamp in RFC 3339 format |
| data[].description | null | string | Free-text description of what the agent is for; null when none was set. |
| data[].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. |
| data[].metadata | object | Free-form string key/value pairs stored with the agent for your own bookkeeping. |
| data[].model | object | Model identifier and configuration. |
| data[].multiagent | null | object | Resolved coordinator topology with a concrete agent roster. |
| data[].name | string | Display name of the agent, as set on create or update. It is a label, not a unique key. |
| data[].skills | array<object> | Skill attachments are not supported: a nonempty skills array returns 400. Omit this field or send an empty array. The native Skill tool loads available runtime skills independently of this field. |
| data[].system | null | string | System prompt given to the model at the start of every session of this agent; null when none was set. |
| data[].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; custom tool definitions are rejected with 400. Keep bash enabled to use codemode, Skill and subagents. |
| data[].type | string | Always `agent`. An agent definition. |
| data[].updated_at | string | A timestamp in RFC 3339 format |
| data[].version | number | The agent's current version. Starts at 1 and increments when the agent is modified. |
| data[].computer_id | string | Praxis extension: MA only has session-scoped temporary containers and memory_stores, not durable browsable computers. computer_id selects a tenant-owned active computer. Session selection overrides the agent default; a sandbox environment_id and computer_id cannot be combined. Omitted when no computer is selected. |
| data[].subagent_model | string | null | Praxis extension: default subagent model ID, pinned in the agent revision. Call model overrides this; otherwise it overrides the roster member model or the parent model for built-ins. Null clears the default. /agent/v1 only. |
| data[].models | object | Praxis extension: switchable model ids on /agent/v1 only. The default model must be included. When omitted, only the default model is selectable. |
| next_page | string | null | Opaque cursor for the next page: pass it unchanged as page to continue. Null when this is the last page. |
/agent/v1/agents◐ 部分支持namestring必填智能体名称,1–255 个字符,工作区内可读。
modelstring | object必填智能体使用的模型:直接写模型名字符串(如 claude-opus-5),或传对象做附加配置(见子字段)。
idstring必填模型名字符串,如 claude-opus-5。
effortstring | object可选每次推理的思考力度:可传级别字符串(如 high)或 {type: high} 对象。创建时省略取该模型的默认值;更新时省略保持不变。
inference_geostring可选模型推理的地理区域;不传沿用工作区默认。model 是整体替换字段,更新时省略子字段即清除该项。
speedstring可选推理速度模式:fast 出字显著更快但按溢价计费;并非所有模型都支持,不支持的组合在创建时被拒。
settingsobject可选Platform model settings. Only reasoning is supported; other model controls return 400.
systemstring可选智能体的系统提示词。
metadataobject可选自定义元数据键值对,最多 16 个键、每个值最长 512 字符。
descriptionstring可选智能体的用途说明。
mcp_serversarray可选智能体连接的 MCP 服务器列表,最多 20 个,名称必须唯一;每个服务器都要被 tools 里的 mcp_toolset 引用,否则整笔请求被拒。
typestring必填服务器类型,目前只支持 url。
namestring必填MCP 服务器在本列表内的唯一名称,1–255 个字符,供 mcp_toolset 配置引用。
urlstring必填MCP 服务器的端点地址。
multiagentobject可选◐ 部分支持多智能体协作拓扑:会话主线程作为协调者,从 agents 名单派生会话线程执行工作。
agentsarray必填协调者可以派生为会话线程的智能体名单,1–20 项;支持 ID 字符串、{type: agent, id, version?} 和最多一个 {type: self}。创建/更新时固定版本。成员须唯一、存在且未归档,不能自身带 multiagent。每个 coordinator 最多一个 advisor,模型须可用且不同于智能体模型;仅主会话可咨询,每次咨询为独立 advisor 线程,建议以 agent.thread_message_received 返回。
typestring必填拓扑类型,目前只有 coordinator。
skillsarray可选智能体可用的 Skill 列表。
toolsarray可选智能体可用的工具配置,所有工具合计最多 128 个。
computer_idstring可选Praxis extension: MA only has session-scoped temporary containers and memory_stores, not durable browsable computers. computer_id selects a tenant-owned active computer. Session selection overrides the agent default; a sandbox environment_id and computer_id cannot be combined.
subagent_modelstring可选/agent/v1 扩展:智能体级子智能体默认模型 ID,随修订固定。省略保持,null 清除。调用 model 优先,其次本字段,再其次名册成员模型或内置类型的父会话模型。/anthropic 不接受或返回此字段。
modelsobject可选扩展:可切换模型列表,仅 /agent/v1 支持。
allowedarray必填必须包含默认模型;创建时省略表示只能使用默认模型。更新时省略保持不变。会话使用其钉住版本的列表。
200
agent_toolset_20260401 是原生工具集,包含 bash、edit、glob、grep、read、write、web_search、web_fetch,以及 TaskOutput、TaskStop、Monitor、Agent、SendMessage。新建智能体默认全部启用;configs 可逐个设置 name、enabled、permission_policy,未列出的工具遵循 default_config(默认启用)。后台任务、Monitor 和子智能体依赖 bash;启用任一后台工具时,bash 提供 run_in_background。兼容 API /anthropic 只接受和返回官方 8 个工具,经该入口创建的会话也只注册这 8 个工具。 支持文本提示词、模型、元数据与内置工具。model.settings.reasoning 可选 low、medium、high、xhigh、none,为会话提供默认思考档位;会话显式 thinking 优先,不支持的默认值回退到模型 default_effort。示例 model: {id: "deepseek-v4-flash", settings: {reasoning: "high"}}。Skills 及其它额外模型控制尚不支持,传入会返回 400。可在工具集 permissions 中设置 allow、ask、deny 规则,最多共 100 条,用于以后的对话。 multiagent 接受 null 或 coordinator 名册,1–20 项:智能体 ID、{type:"agent",id,version?} 或最多一个 {type:"self"}。创建/更新时固定版本;成员去重且须存在、未归档、不能自身带 multiagent。名册可启用 Agent,仍需启用 bash;SendMessage 遵循工具配置。每个 coordinator 最多一个 advisor,模型须可用且不同于智能体模型;仅主会话可咨询,每次咨询为独立 advisor 线程,建议以 agent.thread_message_received 返回。 /agent/v1 顶层 subagent_model 是可空模型 ID,随智能体版本保存;省略保留、null 清除。模型须存在。优先级为调用 model > subagent_model > 成员模型(内置类型用父会话模型)。/anthropic 不接受或返回此字段。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
Successful response
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| id | string | Agent id (agent_...). Pass it as agent when creating a session and as agent_id in agent calls. |
| archived_at | null | string | A timestamp in RFC 3339 format |
| created_at | string | A timestamp in RFC 3339 format |
| description | null | string | Free-text description of what the agent is for; null when none was set. |
| 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. |
| mcp_servers[].type | string | Always `url`. An MCP server reached over a URL. |
| mcp_servers[].name | string | Name of the MCP server; the mcp_toolset entry that refers to it uses the same name in mcp_server_name. |
| mcp_servers[].url | string | http(s) endpoint of the MCP server, at most 2048 characters. |
| metadata | object | Free-form string key/value pairs stored with the agent for your own bookkeeping. |
| model | object | Model identifier and configuration. |
| model.id | string | The model that will power your agent. See models for additional details and options. |
| model.effort | object | How hard Claude works on each turn. Sets `output_config.effort` on every Messages call the session makes. |
| model.inference_geo | string | Geographic region for model inference. When unset, requests fall through to the workspace's default_inference_geo. |
| model.speed | string | Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time. |
| model.settings | object | Platform model settings. Only reasoning is supported; other model controls return 400. |
| multiagent | null | object | Resolved coordinator topology with a concrete agent roster. |
| multiagent.agents | array<object> | Agents the coordinator may spawn as session threads, each resolved to a specific version. |
| multiagent.type | string | Always `coordinator`. The agent coordinates the roster in agents and can delegate to its members. |
| name | string | Display name of the agent, as set on create or update. It is a label, not a unique key. |
| skills | array<object> | Skill attachments are not supported: a nonempty skills array returns 400. Omit this field or send an empty array. The native Skill tool loads available runtime skills independently of this field. |
| skills[].skill_id | string | Id of the skill to attach. |
| skills[].type | string | Always `anthropic`. A skill provided by Anthropic, identified by skill_id. / Always `custom`. A skill created by you, identified by skill_id. |
| skills[].version | string | Version of the skill; a string. |
| system | null | string | System prompt given to the model at the start of every session of this agent; null when none was set. |
| 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; custom tool definitions are rejected with 400. Keep bash enabled to use codemode, Skill and subagents. |
| tools[].configs | array<object> | array | null | Per-tool settings that override default_config. Tools that are not listed follow default_config. |
| tools[].default_config | object | object | null | Resolved default configuration for agent tools. / Settings applied to every tool of this toolset that configs does not name. When omitted, tools are enabled with the always_allow policy. |
| tools[].type | string | Always `agent_toolset_20260401`. The native toolset entry (bash, edit, glob, grep, read, write, web_search, web_fetch, TaskOutput, TaskStop, Monitor, Agent, SendMessage). / Always `mcp_toolset`. An entry that exposes the tools of one MCP server from mcp_servers. / Always `custom`. A custom tool defined by name, description and input_schema; its calls are answered by the client with user.custom_tool_result. |
| tools[].mcp_server_name | string | Name of the MCP server in mcp_servers whose tools this entry exposes. |
| tools[].description | string | What the custom tool does and when the model should call it. |
| tools[].input_schema | object | JSON Schema for custom tool input parameters. |
| tools[].name | string | Name of the custom tool, as the model sees and calls it. |
| type | string | Always `agent`. An agent definition. |
| updated_at | string | A timestamp in RFC 3339 format |
| version | number | The agent's current version. Starts at 1 and increments when the agent is modified. |
| computer_id | string | Praxis extension: MA only has session-scoped temporary containers and memory_stores, not durable browsable computers. computer_id selects a tenant-owned active computer. Session selection overrides the agent default; a sandbox environment_id and computer_id cannot be combined. Omitted when no computer is selected. |
| subagent_model | string | null | Praxis extension: default subagent model ID, pinned in the agent revision. Call model overrides this; otherwise it overrides the roster member model or the parent model for built-ins. Null clears the default. /agent/v1 only. |
| models | object | Praxis extension: switchable model ids on /agent/v1 only. The default model must be included. When omitted, only the default model is selectable. |
| models.allowed | array<string> | Model ids a session may select with its model field; it must be non-empty and must contain the agent's default model. |
先调用「创建智能体」,用返回的智能体 ID 替换示例 ID。
/agent/v1/agents/{agent_id}● 支持agent_idstring必填path: Agent id, as returned by agents.create or agents.list (for a session filter, the agent the session was created with). Not the agent name.
versionnumber可选query: Agent version to read; omit for the latest. Integer of at least 1; versions are listed by agents.versions.list.
200
tools 在一个 agent_toolset_20260401 条目中返回全部原生工具的有效配置,可原样用于更新。将示例中的资源 ID 替换成你创建的资源 ID。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
Successful response
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| id | string | Agent id (agent_...). Pass it as agent when creating a session and as agent_id in agent calls. |
| archived_at | null | string | A timestamp in RFC 3339 format |
| created_at | string | A timestamp in RFC 3339 format |
| description | null | string | Free-text description of what the agent is for; null when none was set. |
| 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. |
| mcp_servers[].type | string | Always `url`. An MCP server reached over a URL. |
| mcp_servers[].name | string | Name of the MCP server; the mcp_toolset entry that refers to it uses the same name in mcp_server_name. |
| mcp_servers[].url | string | http(s) endpoint of the MCP server, at most 2048 characters. |
| metadata | object | Free-form string key/value pairs stored with the agent for your own bookkeeping. |
| model | object | Model identifier and configuration. |
| model.id | string | The model that will power your agent. See models for additional details and options. |
| model.effort | object | How hard Claude works on each turn. Sets `output_config.effort` on every Messages call the session makes. |
| model.inference_geo | string | Geographic region for model inference. When unset, requests fall through to the workspace's default_inference_geo. |
| model.speed | string | Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time. |
| model.settings | object | Platform model settings. Only reasoning is supported; other model controls return 400. |
| multiagent | null | object | Resolved coordinator topology with a concrete agent roster. |
| multiagent.agents | array<object> | Agents the coordinator may spawn as session threads, each resolved to a specific version. |
| multiagent.type | string | Always `coordinator`. The agent coordinates the roster in agents and can delegate to its members. |
| name | string | Display name of the agent, as set on create or update. It is a label, not a unique key. |
| skills | array<object> | Skill attachments are not supported: a nonempty skills array returns 400. Omit this field or send an empty array. The native Skill tool loads available runtime skills independently of this field. |
| skills[].skill_id | string | Id of the skill to attach. |
| skills[].type | string | Always `anthropic`. A skill provided by Anthropic, identified by skill_id. / Always `custom`. A skill created by you, identified by skill_id. |
| skills[].version | string | Version of the skill; a string. |
| system | null | string | System prompt given to the model at the start of every session of this agent; null when none was set. |
| 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; custom tool definitions are rejected with 400. Keep bash enabled to use codemode, Skill and subagents. |
| tools[].configs | array<object> | array | null | Per-tool settings that override default_config. Tools that are not listed follow default_config. |
| tools[].default_config | object | object | null | Resolved default configuration for agent tools. / Settings applied to every tool of this toolset that configs does not name. When omitted, tools are enabled with the always_allow policy. |
| tools[].type | string | Always `agent_toolset_20260401`. The native toolset entry (bash, edit, glob, grep, read, write, web_search, web_fetch, TaskOutput, TaskStop, Monitor, Agent, SendMessage). / Always `mcp_toolset`. An entry that exposes the tools of one MCP server from mcp_servers. / Always `custom`. A custom tool defined by name, description and input_schema; its calls are answered by the client with user.custom_tool_result. |
| tools[].mcp_server_name | string | Name of the MCP server in mcp_servers whose tools this entry exposes. |
| tools[].description | string | What the custom tool does and when the model should call it. |
| tools[].input_schema | object | JSON Schema for custom tool input parameters. |
| tools[].name | string | Name of the custom tool, as the model sees and calls it. |
| type | string | Always `agent`. An agent definition. |
| updated_at | string | A timestamp in RFC 3339 format |
| version | number | The agent's current version. Starts at 1 and increments when the agent is modified. |
| computer_id | string | Praxis extension: MA only has session-scoped temporary containers and memory_stores, not durable browsable computers. computer_id selects a tenant-owned active computer. Session selection overrides the agent default; a sandbox environment_id and computer_id cannot be combined. Omitted when no computer is selected. |
| subagent_model | string | null | Praxis extension: default subagent model ID, pinned in the agent revision. Call model overrides this; otherwise it overrides the roster member model or the parent model for built-ins. Null clears the default. /agent/v1 only. |
| models | object | Praxis extension: switchable model ids on /agent/v1 only. The default model must be included. When omitted, only the default model is selectable. |
| models.allowed | array<string> | Model ids a session may select with its model field; it must be non-empty and must contain the agent's default model. |
先调用「创建智能体」,用返回的智能体 ID 替换示例 ID。
/agent/v1/agents/{agent_id}◐ 部分支持agent_idstring必填path: Agent id, as returned by agents.create or agents.list (for a session filter, the agent the session was created with). Not the agent name.
namestring可选智能体名称;省略保持不变,不能传空串清除。
modelstring | object可选智能体使用的模型:直接写模型名字符串(如 claude-opus-5),或传对象做附加配置(见子字段)。
idstring必填模型名字符串,如 claude-opus-5。
effortstring | object可选每次推理的思考力度:可传级别字符串(如 high)或 {type: high} 对象。创建时省略取该模型的默认值;更新时省略保持不变。
inference_geostring可选模型推理的地理区域;不传沿用工作区默认。model 是整体替换字段,更新时省略子字段即清除该项。
speedstring可选推理速度模式:fast 出字显著更快但按溢价计费;并非所有模型都支持,不支持的组合在创建时被拒。
settingsobject可选Platform model settings. Only reasoning is supported; other model controls return 400.
systemstring可选系统提示词;省略保持不变,传空串或 null 清除。
versionnumber可选智能体当前版本号,用于并发保护:必须与最近一次创建/读取返回的版本一致,否则返回冲突。
metadataobject可选元数据补丁:键设为字符串即写入,设为 null 即删除;省略该字段保持不变。存储上限 16 个键、每个值 512 字符。
descriptionstring可选用途说明;省略保持不变,传空串或 null 清除。
mcp_serversarray可选整体替换的 MCP 服务器列表;省略保持不变,传空数组或 null 清除。
multiagentobject可选◐ 部分支持多智能体协作拓扑:会话主线程作为协调者,从 agents 名单派生会话线程执行工作。
agentsarray必填协调者可以派生为会话线程的智能体名单,1–20 项;支持 ID 字符串、{type: agent, id, version?} 和最多一个 {type: self}。创建/更新时固定版本。成员须唯一、存在且未归档,不能自身带 multiagent。每个 coordinator 最多一个 advisor,模型须可用且不同于智能体模型;仅主会话可咨询,每次咨询为独立 advisor 线程,建议以 agent.thread_message_received 返回。
typestring必填拓扑类型,目前只有 coordinator。
skillsarray可选整体替换的 Skill 列表;省略保持不变,传空数组或 null 清除。
toolsarray可选整体替换的工具配置;省略保持不变,传空数组或 null 清除。
computer_idstring可选Praxis extension: MA only has session-scoped temporary containers and memory_stores, not durable browsable computers. computer_id selects a tenant-owned active computer. Session selection overrides the agent default; a sandbox environment_id and computer_id cannot be combined.
subagent_modelstring可选/agent/v1 扩展:智能体级子智能体默认模型 ID,随修订固定。省略保持,null 清除。调用 model 优先,其次本字段,再其次名册成员模型或内置类型的父会话模型。/anthropic 不接受或返回此字段。
modelsobject可选扩展:可切换模型列表,仅 /agent/v1 支持。
allowedarray必填必须包含默认模型;创建时省略表示只能使用默认模型。更新时省略保持不变。会话使用其钉住版本的列表。
200
通过 agent_toolset_20260401.configs 逐个开关原生工具并设置权限。未列出的工具遵循 default_config;后台任务、Monitor 和子智能体依赖 bash。version 可用于乐观并发控制,版本冲突返回 409;无变化的更新不增加版本。Skills 尚不支持。更新工具集 permissions 可把允许的同类操作保存到智能体的新版本,供以后的对话使用。 multiagent 接受 null 或 coordinator 名册,1–20 项:智能体 ID、{type:"agent",id,version?} 或最多一个 {type:"self"}。创建/更新时固定版本;成员去重且须存在、未归档、不能自身带 multiagent。名册可启用 Agent,仍需启用 bash;SendMessage 遵循工具配置。每个 coordinator 最多一个 advisor,模型须可用且不同于智能体模型;仅主会话可咨询,每次咨询为独立 advisor 线程,建议以 agent.thread_message_received 返回。 /agent/v1 顶层 subagent_model 是可空模型 ID,随智能体版本保存;省略保留、null 清除。模型须存在。优先级为调用 model > subagent_model > 成员模型(内置类型用父会话模型)。/anthropic 不接受或返回此字段。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
Successful response
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| id | string | Agent id (agent_...). Pass it as agent when creating a session and as agent_id in agent calls. |
| archived_at | null | string | A timestamp in RFC 3339 format |
| created_at | string | A timestamp in RFC 3339 format |
| description | null | string | Free-text description of what the agent is for; null when none was set. |
| 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. |
| mcp_servers[].type | string | Always `url`. An MCP server reached over a URL. |
| mcp_servers[].name | string | Name of the MCP server; the mcp_toolset entry that refers to it uses the same name in mcp_server_name. |
| mcp_servers[].url | string | http(s) endpoint of the MCP server, at most 2048 characters. |
| metadata | object | Free-form string key/value pairs stored with the agent for your own bookkeeping. |
| model | object | Model identifier and configuration. |
| model.id | string | The model that will power your agent. See models for additional details and options. |
| model.effort | object | How hard Claude works on each turn. Sets `output_config.effort` on every Messages call the session makes. |
| model.inference_geo | string | Geographic region for model inference. When unset, requests fall through to the workspace's default_inference_geo. |
| model.speed | string | Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time. |
| model.settings | object | Platform model settings. Only reasoning is supported; other model controls return 400. |
| multiagent | null | object | Resolved coordinator topology with a concrete agent roster. |
| multiagent.agents | array<object> | Agents the coordinator may spawn as session threads, each resolved to a specific version. |
| multiagent.type | string | Always `coordinator`. The agent coordinates the roster in agents and can delegate to its members. |
| name | string | Display name of the agent, as set on create or update. It is a label, not a unique key. |
| skills | array<object> | Skill attachments are not supported: a nonempty skills array returns 400. Omit this field or send an empty array. The native Skill tool loads available runtime skills independently of this field. |
| skills[].skill_id | string | Id of the skill to attach. |
| skills[].type | string | Always `anthropic`. A skill provided by Anthropic, identified by skill_id. / Always `custom`. A skill created by you, identified by skill_id. |
| skills[].version | string | Version of the skill; a string. |
| system | null | string | System prompt given to the model at the start of every session of this agent; null when none was set. |
| 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; custom tool definitions are rejected with 400. Keep bash enabled to use codemode, Skill and subagents. |
| tools[].configs | array<object> | array | null | Per-tool settings that override default_config. Tools that are not listed follow default_config. |
| tools[].default_config | object | object | null | Resolved default configuration for agent tools. / Settings applied to every tool of this toolset that configs does not name. When omitted, tools are enabled with the always_allow policy. |
| tools[].type | string | Always `agent_toolset_20260401`. The native toolset entry (bash, edit, glob, grep, read, write, web_search, web_fetch, TaskOutput, TaskStop, Monitor, Agent, SendMessage). / Always `mcp_toolset`. An entry that exposes the tools of one MCP server from mcp_servers. / Always `custom`. A custom tool defined by name, description and input_schema; its calls are answered by the client with user.custom_tool_result. |
| tools[].mcp_server_name | string | Name of the MCP server in mcp_servers whose tools this entry exposes. |
| tools[].description | string | What the custom tool does and when the model should call it. |
| tools[].input_schema | object | JSON Schema for custom tool input parameters. |
| tools[].name | string | Name of the custom tool, as the model sees and calls it. |
| type | string | Always `agent`. An agent definition. |
| updated_at | string | A timestamp in RFC 3339 format |
| version | number | The agent's current version. Starts at 1 and increments when the agent is modified. |
| computer_id | string | Praxis extension: MA only has session-scoped temporary containers and memory_stores, not durable browsable computers. computer_id selects a tenant-owned active computer. Session selection overrides the agent default; a sandbox environment_id and computer_id cannot be combined. Omitted when no computer is selected. |
| subagent_model | string | null | Praxis extension: default subagent model ID, pinned in the agent revision. Call model overrides this; otherwise it overrides the roster member model or the parent model for built-ins. Null clears the default. /agent/v1 only. |
| models | object | Praxis extension: switchable model ids on /agent/v1 only. The default model must be included. When omitted, only the default model is selectable. |
| models.allowed | array<string> | Model ids a session may select with its model field; it must be non-empty and must contain the agent's default model. |
先调用「创建智能体」,用返回的智能体 ID 替换示例 ID。
/agent/v1/agents/{agent_id}/versions● 支持agent_idstring必填path: Agent id, as returned by agents.create or agents.list (for a session filter, the agent the session was created with). Not the agent name.
limitnumber可选query: Number of items per page.
pagestring可选query: Opaque pagination cursor: pass the next_page value of the previous response unchanged. Omit it for the first page. A cursor from a different query or a malformed one returns 400.
200
将示例中的资源 ID 替换成你创建的资源 ID。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
Successful response
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| data | array<object> | Items of this page, in the order requested by the call. |
| data[].id | string | Agent id (agent_...). Pass it as agent when creating a session and as agent_id in agent calls. |
| data[].archived_at | null | string | A timestamp in RFC 3339 format |
| data[].created_at | string | A timestamp in RFC 3339 format |
| data[].description | null | string | Free-text description of what the agent is for; null when none was set. |
| data[].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. |
| data[].metadata | object | Free-form string key/value pairs stored with the agent for your own bookkeeping. |
| data[].model | object | Model identifier and configuration. |
| data[].multiagent | null | object | Resolved coordinator topology with a concrete agent roster. |
| data[].name | string | Display name of the agent, as set on create or update. It is a label, not a unique key. |
| data[].skills | array<object> | Skill attachments are not supported: a nonempty skills array returns 400. Omit this field or send an empty array. The native Skill tool loads available runtime skills independently of this field. |
| data[].system | null | string | System prompt given to the model at the start of every session of this agent; null when none was set. |
| data[].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; custom tool definitions are rejected with 400. Keep bash enabled to use codemode, Skill and subagents. |
| data[].type | string | Always `agent`. An agent definition. |
| data[].updated_at | string | A timestamp in RFC 3339 format |
| data[].version | number | The agent's current version. Starts at 1 and increments when the agent is modified. |
| data[].computer_id | string | Praxis extension: MA only has session-scoped temporary containers and memory_stores, not durable browsable computers. computer_id selects a tenant-owned active computer. Session selection overrides the agent default; a sandbox environment_id and computer_id cannot be combined. Omitted when no computer is selected. |
| data[].subagent_model | string | null | Praxis extension: default subagent model ID, pinned in the agent revision. Call model overrides this; otherwise it overrides the roster member model or the parent model for built-ins. Null clears the default. /agent/v1 only. |
| data[].models | object | Praxis extension: switchable model ids on /agent/v1 only. The default model must be included. When omitted, only the default model is selectable. |
| next_page | string | null | Opaque cursor for the next page: pass it unchanged as page to continue. Null when this is the last page. |
先调用「创建智能体」,用返回的智能体 ID 替换示例 ID。
/agent/v1/agents/{agent_id}/archive● 支持agent_idstring必填path: Agent id, as returned by agents.create or agents.list (for a session filter, the agent the session was created with). Not the agent name.
200
归档后保留查询与历史版本,不能继续更新。请只归档自己的测试智能体。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
Successful response
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| id | string | Agent id (agent_...). Pass it as agent when creating a session and as agent_id in agent calls. |
| archived_at | null | string | A timestamp in RFC 3339 format |
| created_at | string | A timestamp in RFC 3339 format |
| description | null | string | Free-text description of what the agent is for; null when none was set. |
| 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. |
| mcp_servers[].type | string | Always `url`. An MCP server reached over a URL. |
| mcp_servers[].name | string | Name of the MCP server; the mcp_toolset entry that refers to it uses the same name in mcp_server_name. |
| mcp_servers[].url | string | http(s) endpoint of the MCP server, at most 2048 characters. |
| metadata | object | Free-form string key/value pairs stored with the agent for your own bookkeeping. |
| model | object | Model identifier and configuration. |
| model.id | string | The model that will power your agent. See models for additional details and options. |
| model.effort | object | How hard Claude works on each turn. Sets `output_config.effort` on every Messages call the session makes. |
| model.inference_geo | string | Geographic region for model inference. When unset, requests fall through to the workspace's default_inference_geo. |
| model.speed | string | Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time. |
| model.settings | object | Platform model settings. Only reasoning is supported; other model controls return 400. |
| multiagent | null | object | Resolved coordinator topology with a concrete agent roster. |
| multiagent.agents | array<object> | Agents the coordinator may spawn as session threads, each resolved to a specific version. |
| multiagent.type | string | Always `coordinator`. The agent coordinates the roster in agents and can delegate to its members. |
| name | string | Display name of the agent, as set on create or update. It is a label, not a unique key. |
| skills | array<object> | Skill attachments are not supported: a nonempty skills array returns 400. Omit this field or send an empty array. The native Skill tool loads available runtime skills independently of this field. |
| skills[].skill_id | string | Id of the skill to attach. |
| skills[].type | string | Always `anthropic`. A skill provided by Anthropic, identified by skill_id. / Always `custom`. A skill created by you, identified by skill_id. |
| skills[].version | string | Version of the skill; a string. |
| system | null | string | System prompt given to the model at the start of every session of this agent; null when none was set. |
| 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; custom tool definitions are rejected with 400. Keep bash enabled to use codemode, Skill and subagents. |
| tools[].configs | array<object> | array | null | Per-tool settings that override default_config. Tools that are not listed follow default_config. |
| tools[].default_config | object | object | null | Resolved default configuration for agent tools. / Settings applied to every tool of this toolset that configs does not name. When omitted, tools are enabled with the always_allow policy. |
| tools[].type | string | Always `agent_toolset_20260401`. The native toolset entry (bash, edit, glob, grep, read, write, web_search, web_fetch, TaskOutput, TaskStop, Monitor, Agent, SendMessage). / Always `mcp_toolset`. An entry that exposes the tools of one MCP server from mcp_servers. / Always `custom`. A custom tool defined by name, description and input_schema; its calls are answered by the client with user.custom_tool_result. |
| tools[].mcp_server_name | string | Name of the MCP server in mcp_servers whose tools this entry exposes. |
| tools[].description | string | What the custom tool does and when the model should call it. |
| tools[].input_schema | object | JSON Schema for custom tool input parameters. |
| tools[].name | string | Name of the custom tool, as the model sees and calls it. |
| type | string | Always `agent`. An agent definition. |
| updated_at | string | A timestamp in RFC 3339 format |
| version | number | The agent's current version. Starts at 1 and increments when the agent is modified. |
| computer_id | string | Praxis extension: MA only has session-scoped temporary containers and memory_stores, not durable browsable computers. computer_id selects a tenant-owned active computer. Session selection overrides the agent default; a sandbox environment_id and computer_id cannot be combined. Omitted when no computer is selected. |
| subagent_model | string | null | Praxis extension: default subagent model ID, pinned in the agent revision. Call model overrides this; otherwise it overrides the roster member model or the parent model for built-ins. Null clears the default. /agent/v1 only. |
| models | object | Praxis extension: switchable model ids on /agent/v1 only. The default model must be included. When omitted, only the default model is selectable. |
| models.allowed | array<string> | Model ids a session may select with its model field; it must be non-empty and must contain the agent's default model. |
/agent/v1/sessions◐ 部分支持agent_idstring可选query: Return only sessions created with this agent id (from agents.list or agents.create). This is one of the three filters sessions.list supports.
agent_versionnumber可选query: 按智能体版本过滤;仅在同时设置 agent_id 时生效。
created_at[gt]string可选query: Exclusive created-at lower bound for sessions. Declared by the Managed Agents shape but not supported here; sending it returns 400.
created_at[gte]string可选query: Created-at lower bound for sessions. Declared by the Managed Agents shape but not supported here: sessions.list honors only limit, page and agent_id, and other filters return 400.
created_at[lt]string可选query: Exclusive created-at upper bound for sessions. Declared by the Managed Agents shape but not supported here; sending it returns 400.
created_at[lte]string可选query: Created-at upper bound for sessions. Declared by the Managed Agents shape but not supported here: sessions.list honors only limit, page and agent_id, and other filters return 400.
deployment_idstring可选query: Declared by the Managed Agents shape but not supported by sessions.list; sending it returns 400.
include_archivedboolean可选query: Declared by the Managed Agents shape but not supported by sessions.list; sending it returns 400. Archived sessions are retrievable by id.
memory_store_idstring可选query: Declared by the Managed Agents shape but not supported by sessions.list; sending it returns 400.
orderstring可选query: 按创建时间排序:asc 从旧到新,desc 从新到旧(默认)。
statusesarray可选query: 按会话状态过滤,可重复该参数匹配多种状态。
limitnumber可选query: Number of items per page.
pagestring可选query: Opaque pagination cursor: pass the next_page value of the previous response unchanged. Omit it for the first page. A cursor from a different query or a malformed one returns 400.
200
支持 limit、page 与 agent_id;agent_version、时间范围、deployment_id、memory_store_id、include_archived、order、statuses 尚不支持,传入返回 400。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
Successful response
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| data | array<object> | Items of this page, in the order requested by the call. |
| data[].id | string | Session id (sesn_...). Pass it as session_id in every session call. |
| data[].agent | object | Resolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time. |
| data[].archived_at | null | string | A timestamp in RFC 3339 format |
| data[].budget | null | object | A hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`. |
| data[].created_at | string | A timestamp in RFC 3339 format |
| data[].environment_id | string | Id of the environment recipe the session's sandbox was created from. Omitted when no recipe was selected, that is, for a light machine or the Computer chosen by computer_id. |
| data[].metadata | object | Free-form string key/value pairs stored with the session, changed through sessions.update patch semantics. |
| data[].outcome_evaluations | array<object> | Per-outcome evaluation state. One entry per `define_outcome` event sent to the session. |
| data[].resources | array<object> | Resources attached to the session, at most 500; each is a file reference mounted into the session's machine. |
| data[].stats | object | Timing statistics for a session. |
| data[].status | string | SessionStatus enum - `rescheduling` - Transient error occurred, retrying automatically. - `running` - Agent is actively executing. - `idle` - Agent is waiting for input, including user messages or tool confirmations. Sessions start in idle. - `terminated` - Session has ended, either due to an error or completion. |
| data[].title | null | string | Title of the session, set on create or through sessions.update; null when none was set. |
| data[].type | string | Always `session`. A session, one conversation of an agent on a machine. |
| data[].updated_at | string | A timestamp in RFC 3339 format |
| data[].usage | object | Cumulative token usage for a session across all turns. |
| data[].vault_ids | array<string> | Vault IDs attached to the session at creation. Empty when no vaults were supplied. |
| data[].deployment_id | null | string | Deployment ID when the session was created from a deployment reference. Null otherwise. |
| data[].cwd | string | Normalized session working directory; defaults to /home/user/workspace. Forks inherit this directory. |
| data[].computer_id | string | Praxis extension: MA only has session-scoped temporary containers and memory_stores, not durable browsable computers. computer_id selects a tenant-owned active computer. Session selection overrides the agent default; a sandbox environment_id and computer_id cannot be combined. Omitted when no computer is selected. |
| data[].model | object | Praxis extension: the currently selected session model. |
| data[].thinking | object | null | Praxis extension: explicit session thinking effort; null inherits the pinned agent default, then the model default. none disables thinking only when model.thinking.can_disable is true. Unsupported efforts return 400 invalid_request_error. |
| data[].forked_from | object | null | Praxis extension: source of a forked session; null for other sessions. Available only on /agent/v1. |
| next_page | string | null | Opaque cursor for the next page: pass it unchanged as page to continue. Null when this is the last page. |
先调用「创建智能体」,用返回的智能体 ID 替换示例 ID。
/agent/v1/sessions◐ 部分支持modelstring可选智能体使用的模型:直接写模型名字符串(如 claude-opus-5),或传对象做附加配置(见子字段)。
agentstring | object必填会话要运行的智能体:直接写智能体 ID 字符串(固定用最新版本),或传对象指定 id 与 version(见子字段)。
idstring必填会话要运行的智能体 ID。
typestring必填引用类型,目前只有 agent。
versionnumber可选固定使用的智能体版本;省略用最新版本。
mcp_serversarray可选替换本会话的 MCP 服务器列表:传入的数组整体生效;传空数组清除,省略沿用智能体的配置。
modelstring | object可选替换本会话的模型:模型名字符串(如 claude-opus-5)或配置对象;省略沿用智能体自身的模型。
skillsarray可选替换本会话的 Skill 列表;传空数组清除,省略沿用智能体的配置。
systemstring可选替换本会话的系统提示词,最长 100,000 字符;传 null 清除,省略沿用智能体的。
toolsarray可选替换本会话的工具配置;传空数组清除,省略沿用智能体的配置。
environment_idstring可选会话运行所在的环境 ID,决定容器的基础环境。
titlestring可选会话标题,便于在控制台辨认。
metadataobject可选会话的自定义元数据键值对。
budgetobject可选会话的预算上限设置。
max_list_costobject必填预算内列表类调用的花费上限。
typestring必填预算类型,目前只有 max_list_cost。
initial_eventsarray可选创建时按顺序发给会话的初始事件,支持 user.message 与 user.define_outcome,一次最多 50 条。
resourcesarray可选要挂载进会话容器的资源(如代码仓库、文件)。
vault_idsarray可选保险库 ID 列表:会话里智能体可以使用这些已存凭据。
cwdstring可选Session working directory on any machine. Must be an absolute path within /home/user with no . or .. segments. Repeated and trailing slashes are normalized. Invalid values return 400 invalid_request_error with Invalid cwd.
computer_idstring可选Praxis extension: MA only has session-scoped temporary containers and memory_stores, not durable browsable computers. computer_id selects a tenant-owned active computer. Session selection overrides the agent default; a sandbox environment_id and computer_id cannot be combined.
time_zonestring可选Praxis extension: the session's IANA time zone name (e.g. Asia/Shanghai) — the clock the runtime environment block renders for every turn. Absent means UTC. Only IANA names are accepted; fixed offsets ("+08:00") and unknown names return 400. Never stored in `metadata`.
thinkingobject可选Praxis extension: explicit session thinking effort; null inherits the pinned agent default, then the model default. none disables thinking only when model.thinking.can_disable is true. Unsupported efforts return 400 invalid_request_error.
effortstring必填Thinking level for this session. The model must support the chosen effort; none requires can_disable. Null on thinking restores inheritance from the agent and model.
200
可在创建时传 model(models.allowed 内的 ID 字符串;无 allowed 时只允许默认模型)与 thinking({effort: "low|medium|high|xhigh|none"} 或 null),在首条 initial_events 执行前保存。省略或 null 继承智能体默认,再使用模型默认。档位必须在 model.thinking.efforts 内;none 要求 can_disable 为 true,否则返回 400 invalid_request_error。响应包含 thinking 与 model.thinking: {efforts, can_disable, default_effort};未知能力为 null,默认档位也可为 null。示例:{"agent":"agent_123","model":"deepseek-v4-flash","thinking":{"effort":"xhigh"}}。这些选择字段只在 /agent/v1 提供。先创建智能体,将示例 agent_123 换成返回的 id。省略 environment_id 得到轻量机器(light),有默认或显式 computer_id 时使用该 Computer;指定 node22 或租户自建 cloud 环境则使用沙箱配方。无配方时响应省略 environment_id。不支持内联智能体覆盖、预算与凭据库。支持 file 类型资源的持久化、查询和解除关联,单会话最多 500 条。文件须属于当前租户且有效。默认路径为 /mnt/session/uploads/<file_id>,自定义路径归一到该目录,拒绝父目录遍历。不修改文件内容;本批尚不将资源同步到沙箱。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
Successful response
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| id | string | Session id (sesn_...). Pass it as session_id in every session call. |
| agent | object | Resolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time. |
| 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.model | object | Model identifier and configuration. |
| agent.multiagent | null | object | Resolved coordinator topology with full agent definitions for each roster member. |
| 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> | Skill attachments are not supported: a nonempty skills array returns 400. Omit this field or send an empty array. The native Skill tool loads available runtime skills independently of this field. |
| 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; custom tool definitions are rejected with 400. Keep bash enabled to use codemode, Skill and subagents. |
| agent.type | string | Always `agent`. An agent definition. |
| 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 |
| budget | null | object | A hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`. |
| budget.max_list_cost | object | A monetary amount in a specific currency. |
| budget.type | string | Always `limit`. A spending limit. |
| created_at | string | A timestamp in RFC 3339 format |
| environment_id | string | Id of the environment recipe the session's sandbox was created from. Omitted when no recipe was selected, that is, for a light machine or the Computer chosen by computer_id. |
| metadata | object | Free-form string key/value pairs stored with the session, changed through sessions.update patch semantics. |
| outcome_evaluations | array<object> | Per-outcome evaluation state. One entry per `define_outcome` event sent to the session. |
| outcome_evaluations[].completed_at | null | string | A timestamp in RFC 3339 format |
| outcome_evaluations[].description | string | What the agent should produce. |
| outcome_evaluations[].explanation | null | string | Grader's verdict text from the most recent evaluation. For `satisfied`, explains why criteria are met; for `needs_revision` (intermediate), what's missing; for `failed`, why unrecoverable. |
| outcome_evaluations[].iteration | number | 0-indexed revision cycle the outcome is currently on. |
| outcome_evaluations[].outcome_id | string | Server-generated outc_ ID for this outcome. |
| outcome_evaluations[].result | string | Current evaluation state. `pending` before the agent begins work; `running` while producing or revising; `evaluating` while the grader scores; `satisfied`/`max_iterations_reached`/`failed`/`interrupted` are terminal. |
| outcome_evaluations[].type | string | Always `outcome_evaluation`. Record of one outcome evaluation. |
| resources | array<object> | Resources attached to the session, at most 500; each is a file reference mounted into the session's machine. |
| resources[].id | string | Resource id, the resource_id of sessions.resources calls. |
| resources[].created_at | string | A timestamp in RFC 3339 format |
| resources[].mount_path | string | null | string | Path inside the machine where the file is mounted; defaults to /mnt/session/uploads/<file_id>, and custom paths are rooted there. / Filesystem path where the store is mounted in the session container, e.g. /mnt/memory/user-preferences. Derived from the store's name. Output-only. |
| resources[].type | string | Always `github_repository`. A GitHub repository resource; not supported on this platform. / Always `file`. A file resource: an uploaded file mounted into the session's machine. / Always `memory_store`. A memory store resource; not supported on this platform. |
| resources[].updated_at | string | A timestamp in RFC 3339 format |
| resources[].url | string | Repository URL. |
| resources[].checkout | null | object | Branch or commit to check out. |
| resources[].file_id | string | Id of the uploaded file; it must exist and belong to your tenant. |
| resources[].memory_store_id | string | The memory store ID (memstore_...). Must belong to the caller's organization and workspace. |
| resources[].access | null | string | Access mode for an attached memory store. |
| resources[].description | string | Description of the memory store, snapshotted at attach time. Rendered into the agent's system prompt. Empty string when the store has no description. |
| resources[].instructions | null | string | Per-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars. |
| resources[].name | null | string | Display name of the memory store, snapshotted at attach time. Later edits to the store's name do not propagate to this resource. |
| stats | object | Timing statistics for a session. |
| stats.active_seconds | number | Cumulative time in seconds the session spent in `running` status. Excludes idle time. |
| stats.duration_seconds | number | Elapsed time since session creation in seconds. For terminated sessions, frozen at the final update. |
| status | string | SessionStatus enum - `rescheduling` - Transient error occurred, retrying automatically. - `running` - Agent is actively executing. - `idle` - Agent is waiting for input, including user messages or tool confirmations. Sessions start in idle. - `terminated` - Session has ended, either due to an error or completion. |
| title | null | string | Title of the session, set on create or through sessions.update; null when none was set. |
| type | string | Always `session`. A session, one conversation of an agent on a machine. |
| updated_at | string | A timestamp in RFC 3339 format |
| usage | object | Cumulative token usage for a session across all turns. |
| usage.active_seconds | number | Cumulative time in seconds during which the session had at least one thread in running status. Overlapping activity from concurrent threads is counted once, unlike `stats.active_seconds`, which sums each thread's own active time. This is the duration the session's runtime 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. |
| vault_ids | array<string> | Vault IDs attached to the session at creation. Empty when no vaults were supplied. |
| deployment_id | null | string | Deployment ID when the session was created from a deployment reference. Null otherwise. |
| cwd | string | Normalized session working directory; defaults to /home/user/workspace. Forks inherit this directory. |
| computer_id | string | Praxis extension: MA only has session-scoped temporary containers and memory_stores, not durable browsable computers. computer_id selects a tenant-owned active computer. Session selection overrides the agent default; a sandbox environment_id and computer_id cannot be combined. Omitted when no computer is selected. |
| model | object | Praxis extension: the currently selected session model. |
| model.id | string | Identifier of the object, as returned by the API; pass it in the path of follow-up calls on the same resource. |
| model.thinking | object | null | Supported thinking controls, or null when capability is unknown or unavailable. efforts lists selectable strengths; can_disable permits none; default_effort is nullable. |
| thinking | object | null | Praxis extension: explicit session thinking effort; null inherits the pinned agent default, then the model default. none disables thinking only when model.thinking.can_disable is true. Unsupported efforts return 400 invalid_request_error. |
| thinking.effort | string | Thinking level saved for this session: low, medium, high, xhigh, or none to turn thinking off. Null or absent means the session inherits the agent default and then the model default. |
| forked_from | object | null | Praxis extension: source of a forked session; null for other sessions. Available only on /agent/v1. |
| forked_from.session_id | string | Id of the parent session this session was forked from; it is left unchanged by the fork. |
| forked_from.message_id | string | message_id of the agent message in the parent session up to which the conversation was copied. |
先调用「创建会话」,用返回的会话 ID 替换示例 ID。
/agent/v1/sessions/{session_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.
200
将示例中的资源 ID 替换成你创建的资源 ID。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
Successful response
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| id | string | Session id (sesn_...). Pass it as session_id in every session call. |
| agent | object | Resolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time. |
| 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.model | object | Model identifier and configuration. |
| agent.multiagent | null | object | Resolved coordinator topology with full agent definitions for each roster member. |
| 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> | Skill attachments are not supported: a nonempty skills array returns 400. Omit this field or send an empty array. The native Skill tool loads available runtime skills independently of this field. |
| 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; custom tool definitions are rejected with 400. Keep bash enabled to use codemode, Skill and subagents. |
| agent.type | string | Always `agent`. An agent definition. |
| 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 |
| budget | null | object | A hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`. |
| budget.max_list_cost | object | A monetary amount in a specific currency. |
| budget.type | string | Always `limit`. A spending limit. |
| created_at | string | A timestamp in RFC 3339 format |
| environment_id | string | Id of the environment recipe the session's sandbox was created from. Omitted when no recipe was selected, that is, for a light machine or the Computer chosen by computer_id. |
| metadata | object | Free-form string key/value pairs stored with the session, changed through sessions.update patch semantics. |
| outcome_evaluations | array<object> | Per-outcome evaluation state. One entry per `define_outcome` event sent to the session. |
| outcome_evaluations[].completed_at | null | string | A timestamp in RFC 3339 format |
| outcome_evaluations[].description | string | What the agent should produce. |
| outcome_evaluations[].explanation | null | string | Grader's verdict text from the most recent evaluation. For `satisfied`, explains why criteria are met; for `needs_revision` (intermediate), what's missing; for `failed`, why unrecoverable. |
| outcome_evaluations[].iteration | number | 0-indexed revision cycle the outcome is currently on. |
| outcome_evaluations[].outcome_id | string | Server-generated outc_ ID for this outcome. |
| outcome_evaluations[].result | string | Current evaluation state. `pending` before the agent begins work; `running` while producing or revising; `evaluating` while the grader scores; `satisfied`/`max_iterations_reached`/`failed`/`interrupted` are terminal. |
| outcome_evaluations[].type | string | Always `outcome_evaluation`. Record of one outcome evaluation. |
| resources | array<object> | Resources attached to the session, at most 500; each is a file reference mounted into the session's machine. |
| resources[].id | string | Resource id, the resource_id of sessions.resources calls. |
| resources[].created_at | string | A timestamp in RFC 3339 format |
| resources[].mount_path | string | null | string | Path inside the machine where the file is mounted; defaults to /mnt/session/uploads/<file_id>, and custom paths are rooted there. / Filesystem path where the store is mounted in the session container, e.g. /mnt/memory/user-preferences. Derived from the store's name. Output-only. |
| resources[].type | string | Always `github_repository`. A GitHub repository resource; not supported on this platform. / Always `file`. A file resource: an uploaded file mounted into the session's machine. / Always `memory_store`. A memory store resource; not supported on this platform. |
| resources[].updated_at | string | A timestamp in RFC 3339 format |
| resources[].url | string | Repository URL. |
| resources[].checkout | null | object | Branch or commit to check out. |
| resources[].file_id | string | Id of the uploaded file; it must exist and belong to your tenant. |
| resources[].memory_store_id | string | The memory store ID (memstore_...). Must belong to the caller's organization and workspace. |
| resources[].access | null | string | Access mode for an attached memory store. |
| resources[].description | string | Description of the memory store, snapshotted at attach time. Rendered into the agent's system prompt. Empty string when the store has no description. |
| resources[].instructions | null | string | Per-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars. |
| resources[].name | null | string | Display name of the memory store, snapshotted at attach time. Later edits to the store's name do not propagate to this resource. |
| stats | object | Timing statistics for a session. |
| stats.active_seconds | number | Cumulative time in seconds the session spent in `running` status. Excludes idle time. |
| stats.duration_seconds | number | Elapsed time since session creation in seconds. For terminated sessions, frozen at the final update. |
| status | string | SessionStatus enum - `rescheduling` - Transient error occurred, retrying automatically. - `running` - Agent is actively executing. - `idle` - Agent is waiting for input, including user messages or tool confirmations. Sessions start in idle. - `terminated` - Session has ended, either due to an error or completion. |
| title | null | string | Title of the session, set on create or through sessions.update; null when none was set. |
| type | string | Always `session`. A session, one conversation of an agent on a machine. |
| updated_at | string | A timestamp in RFC 3339 format |
| usage | object | Cumulative token usage for a session across all turns. |
| usage.active_seconds | number | Cumulative time in seconds during which the session had at least one thread in running status. Overlapping activity from concurrent threads is counted once, unlike `stats.active_seconds`, which sums each thread's own active time. This is the duration the session's runtime 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. |
| vault_ids | array<string> | Vault IDs attached to the session at creation. Empty when no vaults were supplied. |
| deployment_id | null | string | Deployment ID when the session was created from a deployment reference. Null otherwise. |
| cwd | string | Normalized session working directory; defaults to /home/user/workspace. Forks inherit this directory. |
| computer_id | string | Praxis extension: MA only has session-scoped temporary containers and memory_stores, not durable browsable computers. computer_id selects a tenant-owned active computer. Session selection overrides the agent default; a sandbox environment_id and computer_id cannot be combined. Omitted when no computer is selected. |
| model | object | Praxis extension: the currently selected session model. |
| model.id | string | Identifier of the object, as returned by the API; pass it in the path of follow-up calls on the same resource. |
| model.thinking | object | null | Supported thinking controls, or null when capability is unknown or unavailable. efforts lists selectable strengths; can_disable permits none; default_effort is nullable. |
| thinking | object | null | Praxis extension: explicit session thinking effort; null inherits the pinned agent default, then the model default. none disables thinking only when model.thinking.can_disable is true. Unsupported efforts return 400 invalid_request_error. |
| thinking.effort | string | Thinking level saved for this session: low, medium, high, xhigh, or none to turn thinking off. Null or absent means the session inherits the agent default and then the model default. |
| forked_from | object | null | Praxis extension: source of a forked session; null for other sessions. Available only on /agent/v1. |
| forked_from.session_id | string | Id of the parent session this session was forked from; it is left unchanged by the fork. |
| forked_from.message_id | string | message_id of the agent message in the parent session up to which the conversation was copied. |
/agent/v1/sessions/{session_id}/fork● 支持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.
message_idstring必填分支点的 UI 消息 ID,取自自有面事件的 message_id 字段;须为成功完成轮次的最后一条助手消息。
201
仅在 /agent/v1 提供。message_id 来自 /agent/v1 事件的同名字段,不是事件 id。复制截至并包含该消息的全部对话与工具调用结果;父会话不变,其他轮次正在运行不影响已有完成轮次的分支。新会话沿用智能体及版本、当前模型与思考设置和 cwd 工作目录,标题为父标题加「 的分支」,作为普通根会话出现在列表中。父会话有沙箱时复制沙箱及内存快照,新会话独立拥有该沙箱;继承的运行中后台任务被终止,门铃目标只保留新会话,新后台任务表为空。父会话没有沙箱时保留懒创建。返回 201,响应与读取会话相同,forked_from 为 {session_id, message_id},普通会话为 null。新会话历史末尾有 session.forked 事件,包含 forked_from_session_id 与 forked_from_message_id。上述字段和事件仅在 /agent/v1 可见。非法请求返回 400;不满足分支条件返回 409 FORK_TARGET_INVALID;会话不存在或不属于调用者返回 404。初始化失败时不公开新会话,并回收已分出的沙箱。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
Forked session (same shape as session retrieval)
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| id | string | Session id (sesn_...). Pass it as session_id in every session call. |
| agent | object | Resolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time. |
| 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.model | object | Model identifier and configuration. |
| agent.multiagent | null | object | Resolved coordinator topology with full agent definitions for each roster member. |
| 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> | Skill attachments are not supported: a nonempty skills array returns 400. Omit this field or send an empty array. The native Skill tool loads available runtime skills independently of this field. |
| 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; custom tool definitions are rejected with 400. Keep bash enabled to use codemode, Skill and subagents. |
| agent.type | string | Always `agent`. An agent definition. |
| 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 |
| budget | null | object | A hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`. |
| budget.max_list_cost | object | A monetary amount in a specific currency. |
| budget.type | string | Always `limit`. A spending limit. |
| created_at | string | A timestamp in RFC 3339 format |
| environment_id | string | Id of the environment recipe the session's sandbox was created from. Omitted when no recipe was selected, that is, for a light machine or the Computer chosen by computer_id. |
| metadata | object | Free-form string key/value pairs stored with the session, changed through sessions.update patch semantics. |
| outcome_evaluations | array<object> | Per-outcome evaluation state. One entry per `define_outcome` event sent to the session. |
| outcome_evaluations[].completed_at | null | string | A timestamp in RFC 3339 format |
| outcome_evaluations[].description | string | What the agent should produce. |
| outcome_evaluations[].explanation | null | string | Grader's verdict text from the most recent evaluation. For `satisfied`, explains why criteria are met; for `needs_revision` (intermediate), what's missing; for `failed`, why unrecoverable. |
| outcome_evaluations[].iteration | number | 0-indexed revision cycle the outcome is currently on. |
| outcome_evaluations[].outcome_id | string | Server-generated outc_ ID for this outcome. |
| outcome_evaluations[].result | string | Current evaluation state. `pending` before the agent begins work; `running` while producing or revising; `evaluating` while the grader scores; `satisfied`/`max_iterations_reached`/`failed`/`interrupted` are terminal. |
| outcome_evaluations[].type | string | Always `outcome_evaluation`. Record of one outcome evaluation. |
| resources | array<object> | Resources attached to the session, at most 500; each is a file reference mounted into the session's machine. |
| resources[].id | string | Resource id, the resource_id of sessions.resources calls. |
| resources[].created_at | string | A timestamp in RFC 3339 format |
| resources[].mount_path | string | null | string | Path inside the machine where the file is mounted; defaults to /mnt/session/uploads/<file_id>, and custom paths are rooted there. / Filesystem path where the store is mounted in the session container, e.g. /mnt/memory/user-preferences. Derived from the store's name. Output-only. |
| resources[].type | string | Always `github_repository`. A GitHub repository resource; not supported on this platform. / Always `file`. A file resource: an uploaded file mounted into the session's machine. / Always `memory_store`. A memory store resource; not supported on this platform. |
| resources[].updated_at | string | A timestamp in RFC 3339 format |
| resources[].url | string | Repository URL. |
| resources[].checkout | null | object | Branch or commit to check out. |
| resources[].file_id | string | Id of the uploaded file; it must exist and belong to your tenant. |
| resources[].memory_store_id | string | The memory store ID (memstore_...). Must belong to the caller's organization and workspace. |
| resources[].access | null | string | Access mode for an attached memory store. |
| resources[].description | string | Description of the memory store, snapshotted at attach time. Rendered into the agent's system prompt. Empty string when the store has no description. |
| resources[].instructions | null | string | Per-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars. |
| resources[].name | null | string | Display name of the memory store, snapshotted at attach time. Later edits to the store's name do not propagate to this resource. |
| stats | object | Timing statistics for a session. |
| stats.active_seconds | number | Cumulative time in seconds the session spent in `running` status. Excludes idle time. |
| stats.duration_seconds | number | Elapsed time since session creation in seconds. For terminated sessions, frozen at the final update. |
| status | string | SessionStatus enum - `rescheduling` - Transient error occurred, retrying automatically. - `running` - Agent is actively executing. - `idle` - Agent is waiting for input, including user messages or tool confirmations. Sessions start in idle. - `terminated` - Session has ended, either due to an error or completion. |
| title | null | string | Title of the session, set on create or through sessions.update; null when none was set. |
| type | string | Always `session`. A session, one conversation of an agent on a machine. |
| updated_at | string | A timestamp in RFC 3339 format |
| usage | object | Cumulative token usage for a session across all turns. |
| usage.active_seconds | number | Cumulative time in seconds during which the session had at least one thread in running status. Overlapping activity from concurrent threads is counted once, unlike `stats.active_seconds`, which sums each thread's own active time. This is the duration the session's runtime 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. |
| vault_ids | array<string> | Vault IDs attached to the session at creation. Empty when no vaults were supplied. |
| deployment_id | null | string | Deployment ID when the session was created from a deployment reference. Null otherwise. |
| cwd | string | Normalized session working directory; defaults to /home/user/workspace. Forks inherit this directory. |
| computer_id | string | Praxis extension: MA only has session-scoped temporary containers and memory_stores, not durable browsable computers. computer_id selects a tenant-owned active computer. Session selection overrides the agent default; a sandbox environment_id and computer_id cannot be combined. Omitted when no computer is selected. |
| model | object | Praxis extension: the currently selected session model. |
| model.id | string | Identifier of the object, as returned by the API; pass it in the path of follow-up calls on the same resource. |
| model.thinking | object | null | Supported thinking controls, or null when capability is unknown or unavailable. efforts lists selectable strengths; can_disable permits none; default_effort is nullable. |
| thinking | object | null | Praxis extension: explicit session thinking effort; null inherits the pinned agent default, then the model default. none disables thinking only when model.thinking.can_disable is true. Unsupported efforts return 400 invalid_request_error. |
| thinking.effort | string | Thinking level saved for this session: low, medium, high, xhigh, or none to turn thinking off. Null or absent means the session inherits the agent default and then the model default. |
| forked_from | object | null | Praxis extension: source of a forked session; null for other sessions. Available only on /agent/v1. |
| forked_from.session_id | string | Id of the parent session this session was forked from; it is left unchanged by the fork. |
| forked_from.message_id | string | message_id of the agent message in the parent session up to which the conversation was copied. |
/agent/v1/sessions/{session_id}/context● 支持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 提供,形状参照 Claude Agent SDK getContextUsage(),字段使用 snake_case。detail 固定为 summary:总量优先使用上次模型实测,各来源按本地估算占比摊分,used 分类之和等于 total_tokens。categories 只列非零来源,按 kind(used/free/buffer/deferred)判断用途。key 是稳定来源标识扩展;客户端须容忍未知 key 和新增来源,未知名称回退显示 name。MCP 按服务器归组,插件按 id 归组,摘要单独计量。excluded_items 暂为零。尚无测量时 total_tokens、total_tokens_source、measured_at 为 null,categories 为空,明细为零或空数组。切换模型后 max_tokens、auto_compact_threshold 与 free/buffer 立即按新模型重算,保留最近测量值。窗口未知或自动压缩熔断时 is_auto_compact_enabled 为 false。例如 model.thinking 为 {efforts: [high, xhigh], can_disable: true, default_effort: high}。model.thinking 返回 efforts(支持的档位)、can_disable(是否允许 none)及 default_effort(模型默认档位,可为 null);能力未知时整个 thinking 为 null。会话不存在或调用者不可见时返回 404。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
Current model and latest context measurement
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| type | string | Always `session_context`. Snapshot of a session's context window usage. |
| session_id | string | Session whose context this snapshot describes. |
| model | object | Model of the session and its context window facts. |
| model.id | string | Identifier of the object, as returned by the API; pass it in the path of follow-up calls on the same resource. |
| model.display_name | string | Human-readable name of the model. |
| model.thinking | object | null | Thinking capability of the model: supported efforts, whether thinking can be disabled, and the default. Null when the capability is unknown. |
| total_tokens | number | null | Tokens currently occupying the context window; null before the first measurement. |
| total_tokens_source | string | null | Whether total_tokens is the provider-reported input usage (actual) or a local estimate (estimated); null before the first measurement. |
| max_tokens | number | null | Context window of the model in tokens; null when the model does not state one. |
| max_input_tokens | number | null | Maximum input tokens the model accepts per request; null when not stated. |
| percentage | number | Share of the context window in use, as a whole-number percent; 0 when the window or usage is unknown. |
| auto_compact_threshold | number | null | Token count at which automatic compaction starts; null when the window is unknown. |
| is_auto_compact_enabled | boolean | Whether automatic compaction is enabled for this session. |
| clear_tool_results_at | number | Token count at which old tool results are cleared from the context. |
| detail | string | Level of detail of the snapshot. |
| categories | array<object> | Context usage by category; each row has a stable key and a kind. |
| categories[].key | string | Praxis extension: stable source identifier (system, tools, mcp:<server>, plugin:<id>, messages, summary, free, buffer). Clients must tolerate unknown keys and newly added sources; classify rows by kind, not key or name. |
| categories[].name | string | Display name of the category. |
| categories[].tokens | number | Tokens used by the category. |
| categories[].kind | string | How the category counts against the window. |
| mcp_tools | array<object> | Tokens spent on the tool definitions of each MCP server. |
| mcp_tools[].name | string | Name of the MCP tool. |
| mcp_tools[].server_name | string | Name of the MCP server that provides the tool. |
| mcp_tools[].tokens | number | Tokens used by the tool definition. |
| plugin_blocks | array<object> | Tokens spent on context blocks injected by each mod. |
| plugin_blocks[].name | string | Name of the mod that injected the block. |
| plugin_blocks[].tokens | number | Tokens used by the block. |
| message_breakdown | object | Tokens in the conversation messages, split by role and tool traffic. |
| message_breakdown.user_message_tokens | number | Tokens of user messages. |
| message_breakdown.assistant_message_tokens | number | Tokens of assistant text messages. |
| message_breakdown.tool_call_tokens | number | Tokens of tool-call arguments. |
| message_breakdown.tool_result_tokens | number | Tokens of tool results. |
| message_breakdown.reasoning_tokens | number | Tokens of reasoning content. |
| message_breakdown.tool_calls_by_type | array<object> | Tool-call and tool-result tokens grouped by tool name. |
| compaction_summary | object | null | Tokens held by the latest compaction summary; null when the session was never compacted. |
| compaction_summary.tokens | number | Tokens of the compaction summary. |
| excluded_items | object | Items removed from the context for content safety, kept for audit only and not counted as usage. |
| excluded_items.count | number | Number of excluded items. |
| excluded_items.tokens | number | Tokens of the excluded items. |
| measured_at | string | null | RFC 3339 time of the measurement; null before the first measurement. |
/agent/v1/sessions/{session_id}/background_tasks● 支持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 提供。kind 是开放字符串。subagent 行的 thread_id 指向对应子线程,其他 kind 为 null。completed 且 delivery=pending 显示 result_pending。notified_at 是系统通知批次被受理开轮的时间,无则 null。trigger_count 仅监视器返回已受理的事件批次数,无记录则 null。时间为 RFC3339。会话不存在或不可见返回 404。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
Session background tasks
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| data | array<object> | Items of this page, in the order requested by the call. |
| data[].id | string | Identifier of the object, as returned by the API; pass it in the path of follow-up calls on the same resource. |
| data[].kind | string | Kind of background task: bash for a command started with run_in_background, monitor for a Monitor watch. |
| data[].title | string | Short human-readable title of the task or object. |
| data[].thread_id | string | null | Execution thread the task belongs to; null for the primary thread. |
| data[].status | string | Current lifecycle state. |
| data[].started_at | string | RFC 3339 time at which the task started. |
| data[].ended_at | string | null | RFC 3339 time at which the task ended; null while it is running. |
| data[].cancellable | boolean | Whether the task can still be stopped. |
| data[].notified_at | string | null | RFC 3339 time of the latest run that the task's notification started; null while no notification has been delivered. |
| data[].trigger_count | integer | null | For a monitor task, how many times its matches woke the session; null for other kinds or before the first notification. |
/agent/v1/sessions/{session_id}/background_tasks/{task_id}/output● 支持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.
task_idstring必填path: Background task id (task_...), as listed by sessions.background_tasks.list.
offsetinteger可选query: Byte offset into the task output to read from; start at 0 and continue with the next_offset of the previous response. Integer of at least 0, default 0.
max_bytesinteger可选query: Maximum number of bytes to return: an integer from 1 to 262144, default 65536.
200
offset 默认 0;max_bytes 默认 65536,上限 262144。返回 text、next_offset、eof。沙箱已暂停或不存在时返回空 text、原 offset、eof=true、unavailable=true。读取不确认模型结果。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
Background task output byte page
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| text | string | Text of the block. |
| next_offset | integer | Byte offset to pass as offset to continue reading the output. |
| eof | boolean | True when the output has ended and no more bytes will follow. |
| unavailable | boolean | True when the output could not be read; text is then empty. |
/agent/v1/sessions/{session_id}/background_tasks/{task_id}/stop● 支持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.
task_idstring必填path: Background task id (task_...), as listed by sessions.background_tasks.list.
200
复用 TaskStop:持久化 stop_requested_at 并终止进程组。返回 BackgroundTask;终止尚未观察到时仍可为 running,但不可取消。已结束或不支持停止的任务返回 409。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
Current task after stop request
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| id | string | Identifier of the object, as returned by the API; pass it in the path of follow-up calls on the same resource. |
| kind | string | Kind of background task: bash for a command started with run_in_background, monitor for a Monitor watch. |
| title | string | Short human-readable title of the task or object. |
| thread_id | string | null | Execution thread the task belongs to; null for the primary thread. |
| status | string | Current lifecycle state. |
| started_at | string | RFC 3339 time at which the task started. |
| ended_at | string | null | RFC 3339 time at which the task ended; null while it is running. |
| cancellable | boolean | Whether the task can still be stopped. |
| notified_at | string | null | RFC 3339 time of the latest run that the task's notification started; null while no notification has been delivered. |
| trigger_count | integer | null | For a monitor task, how many times its matches woke the session; null for other kinds or before the first notification. |
先调用「创建会话」,用返回的会话 ID 替换示例 ID。
/agent/v1/sessions/{session_id}/compact● 支持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.
instructionsstring可选Optional focus instructions for the summary, passed to the summarizing model unchanged.
200
仅在 /agent/v1 提供。请求体可省略或为 {},可选 instructions 必须为字符串且原样传递。Idempotency-Key 请求头原样传递;缺失时生成 UUID。响应为 { type: session_compaction, id, status, reason? },id 是操作 ID。queued/running 返回 202;skipped/succeeded/failed 返回 200。非字符串 instructions 返回 400 invalid_request_error。不存在或不可见的托管会话返回 404 not_found_error。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
Skipped, succeeded or failed compaction
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. |
Queued or running compaction
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. |
先调用「创建会话」,用返回的会话 ID 替换示例 ID。
/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),参见 错误码
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. |
先调用「创建会话」,用返回的会话 ID 替换示例 ID。
/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),参见 错误码
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. |
先调用「创建会话」,用返回的会话 ID 替换示例 ID。
/agent/v1/sessions/{session_id}/events● 支持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.
created_at[gt]string可选query: Return events created after this time (exclusive). Compared against the event's `processed_at` value.
created_at[gte]string可选query: Return events created at or after this time (inclusive). Compared against the event's `processed_at` value.
created_at[lt]string可选query: Return events created before this time (exclusive). Compared against the event's `processed_at` value.
created_at[lte]string可选query: Return events created at or before this time (inclusive). Compared against the event's `processed_at` value.
orderstring可选query: 按事件处理时间排序:asc 从早到晚(默认),desc 相反。
typesarray可选query: 按事件类型过滤,取值与返回事件的 type 字段一致(如 user.message、agent.tool_use);不传返回全部类型。
limitnumber可选query: Number of items per page.
pagestring可选query: Opaque pagination cursor: pass the next_page value of the previous response unchanged. Omit it for the first page. A cursor from a different query or a malformed one returns 400.
200
先发送消息再读取历史;处理完成前可能只看到已接纳的输入。支持分页、事件类型和时间过滤。会话等待工具授权时停在 session.status_idle,stop_reason 为 requires_action,event_ids 列出待确认的 agent.tool_use;运行失败时先出现 session.error,再出现 session.status_terminated。agent.thinking 带思考内容 content。使用网页搜索或读取网页时,/agent/v1 与 /anthropic 的工具结果均为官方 search_result 块;回答文本块的 citations 是 /agent/v1 的扩展字段,/anthropic 将回答引用显示为正文中的 [n]。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
Successful response
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| data | array<object> | Items of this page, in the order requested by the call. |
| data[].id | string | Unique identifier for this event. / Event id, unique within the session. Use it to refer to this event, for example in user.tool_confirmation or user.steer. / Event id, unique within the session. / Event id, unique within the session. Use it to refer to this event, for example in user.tool_confirmation or user.steer. / Event id, unique within the session. Use it to refer to this event, for example in user.tool_confirmation or user.steer. / Event id, unique within the session. |
| data[].content | array<object> | Array of content blocks comprising the user message. / The result content returned by the tool. / Array of text blocks comprising the agent response. / The result content returned by the tool. / The result content returned by the tool. / Message content blocks. / Message content blocks. / The result content returned by the tool. / System content blocks. Text-only. |
| data[].type | string | Always `user.message`. A message from the user to the agent, with content blocks. / Always `user.interrupt`. The user interrupted the running turn. / Always `user.tool_confirmation`. The user's decision to allow or deny a tool call that waits for approval. / Always `user.custom_tool_result`. The user's result for a custom tool call. / Always `agent.custom_tool_use`. The agent called a custom tool defined by the client. / Always `agent.message`. A message from the agent, with text content blocks. / Always `agent.thinking`. The agent's thinking text for a step. / Always `agent.mcp_tool_use`. The agent called an MCP tool. / Always `agent.mcp_tool_result`. The result of an MCP tool call. / Always `agent.tool_use`. The agent called a tool. / Always `agent.tool_result`. The result of a tool call. / Always `agent.thread_message_received`. The agent received a message from another thread. / Always `agent.thread_message_sent`. The agent sent a message to another thread. / Always `agent.thread_context_compacted`. The thread's context was compacted into a summary. / Always `session.error`. The session hit an error. / Always `session.status_rescheduled`. The session will retry after a recoverable error. / Always `session.status_running`. The session started running a turn. / Always `session.status_idle`. The session stopped running; stop_reason says why. / Always `session.status_terminated`. The session ended and accepts no more work. / Always `session.thread_created`. A child thread was started. / Always `span.outcome_evaluation_start`. An outcome evaluation started. / Always `span.outcome_evaluation_end`. An outcome evaluation ended. / Always `span.model_request_start`. A model request started. / Always `span.model_request_end`. A model request ended, with its usage. / Always `span.outcome_evaluation_ongoing`. An outcome evaluation is still running. / Always `user.define_outcome`. The user defined the outcome the agent should reach. / Always `session.deleted`. The session was deleted. / Always `session.thread_status_running`. A thread started running. / Always `session.thread_status_idle`. A thread stopped running; stop_reason says why. / Always `session.thread_status_terminated`. A thread ended. / Always `user.tool_result`. The user's result for a client-side tool call. / Always `session.thread_status_rescheduled`. A thread will retry after a recoverable error. / Always `session.updated`. The session's model, title, metadata, agent or budget changed. / Always `system.message`. A message produced by the platform rather than the user or the agent. / Always `session.usage`. Cumulative usage of the session. / Always `session.forked`. The session was created by forking another session. / Always `session.goal_changed`. / Always `session.goal_verification`. / Always `user.steer`. Receipt that a queued user.message was injected into the running turn. / Always `user.tool_confirmation`. |
| data[].processed_at | null | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | null | string | string | string | null | string | string | string | string | string | string | string | A timestamp in RFC 3339 format / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / When the event was recorded, RFC 3339. / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / When the event was recorded, RFC 3339. |
| data[].message_id | string | UI transcript message ID. Use the last assistant message in a successfully completed turn as the fork target. / UI transcript message ID shared with this assistant's message parts. |
| data[].session_thread_id | null | string | string | string | string | string | null | string | string | If absent, interrupts every non-archived thread in a multiagent session (or the primary alone in a single-agent session). If present, interrupts only the named thread. / Set by the server to the subagent thread this confirmation was routed to. Omitted when it was routed to the primary thread. / Set by the server to the subagent thread this result was routed to. Omitted when it was routed to the primary thread. / When set, this event was cross-posted from a subagent's thread to surface its custom tool use on the primary thread's stream. Empty on the thread's own events. Informational only: the server routes the matching `user.custom_tool_result` by `custom_tool_use_id`, so clients do not send it back. / When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Informational only: the server routes the matching `user.tool_confirmation` by `tool_use_id`, so clients do not send it back. / When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Informational only: the server routes the matching `user.tool_confirmation` or `user.tool_result` by `tool_use_id`, so clients do not send it back. / Public `sthr_` ID of the newly created thread. / Public sthr_ ID of the thread that started running. / Public sthr_ ID of the thread that went idle. / Public sthr_ ID of the thread that terminated. / Set by the server to the subagent thread this result was routed to. Omitted when it was routed to the primary thread. / Public sthr_ ID of the thread that is retrying. |
| data[].result | string | UserToolConfirmationResult enum / Evaluation verdict. 'satisfied': criteria met, session goes idle. 'needs_revision': criteria not met, another revision cycle follows. 'max_iterations_reached': evaluation budget exhausted with criteria still unmet — one final acknowledgment turn follows before the session goes idle, but no further evaluation runs. 'failed': grader determined the rubric does not apply to the deliverables. 'interrupted': user sent an interrupt while evaluation was in progress. / Always `allow`. |
| data[].tool_use_id | string | The id of the `agent.tool_use` or `agent.mcp_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` event's `stop_reason.event_ids` field. / The id of the `agent.tool_use` event this result corresponds to. / The id of the `agent.tool_use` event this result corresponds to, which can be found in the last `session.status_idle` event's `stop_reason.event_ids` field. / The id of the AskUserQuestion `agent.tool_use` event this answers. |
| data[].deny_message | null | string | Optional message providing context for a 'deny' decision. Only allowed when result is 'deny'. |
| data[].custom_tool_use_id | string | The id of the `agent.custom_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` event's `stop_reason.event_ids` field. |
| data[].is_error | null | boolean | Whether the tool execution resulted in an error. / Whether the model request resulted in an error. / Whether the tool execution resulted in an error. |
| data[].input | object | Input parameters for the tool call. |
| data[].name | string | Name of the custom tool being called. / Name of the MCP tool being used. / Name of the agent tool being used. |
| data[].mcp_server_name | string | Name of the MCP server providing the tool. |
| data[].evaluated_permission | string | AgentEvaluatedPermission enum |
| data[].evaluation | object | Names the resolved permission_policy that produced evaluated_permission, and under auto carries the judgement. Open union: clients must tolerate unknown variants. |
| data[]._meta | object | Praxis extension (MCP Apps, SEP-1865): the `ui` and `openai/ui` keys of the MCP tool definition's `_meta`, verbatim; other `_meta` keys are not exposed. When `ui.resourceUri` is a `ui://` URI, the tool has an interactive view: a client that implements MCP Apps can fetch that resource from the MCP server and render it for this call. Absent when the tool declares neither key. Clients that do not render MCP Apps ignore it. / Praxis extension (MCP Apps, SEP-1865): the MCP CallToolResult `_meta`, verbatim. Views use it for data that should not reach the model; absent when the tool returned none. |
| data[].source | string | Praxis extension (MCP Apps, SEP-1865): `app` when the call was made by an MCP Apps view, `codemode` when a program run by the codemode tool called an MCP tool that declares a view (the event pair exists so a client can render that view; the model already has the result in the codemode tool result); absent for the model's own calls. / What caused the change. |
| data[].parent_tool_use_id | string | Praxis extension (MCP Apps, SEP-1865): present when `source` is `codemode`; the id of the codemode tool use whose program made this call. Absent otherwise. |
| data[].mcp_tool_use_id | string | The id of the `agent.mcp_tool_use` event this result corresponds to. |
| data[].structured_content | any | Praxis extension (MCP Apps, SEP-1865): the MCP CallToolResult `structuredContent`, verbatim JSON. MCP Apps views read it as the data to render; absent when the tool returned none. |
| data[].from_session_thread_id | string | Public `sthr_` ID of the thread that sent the message. |
| data[].from_agent_name | null | string | Name of the callable agent this message came from. Absent when received from the primary agent. |
| data[].to_session_thread_id | string | Public `sthr_` ID of the thread the message was sent to. |
| data[].to_agent_name | null | string | Name of the callable agent this message was sent to. Absent when sent to the primary agent. |
| data[].error | object | Description of the error and what the client should do next. |
| data[].stop_reason | object | Why the session stopped running, with the variant data needed to continue. |
| data[].agent_name | string | Name of the callable agent the thread runs. / Name of the agent the thread runs. / Name of the agent the thread runs. / Name of the agent the thread runs. / Name of the agent the thread runs. |
| data[].iteration | number | 0-indexed revision cycle. 0 is the first evaluation; 1 is the re-evaluation after the first revision; etc. / 0-indexed revision cycle, matching the corresponding `span.outcome_evaluation_start`. / 0-indexed revision cycle, matching the corresponding `span.outcome_evaluation_start`. |
| data[].outcome_id | string | The `outc_` ID of the outcome being evaluated. / Server-generated `outc_` ID for this outcome. Referenced by `span.outcome_evaluation_*` events and the session's `outcome_evaluations` list. |
| data[].explanation | string | Human-readable explanation of the verdict. For `needs_revision`, describes which criteria failed and why. |
| data[].outcome_evaluation_start_id | string | The id of the corresponding `span.outcome_evaluation_start` event. |
| data[].usage | object | Token usage for a single model request. / Point-in-time snapshot of a session's cumulative usage. |
| data[].model_request_start_id | string | The id of the corresponding `span.model_request_start` event. |
| data[].model_usage | object | Token usage for a single model request. |
| data[].description | string | What the agent should produce. Copied from the input event. |
| data[].max_iterations | null | number | Evaluate-then-revise cycles before giving up. Default 3, max 20. |
| data[].rubric | object | Rubric for grading the quality of an outcome. |
| data[].agent | null | object | Resolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time. |
| data[].budget | null | object | A hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`. |
| data[].metadata | object | The session's full metadata bag after the update. Present when the update set non-empty metadata; absent when metadata was unchanged or cleared to empty. |
| data[].title | null | string | The session's new title. Present only when the update changed it. |
| data[].model | object | Praxis extension: the changed session model, present only on /agent/v1 session.updated events. Model-only updates are omitted on /anthropic. |
| data[].forked_from_session_id | string | Id of the parent session this session was forked from. |
| data[].forked_from_message_id | string | message_id of the agent message in the parent session up to which the conversation was copied. |
| data[].action | string | What changed in the goal. |
| data[].goal | object | null | The goal as the change left it, or null when the session has no goal. |
| data[].previous_goal | object | null | The goal before the change, or null when there was none. |
| data[].status | string | Where the check stands. Read `verification.passed` on the closing event to know whether the goal counts as done. |
| data[].goal_id | string | The goal this check belongs to. |
| data[].goal_iteration | integer | Which check of this goal, matching `iteration` on the goal. |
| data[].verification_id | string | Identifier shared by every event of one check. |
| data[].anchor_message_id | string | null | The assistant message the check follows, or null. |
| data[].verification | object | The verdict; absent on `started`. |
| data[].event_id | string | Id of the event this event refers to. |
| data[].answers | object | The user's answer to each question, keyed by the question text; empty when the questions were dismissed. |
| data[].annotations | object | Per-question notes, keyed by the question text. |
| next_page | string | null | Opaque cursor for the next page: pass it unchanged as page to continue. Null when this is the last page. |
先调用「创建会话」,用返回的会话 ID 替换示例 ID。
/agent/v1/sessions/{session_id}/events◐ 部分支持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.
eventsarray必填要发送给会话的事件列表。
200
将 sesn_123 换成创建会话返回的 id。每条 user.message 只接受一个非空文本块。支持文本 user.message、user.interrupt 和工具确认;可发送 user.withdraw 并用 event_id 指向仍在排队的消息来撤回它,消息已开始处理时返回 409。运行中需要提前补充要求时,发送 user.steer 事件,并用 event_id 指向仍在排队的消息:当前工具继续执行,消息在下一次模型请求前进入当前回合。返回带 processed_at 的 user.steer 回执,重复标记返回同一回执;已开始或已撤回返回 409,事件不存在返回 404。有待授权时继续等待;若当前回合先结束,消息仍按普通队列处理。默认发送消息仍然排队,/anthropic 不接受 user.steer。其它事件变体尚不支持。返回的是已接纳事件;模型回复从事件历史或订阅读取。会话等待工具授权时发送的 user.message 会排队:返回的事件 processed_at 为 null,授权处理完成后按发送顺序执行。允许工具调用时可在 updated_permissions 中原样提交该调用的 permission_suggestions,让本次对话记住同类操作;危险操作不提供可记住的建议。使用网页搜索或读取网页时,/agent/v1 与 /anthropic 的工具结果均为官方 search_result 块;回答文本块的 citations 是 /agent/v1 的扩展字段,/anthropic 将回答引用显示为正文中的 [n]。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
Successful response
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| data | array<object> | Sent events |
| data[].id | string | Unique identifier for this event. / Event id, unique within the session. Use it to refer to this event, for example in user.tool_confirmation or user.steer. / Event id, unique within the session. |
| data[].content | array<object> | Array of content blocks comprising the user message. / The result content returned by the tool. / The result content returned by the tool. / System content blocks. Text-only. |
| data[].type | string | Always `user.message`. A message from the user to the agent, with content blocks. / Always `user.interrupt`. The user interrupted the running turn. / Always `user.tool_confirmation`. The user's decision to allow or deny a tool call that waits for approval. / Always `user.custom_tool_result`. The user's result for a custom tool call. / Always `user.define_outcome`. The user defined the outcome the agent should reach. / Always `user.tool_result`. The user's result for a client-side tool call. / Always `system.message`. A message produced by the platform rather than the user or the agent. / Always `user.steer`. Receipt that a queued user.message was injected into the running turn. / Always `user.tool_confirmation`. |
| data[].processed_at | null | string | string | null | string | null | string | string | string | A timestamp in RFC 3339 format / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / When the event was recorded, RFC 3339. |
| data[].session_thread_id | null | string | If absent, interrupts every non-archived thread in a multiagent session (or the primary alone in a single-agent session). If present, interrupts only the named thread. / Set by the server to the subagent thread this confirmation was routed to. Omitted when it was routed to the primary thread. / Set by the server to the subagent thread this result was routed to. Omitted when it was routed to the primary thread. / Set by the server to the subagent thread this result was routed to. Omitted when it was routed to the primary thread. |
| data[].result | string | UserToolConfirmationResult enum / Always `allow`. |
| data[].tool_use_id | string | The id of the `agent.tool_use` or `agent.mcp_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` event's `stop_reason.event_ids` field. / The id of the `agent.tool_use` event this result corresponds to, which can be found in the last `session.status_idle` event's `stop_reason.event_ids` field. / The id of the AskUserQuestion `agent.tool_use` event this answers. |
| data[].deny_message | null | string | Optional message providing context for a 'deny' decision. Only allowed when result is 'deny'. |
| data[].custom_tool_use_id | string | The id of the `agent.custom_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` event's `stop_reason.event_ids` field. |
| data[].is_error | null | boolean | Whether the tool execution resulted in an error. |
| data[].description | string | What the agent should produce. Copied from the input event. |
| data[].max_iterations | null | number | Evaluate-then-revise cycles before giving up. Default 3, max 20. |
| data[].outcome_id | string | Server-generated `outc_` ID for this outcome. Referenced by `span.outcome_evaluation_*` events and the session's `outcome_evaluations` list. |
| data[].rubric | object | Rubric for grading the quality of an outcome. |
| data[].event_id | string | Id of the event this event refers to. |
| data[].answers | object | The user's answer to each question, keyed by the question text; empty when the questions were dismissed. |
| data[].annotations | object | Per-question notes, keyed by the question text. |
先调用「创建会话」,用返回的会话 ID 替换示例 ID。
/agent/v1/sessions/{session_id}/events/stream◐ 部分支持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.
event_deltasarray可选query: When set, this connection also receives streaming deltas (`event_start`, `event_delta`) while an event is being produced, before the event itself arrives. Deltas are best-effort; when the final event is produced it carries the complete content. A model request that ends early (an error or interrupt) produces no final event — its terminal `span.model_request_end` closes the preview. Accepts one or more event types to preview and may be repeated: `agent.message` streams `content_delta` fragments; `agent.thinking` is start-only — a signal that the agent has begun extended thinking, concluded by the `agent.thinking` event itself. Only previews of the requested event types are sent.
200
保持 SSE 连接以接收事件;请求不会像普通 JSON 接口一样立刻结束。先创建会话并替换 sesn_123,再从另一请求发送消息;停止按钮只断开订阅,不会停止智能体。SDK 0.124.0 会过滤 session.usage,完整用量请读历史。传 event_deltas[]=agent.message 或 event_deltas[]=agent.thinking 可在最终事件到达前收到逐段预览(event_start 与 event_delta)。传 event_deltas[]=agent.tool_use 可以在参数生成过程中收到 input_json_delta 片段。使用网页搜索或读取网页时,/agent/v1 与 /anthropic 的工具结果均为官方 search_result 块;回答文本块的 citations 是 /agent/v1 的扩展字段,/anthropic 将回答引用显示为正文中的 [n]。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
Server-sent events
text/event-stream — chunk / 事件对象
| 名称 | 类型 | 说明 |
|---|---|---|
| id | string | Identifier of the object, as returned by the API; pass it in the path of follow-up calls on the same resource. |
| event | string | Server-Sent Events event name of this frame. / Always `user.message`. SSE event name of this frame; its data is a user.message payload. A message from the user to the agent, with content blocks. / Always `user.interrupt`. SSE event name of this frame; its data is a user.interrupt payload. The user interrupted the running turn. / Always `agent.message`. SSE event name of this frame; its data is a agent.message payload. A message from the agent, with text content blocks. / Always `agent.thinking`. SSE event name of this frame; its data is a agent.thinking payload. The agent's thinking text for a step. / Always `session.status_running`. SSE event name of this frame; its data is a session.status_running payload. The session started running a turn. / Always `session.status_rescheduled`. SSE event name of this frame; its data is a session.status_rescheduled payload. The session will retry after a recoverable error. / Always `session.status_idle`. SSE event name of this frame; its data is a session.status_idle payload. The session stopped running; stop_reason says why. / Always `session.status_terminated`. SSE event name of this frame; its data is a session.status_terminated payload. The session ended and accepts no more work. / Always `agent.thread_context_compacted`. SSE event name of this frame; its data is a agent.thread_context_compacted payload. The thread's context was compacted into a summary. / Always `agent.thread_context_reset`. SSE event name of this frame; its data is a agent.thread_context_reset payload. Content was removed from the model's context after a content-safety refusal. / Always `session.updated`. SSE event name of this frame; its data is a session.updated payload. The session's model, title, metadata, agent or budget changed. / Always `session.error`. SSE event name of this frame; its data is a session.error payload. The session hit an error. / Always `session.usage`. SSE event name of this frame; its data is a session.usage payload. Cumulative usage of the session. / Always `span.model_request_start`. SSE event name of this frame; its data is a span.model_request_start payload. A model request started. / Always `span.model_request_end`. SSE event name of this frame; its data is a span.model_request_end payload. A model request ended, with its usage. / Always `agent.tool_use`. SSE event name of this frame; its data is a agent.tool_use payload. The agent called a tool. / Always `agent.tool_result`. SSE event name of this frame; its data is a agent.tool_result payload. The result of a tool call. / Always `agent.mcp_tool_use`. SSE event name of this frame; its data is a agent.mcp_tool_use payload. The agent called an MCP tool. / Always `agent.mcp_tool_result`. SSE event name of this frame; its data is a agent.mcp_tool_result payload. The result of an MCP tool call. / Always `user.tool_confirmation`. SSE event name of this frame; its data is a user.tool_confirmation payload. The user's decision to allow or deny a tool call that waits for approval. / Always `session.thread_created`. SSE event name of this frame; its data is a session.thread_created payload. A child thread was started. / Always `session.thread_status_running`. SSE event name of this frame; its data is a session.thread_status_running payload. A thread started running. / Always `session.thread_status_idle`. SSE event name of this frame; its data is a session.thread_status_idle payload. A thread stopped running; stop_reason says why. / Always `session.thread_status_rescheduled`. SSE event name of this frame; its data is a session.thread_status_rescheduled payload. A thread will retry after a recoverable error. / Always `session.thread_status_terminated`. SSE event name of this frame; its data is a session.thread_status_terminated payload. A thread ended. / Always `agent.thread_message_sent`. SSE event name of this frame; its data is a agent.thread_message_sent payload. The agent sent a message to another thread. / Always `agent.thread_message_received`. SSE event name of this frame; its data is a agent.thread_message_received payload. The agent received a message from another thread. / Always `user.withdraw`. SSE event name of this frame; its data is a user.withdraw payload. A queued user.message was withdrawn before it ran. / Always `user.steer`. SSE event name of this frame; its data is a user.steer payload. Receipt that a queued user.message was injected into the running turn. / Always `system.notification`. SSE event name of this frame; its data is a system.notification payload. Background work woke the session with a notification. / Always `session.forked`. SSE event name of this frame; its data is a session.forked payload. The session was created by forking another session. / Always `session.goal_changed`. SSE event name of this frame; its data is a session.goal_changed payload. The session's goal was set, changed status, accounted usage or was cleared. / Always `session.goal_verification`. SSE event name of this frame; its data is a session.goal_verification payload. One completion check of the session's goal started or ended. / Always `event_start`. SSE event name of this frame; its data is a event_start payload. Preview that an event of the requested delta types has started. / Always `event_delta`. SSE event name of this frame; its data is a event_delta payload. Incremental fragment of the event being produced. / Always `ping`. SSE event name of this frame; its data is a ping payload. Keep-alive frame; carries no data. / Always `error`. SSE event name of this frame; its data is a error payload. A stream error. |
| data | object | Decoded JSON payload of this frame; its shape is selected by the event name. / Praxis extension (AskUserQuestion, own face only): the confirmation of an AskUserQuestion call, with the answers it carried. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Praxis extension (goal mode, own face only): the session's goal was set, moved to another status, accounted usage or was cleared. `goal` is the goal after the change, `previous_goal` the one before; each is null when there was none. / Praxis extension (goal mode, own face only): one completion check of the goal. A `started` event opens it; `completed`, `failed_closed` or `cancelled` closes it. Events of one check share `verification_id`. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. |
| data.id | string | Unique identifier for this event. / Text of the block. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Event id, unique within the session. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Text of the block. / Event id, unique within the session. Use it to refer to this event, for example in user.tool_confirmation or user.steer. / Text of the block. / Event id, unique within the session. Use it to refer to this event, for example in user.tool_confirmation or user.steer. / Event id, unique within the session. / Event id, unique within the session. Use it to refer to this event, for example in user.tool_confirmation or user.steer. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Text of the block. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Event id, unique within the session. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Text of the block. / Event id, unique within the session. Use it to refer to this event, for example in user.tool_confirmation or user.steer. / Text of the block. / Event id, unique within the session. Use it to refer to this event, for example in user.tool_confirmation or user.steer. / Event id, unique within the session. / Event id, unique within the session. Use it to refer to this event, for example in user.tool_confirmation or user.steer. |
| data.content | array<object> | Array of content blocks comprising the user message. / Array of text blocks comprising the agent response. / Content blocks of the event, in order. / The result content returned by the tool. / The result content returned by the tool. / Message content blocks. / Message content blocks. / Array of content blocks comprising the user message. / Array of text blocks comprising the agent response. / Content blocks of the event, in order. / The result content returned by the tool. / The result content returned by the tool. / Message content blocks. / Message content blocks. |
| data.type | string | Always `user.message`. A message from the user to the agent, with content blocks. / Always `user.interrupt`. The user interrupted the running turn. / Always `agent.message`. A message from the agent, with text content blocks. / Always `agent.thinking`. The agent's thinking text for a step. / Always `session.status_running`. The session started running a turn. / Always `session.status_rescheduled`. The session will retry after a recoverable error. / Always `session.status_idle`. The session stopped running; stop_reason says why. / Always `session.status_terminated`. The session ended and accepts no more work. / Always `agent.thread_context_compacted`. The thread's context was compacted into a summary. / Always `agent.thread_context_reset`. Content was removed from the model's context after a content-safety refusal. / Always `session.updated`. The session's model, title, metadata, agent or budget changed. / Always `session.error`. The session hit an error. / Always `session.usage`. Cumulative usage of the session. / Always `span.model_request_start`. A model request started. / Always `span.model_request_end`. A model request ended, with its usage. / Always `agent.tool_use`. The agent called a tool. / Always `agent.tool_result`. The result of a tool call. / Always `agent.mcp_tool_use`. The agent called an MCP tool. / Always `agent.mcp_tool_result`. The result of an MCP tool call. / Always `user.tool_confirmation`. / Always `session.thread_created`. A child thread was started. / Always `session.thread_status_running`. A thread started running. / Always `session.thread_status_idle`. A thread stopped running; stop_reason says why. / Always `session.thread_status_rescheduled`. A thread will retry after a recoverable error. / Always `session.thread_status_terminated`. A thread ended. / Always `agent.thread_message_sent`. The agent sent a message to another thread. / Always `agent.thread_message_received`. The agent received a message from another thread. / Always `user.withdraw`. A queued user.message was withdrawn before it ran. / Always `user.steer`. Receipt that a queued user.message was injected into the running turn. / Always `system.notification`. Background work woke the session with a notification. / Always `session.forked`. The session was created by forking another session. / Always `session.goal_changed`. / Always `session.goal_verification`. / Always `event_start`. Preview that an event of the requested delta types has started. / Always `event_delta`. Incremental fragment of the event being produced. / Always `ping`. Keep-alive frame; carries no data. / Always `error`. A stream error. / Always `user.message`. A message from the user to the agent, with content blocks. / Always `user.interrupt`. The user interrupted the running turn. / Always `agent.message`. A message from the agent, with text content blocks. / Always `agent.thinking`. The agent's thinking text for a step. / Always `session.status_running`. The session started running a turn. / Always `session.status_rescheduled`. The session will retry after a recoverable error. / Always `session.status_idle`. The session stopped running; stop_reason says why. / Always `session.status_terminated`. The session ended and accepts no more work. / Always `agent.thread_context_compacted`. The thread's context was compacted into a summary. / Always `agent.thread_context_reset`. Content was removed from the model's context after a content-safety refusal. / Always `session.updated`. The session's model, title, metadata, agent or budget changed. / Always `session.error`. The session hit an error. / Always `session.usage`. Cumulative usage of the session. / Always `span.model_request_start`. A model request started. / Always `span.model_request_end`. A model request ended, with its usage. / Always `agent.tool_use`. The agent called a tool. / Always `agent.tool_result`. The result of a tool call. / Always `agent.mcp_tool_use`. The agent called an MCP tool. / Always `agent.mcp_tool_result`. The result of an MCP tool call. / Always `user.tool_confirmation`. / Always `session.thread_created`. A child thread was started. / Always `session.thread_status_running`. A thread started running. / Always `session.thread_status_idle`. A thread stopped running; stop_reason says why. / Always `session.thread_status_rescheduled`. A thread will retry after a recoverable error. / Always `session.thread_status_terminated`. A thread ended. / Always `agent.thread_message_sent`. The agent sent a message to another thread. / Always `agent.thread_message_received`. The agent received a message from another thread. / Always `user.withdraw`. A queued user.message was withdrawn before it ran. / Always `user.steer`. Receipt that a queued user.message was injected into the running turn. / Always `system.notification`. Background work woke the session with a notification. / Always `session.forked`. The session was created by forking another session. / Always `session.goal_changed`. / Always `session.goal_verification`. / Always `event_start`. Preview that an event of the requested delta types has started. / Always `event_delta`. Incremental fragment of the event being produced. / Always `ping`. Keep-alive frame; carries no data. / Always `error`. A stream error. |
| data.processed_at | null | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | null | string | null | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | A timestamp in RFC 3339 format / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / When the event was recorded, RFC 3339. / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / When the event was recorded, RFC 3339. / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / When the event was recorded, RFC 3339. / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / When the event was recorded, RFC 3339. / RFC 3339 time at which the server processed the event; null while a queued input has not started running. |
| data.message_id | string | UI transcript message ID. Use the last assistant message in a successfully completed turn as the fork target. / UI transcript message ID shared with this assistant's message parts. / UI transcript message ID. Use the last assistant message in a successfully completed turn as the fork target. / UI transcript message ID. Use the last assistant message in a successfully completed turn as the fork target. / UI transcript message ID shared with this assistant's message parts. |
| data.session_thread_id | null | string | string | null | string | null | string | string | string | string | string | string | string | string | null | string | string | null | string | null | string | string | string | string | string | string | string | string | If absent, interrupts every non-archived thread in a multiagent session (or the primary alone in a single-agent session). If present, interrupts only the named thread. / Text of the block. / When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Informational only: the server routes the matching `user.tool_confirmation` or `user.tool_result` by `tool_use_id`, so clients do not send it back. / When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Informational only: the server routes the matching `user.tool_confirmation` by `tool_use_id`, so clients do not send it back. / Public `sthr_` ID of the newly created thread. / Public sthr_ ID of the thread that started running. / Public sthr_ ID of the thread that went idle. / Public sthr_ ID of the thread that is retrying. / Public sthr_ ID of the thread that terminated. / Text of the block. / Text of the block. / If absent, interrupts every non-archived thread in a multiagent session (or the primary alone in a single-agent session). If present, interrupts only the named thread. / Text of the block. / When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Informational only: the server routes the matching `user.tool_confirmation` or `user.tool_result` by `tool_use_id`, so clients do not send it back. / When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Informational only: the server routes the matching `user.tool_confirmation` by `tool_use_id`, so clients do not send it back. / Public `sthr_` ID of the newly created thread. / Public sthr_ ID of the thread that started running. / Public sthr_ ID of the thread that went idle. / Public sthr_ ID of the thread that is retrying. / Public sthr_ ID of the thread that terminated. / Text of the block. / Text of the block. |
| data.stop_reason | object | Why the session stopped running, with the variant data needed to continue. |
| data.removed | array<object> | Content removed from the model's context by this reset. |
| data.category | string | Text of the block. |
| data.stopped | boolean | True when the run was stopped instead of retried after the reset. |
| data.agent | null | object | Resolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time. |
| data.budget | null | object | A hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`. |
| data.metadata | object | The session's full metadata bag after the update. Present when the update set non-empty metadata; absent when metadata was unchanged or cleared to empty. |
| data.title | null | string | The session's new title. Present only when the update changed it. |
| data.model | object | Praxis extension: the changed session model, present only on /agent/v1 session.updated events. Model-only updates are omitted on /anthropic. |
| data.error | object | Description of the error and what the client should do next. / Error detail. / Description of the error and what the client should do next. / Error detail. |
| data.usage | object | Point-in-time snapshot of a session's cumulative usage. |
| data.is_error | null | boolean | Whether the model request resulted in an error. / Whether the tool execution resulted in an error. / Whether the tool execution resulted in an error. / Whether the model request resulted in an error. / Whether the tool execution resulted in an error. / Whether the tool execution resulted in an error. |
| data.model_request_start_id | string | The id of the corresponding `span.model_request_start` event. |
| data.model_usage | object | Token usage for a single model request. |
| data.input | object | Input parameters for the tool call. |
| data.name | string | Name of the agent tool being used. / Name of the MCP tool being used. / Name of the agent tool being used. / Name of the MCP tool being used. |
| data.evaluated_permission | string | AgentEvaluatedPermission enum |
| data.evaluation | object | Names the resolved permission_policy that produced evaluated_permission, and under auto carries the judgement. Open union: clients must tolerate unknown variants. |
| data.tool_use_id | string | The id of the `agent.tool_use` event this result corresponds to. / The id of the AskUserQuestion `agent.tool_use` event this answers. / The id of the `agent.tool_use` event this result corresponds to. / The id of the AskUserQuestion `agent.tool_use` event this answers. |
| data.mcp_server_name | string | Name of the MCP server providing the tool. |
| data._meta | object | Praxis extension (MCP Apps, SEP-1865): the `ui` and `openai/ui` keys of the MCP tool definition's `_meta`, verbatim; other `_meta` keys are not exposed. When `ui.resourceUri` is a `ui://` URI, the tool has an interactive view: a client that implements MCP Apps can fetch that resource from the MCP server and render it for this call. Absent when the tool declares neither key. Clients that do not render MCP Apps ignore it. / Praxis extension (MCP Apps, SEP-1865): the MCP CallToolResult `_meta`, verbatim. Views use it for data that should not reach the model; absent when the tool returned none. / Praxis extension (MCP Apps, SEP-1865): the `ui` and `openai/ui` keys of the MCP tool definition's `_meta`, verbatim; other `_meta` keys are not exposed. When `ui.resourceUri` is a `ui://` URI, the tool has an interactive view: a client that implements MCP Apps can fetch that resource from the MCP server and render it for this call. Absent when the tool declares neither key. Clients that do not render MCP Apps ignore it. / Praxis extension (MCP Apps, SEP-1865): the MCP CallToolResult `_meta`, verbatim. Views use it for data that should not reach the model; absent when the tool returned none. |
| data.source | string | Praxis extension (MCP Apps, SEP-1865): `app` when the call was made by an MCP Apps view, `codemode` when a program run by the codemode tool called an MCP tool that declares a view (the event pair exists so a client can render that view; the model already has the result in the codemode tool result); absent for the model's own calls. / What caused the change. / Praxis extension (MCP Apps, SEP-1865): `app` when the call was made by an MCP Apps view, `codemode` when a program run by the codemode tool called an MCP tool that declares a view (the event pair exists so a client can render that view; the model already has the result in the codemode tool result); absent for the model's own calls. / Praxis extension (MCP Apps, SEP-1865): `app` when the call was made by an MCP Apps view, `codemode` when a program run by the codemode tool called an MCP tool that declares a view (the event pair exists so a client can render that view; the model already has the result in the codemode tool result); absent for the model's own calls. / What caused the change. |
| data.parent_tool_use_id | string | Praxis extension (MCP Apps, SEP-1865): present when `source` is `codemode`; the id of the codemode tool use whose program made this call. Absent otherwise. |
| data.mcp_tool_use_id | string | The id of the `agent.mcp_tool_use` event this result corresponds to. |
| data.structured_content | any | Praxis extension (MCP Apps, SEP-1865): the MCP CallToolResult `structuredContent`, verbatim JSON. MCP Apps views read it as the data to render; absent when the tool returned none. |
| data.result | string | Always `allow`. |
| data.answers | object | The user's answer to each question, keyed by the question text; empty when the questions were dismissed. |
| data.annotations | object | Per-question notes, keyed by the question text. |
| data.agent_name | string | Name of the callable agent the thread runs. / Name of the agent the thread runs. / Name of the agent the thread runs. / Name of the agent the thread runs. / Name of the agent the thread runs. / Name of the callable agent the thread runs. / Name of the agent the thread runs. / Name of the agent the thread runs. / Name of the agent the thread runs. / Name of the agent the thread runs. |
| data.to_session_thread_id | string | Public `sthr_` ID of the thread the message was sent to. |
| data.to_agent_name | null | string | Name of the callable agent this message was sent to. Absent when sent to the primary agent. |
| data.from_session_thread_id | string | Public `sthr_` ID of the thread that sent the message. |
| data.from_agent_name | null | string | Name of the callable agent this message came from. Absent when received from the primary agent. |
| data.event_id | string | Text of the block. / Id of the event this event refers to. / Text of the block. / Text of the block. / Id of the event this event refers to. / Text of the block. |
| data.sources | array<object> | Background work that woke the session with this notification. |
| data.forked_from_session_id | string | Id of the parent session this session was forked from. |
| data.forked_from_message_id | string | message_id of the agent message in the parent session up to which the conversation was copied. |
| data.action | string | What changed in the goal. |
| data.goal | object | null | The goal as the change left it, or null when the session has no goal. |
| data.previous_goal | object | null | The goal before the change, or null when there was none. |
| data.status | string | Where the check stands. Read `verification.passed` on the closing event to know whether the goal counts as done. |
| data.goal_id | string | The goal this check belongs to. |
| data.goal_iteration | integer | Which check of this goal, matching `iteration` on the goal. |
| data.verification_id | string | Identifier shared by every event of one check. |
| data.anchor_message_id | string | null | The assistant message the check follows, or null. |
| data.verification | object | The verdict; absent on `started`. |
| data.event | object | Event name or event payload. |
| data.delta | object | Incremental fragment of the event being produced. |
同一地址也可以用 wss:// 建立只读 WebSocket,每个事件一帧,适合服务端长连接。连接、帧格式、关闭码与限额见用 WebSocket 订阅事件。
会话事件除了用 订阅事件(SSE)拉取,也可以在同一个地址上建立 WebSocket 接收:每个事件一帧,内容与 SSE 的事件数据完全相同。这是本平台在官方 SSE 之外额外提供的接入方式,适合在服务端长期挂着连接、把事件转发给自己系统的场景。
wss://api.deepraxis.com/agent/v1/sessions/{session_id}/events/stream这条连接是只读的:它只推送事件,不接收任何消息。发消息、打断仍然用 发送事件。
握手请求带与 HTTP 接口相同的认证头:Authorization: Bearer <API Key> 或 x-api-key: <API Key>。
浏览器原生的 WebSocket 不能设置请求头,所以这是服务端用法。浏览器里请用 SSE,或者由你的服务端建立连接后再转给前端。
握手失败时连接不会建立,服务端直接返回 HTTP 错误(错误体格式见错误):
| 情况 | 返回 |
|---|---|
| 没带凭证,或 Key 无效、已禁用 | 401 |
| 会话不存在,或不属于这个 Key 所在的工作区 | 404 |
| 同时进行的请求超过 Key 的并发上限 | 429,见限流 |
一条打开的 WebSocket 和一个进行中的 SSE 一样,会一直占用 Key 的一个并发名额,直到连接关闭。
每一帧都是一个 JSON 文本。连接建立后,第一帧是就绪通知:
{"type":"session.events.ready"}收到它之后,会话里产生的每个事件以一帧送达,event 字段就是 SSE 里的事件数据:
{"type":"session.event","event":{"id":"d4dc3d96-…","type":"agent.message","processed_at":"2026-09-26T13:35:04.906Z","content":[{"type":"text","text":"好"}]}}| 字段 | 说明 |
|---|---|
type | session.events.ready(就绪,只出现一次)或 session.event(一个事件) |
event | 仅 session.event 帧有;结构与事件列表返回的单个事件相同 |
同一个事件可能送达不止一次。例如一条 user.message 会先以 processed_at: null(已接纳、待处理)出现,被处理后再以带时间的形式出现一次。请按 event.id 去重,以最后一次为准。
| 关闭码 | 含义 | 你该做什么 |
|---|---|---|
1000 | 服务端正常结束订阅 | 需要继续接收就重新连接 |
1008 | 客户端向连接发送了消息 | 这条连接只读;不要发送任何帧 |
1011 | 服务端内部中断 | 重新连接,并用事件列表回填 |
1013 | 暂时超出限额(见下) | 重新连接,并用事件列表回填 |
1013 关闭。长会话请准备好重连。1013 关闭。断开期间产生的事件不会补发。重新连接后,用事件列表按时间补齐:
GET /agent/v1/sessions/{session_id}/events?order=asc&created_at[gt]=<你收到的最后一个事件的 processed_at>回填的事件和新连接推送的事件可能重叠,按 event.id 去重即可。
Bun(内置 WebSocket 支持 headers):
const ws = new WebSocket(
`wss://api.deepraxis.com/agent/v1/sessions/${sessionId}/events/stream`,
{ headers: { Authorization: `Bearer ${process.env.PRAXIS_API_KEY}` } },
);
ws.addEventListener("message", (message) => {
const frame = JSON.parse(String(message.data));
if (frame.type === "session.events.ready") console.log("ready");
if (frame.type === "session.event") console.log(frame.event.type, frame.event);
});
ws.addEventListener("close", (close) => console.log("closed", close.code));Node(ws 包):
import WebSocket from "ws";
const ws = new WebSocket(
`wss://api.deepraxis.com/agent/v1/sessions/${sessionId}/events/stream`,
{ headers: { Authorization: `Bearer ${process.env.PRAXIS_API_KEY}` } },
);
ws.on("message", (data) => {
const frame = JSON.parse(String(data));
if (frame.type === "session.event") console.log(frame.event.type, frame.event);
});
ws.on("close", (code) => console.log("closed", code));Python(websockets 包):
import asyncio, json, os
import websockets
async def main(session_id: str):
url = f"wss://api.deepraxis.com/agent/v1/sessions/{session_id}/events/stream"
headers = {"Authorization": f"Bearer {os.environ['PRAXIS_API_KEY']}"}
async with websockets.connect(url, additional_headers=headers) as ws:
async for message in ws:
frame = json.loads(message)
if frame["type"] == "session.event":
print(frame["event"]["type"], frame["event"])
asyncio.run(main("sesn_123"))先调用「创建会话」,用返回的会话 ID 替换示例 ID。
/agent/v1/sessions/{session_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.
modelstring可选扩展:模型 ID 字符串,必须属于会话钉住版本的 models.allowed;没有列表时只能选默认模型。下一轮生效,在途一轮不受影响,此处不检查上下文窗口。
agentobject可选会话要运行的智能体:直接写智能体 ID 字符串(固定用最新版本),或传对象指定 id 与 version(见子字段)。
mcp_serversarray可选替换本会话的 MCP 服务器列表:传入的数组整体生效;传空数组清除,省略沿用智能体的配置。
toolsarray可选替换本会话的工具配置;传空数组清除,省略沿用智能体的配置。
titlestring可选Human-readable session title.
metadataobject可选Metadata patch. Set a key to a string to upsert it, or to null to delete it. Omit the field to preserve.
budgetobject可选A hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`.
max_list_costobject必填预算内列表类调用的花费上限。
typestring必填预算类型,目前只有 max_list_cost。
vault_idsarray可选Vault IDs (`vlt_*`) to attach to the session. Not yet supported; requests setting this field are rejected. Reserved for future use.
thinkingobject可选Praxis extension: explicit session thinking effort; null inherits the pinned agent default, then the model default. none disables thinking only when model.thinking.can_disable is true. Unsupported efforts return 400 invalid_request_error.
effortstring必填Thinking level for this session. The model must support the chosen effort; none requires can_disable. Null on thinking restores inheritance from the agent and model.
200
可选 model 为钉住版本 allowed 内的 ID,thinking 为 {effort: "low|medium|high|xhigh|none"} 或 null。省略保留原值,null 恢复继承;仅换模型会清除不支持的会话档位。两者同时传入按新模型校验,不支持返回 400 且原选择不变。下一轮生效,在途一轮不变。示例:{"model":"deepseek-v4-flash","thinking":{"effort":"xhigh"}}。响应含 thinking 及 model.thinking: {efforts, can_disable, default_effort},能力未知为 null。这些选择字段仅在 /agent/v1 提供。支持 title 与 metadata(官方补丁语义:字符串值写入、null 删除该键、整包 null 清空,未提及的键保留)。官方的 agent 覆盖(tools/mcp_servers)、budget 与 vault_ids 不支持,传入返回 400 并点名字段。归档后的会话更新返回 409。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
Successful response
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| id | string | Session id (sesn_...). Pass it as session_id in every session call. |
| agent | object | Resolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time. |
| 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.model | object | Model identifier and configuration. |
| agent.multiagent | null | object | Resolved coordinator topology with full agent definitions for each roster member. |
| 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> | Skill attachments are not supported: a nonempty skills array returns 400. Omit this field or send an empty array. The native Skill tool loads available runtime skills independently of this field. |
| 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; custom tool definitions are rejected with 400. Keep bash enabled to use codemode, Skill and subagents. |
| agent.type | string | Always `agent`. An agent definition. |
| 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 |
| budget | null | object | A hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`. |
| budget.max_list_cost | object | A monetary amount in a specific currency. |
| budget.type | string | Always `limit`. A spending limit. |
| created_at | string | A timestamp in RFC 3339 format |
| environment_id | string | Id of the environment recipe the session's sandbox was created from. Omitted when no recipe was selected, that is, for a light machine or the Computer chosen by computer_id. |
| metadata | object | Free-form string key/value pairs stored with the session, changed through sessions.update patch semantics. |
| outcome_evaluations | array<object> | Per-outcome evaluation state. One entry per `define_outcome` event sent to the session. |
| outcome_evaluations[].completed_at | null | string | A timestamp in RFC 3339 format |
| outcome_evaluations[].description | string | What the agent should produce. |
| outcome_evaluations[].explanation | null | string | Grader's verdict text from the most recent evaluation. For `satisfied`, explains why criteria are met; for `needs_revision` (intermediate), what's missing; for `failed`, why unrecoverable. |
| outcome_evaluations[].iteration | number | 0-indexed revision cycle the outcome is currently on. |
| outcome_evaluations[].outcome_id | string | Server-generated outc_ ID for this outcome. |
| outcome_evaluations[].result | string | Current evaluation state. `pending` before the agent begins work; `running` while producing or revising; `evaluating` while the grader scores; `satisfied`/`max_iterations_reached`/`failed`/`interrupted` are terminal. |
| outcome_evaluations[].type | string | Always `outcome_evaluation`. Record of one outcome evaluation. |
| resources | array<object> | Resources attached to the session, at most 500; each is a file reference mounted into the session's machine. |
| resources[].id | string | Resource id, the resource_id of sessions.resources calls. |
| resources[].created_at | string | A timestamp in RFC 3339 format |
| resources[].mount_path | string | null | string | Path inside the machine where the file is mounted; defaults to /mnt/session/uploads/<file_id>, and custom paths are rooted there. / Filesystem path where the store is mounted in the session container, e.g. /mnt/memory/user-preferences. Derived from the store's name. Output-only. |
| resources[].type | string | Always `github_repository`. A GitHub repository resource; not supported on this platform. / Always `file`. A file resource: an uploaded file mounted into the session's machine. / Always `memory_store`. A memory store resource; not supported on this platform. |
| resources[].updated_at | string | A timestamp in RFC 3339 format |
| resources[].url | string | Repository URL. |
| resources[].checkout | null | object | Branch or commit to check out. |
| resources[].file_id | string | Id of the uploaded file; it must exist and belong to your tenant. |
| resources[].memory_store_id | string | The memory store ID (memstore_...). Must belong to the caller's organization and workspace. |
| resources[].access | null | string | Access mode for an attached memory store. |
| resources[].description | string | Description of the memory store, snapshotted at attach time. Rendered into the agent's system prompt. Empty string when the store has no description. |
| resources[].instructions | null | string | Per-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars. |
| resources[].name | null | string | Display name of the memory store, snapshotted at attach time. Later edits to the store's name do not propagate to this resource. |
| stats | object | Timing statistics for a session. |
| stats.active_seconds | number | Cumulative time in seconds the session spent in `running` status. Excludes idle time. |
| stats.duration_seconds | number | Elapsed time since session creation in seconds. For terminated sessions, frozen at the final update. |
| status | string | SessionStatus enum - `rescheduling` - Transient error occurred, retrying automatically. - `running` - Agent is actively executing. - `idle` - Agent is waiting for input, including user messages or tool confirmations. Sessions start in idle. - `terminated` - Session has ended, either due to an error or completion. |
| title | null | string | Title of the session, set on create or through sessions.update; null when none was set. |
| type | string | Always `session`. A session, one conversation of an agent on a machine. |
| updated_at | string | A timestamp in RFC 3339 format |
| usage | object | Cumulative token usage for a session across all turns. |
| usage.active_seconds | number | Cumulative time in seconds during which the session had at least one thread in running status. Overlapping activity from concurrent threads is counted once, unlike `stats.active_seconds`, which sums each thread's own active time. This is the duration the session's runtime 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. |
| vault_ids | array<string> | Vault IDs attached to the session at creation. Empty when no vaults were supplied. |
| deployment_id | null | string | Deployment ID when the session was created from a deployment reference. Null otherwise. |
| cwd | string | Normalized session working directory; defaults to /home/user/workspace. Forks inherit this directory. |
| computer_id | string | Praxis extension: MA only has session-scoped temporary containers and memory_stores, not durable browsable computers. computer_id selects a tenant-owned active computer. Session selection overrides the agent default; a sandbox environment_id and computer_id cannot be combined. Omitted when no computer is selected. |
| model | object | Praxis extension: the currently selected session model. |
| model.id | string | Identifier of the object, as returned by the API; pass it in the path of follow-up calls on the same resource. |
| model.thinking | object | null | Supported thinking controls, or null when capability is unknown or unavailable. efforts lists selectable strengths; can_disable permits none; default_effort is nullable. |
| thinking | object | null | Praxis extension: explicit session thinking effort; null inherits the pinned agent default, then the model default. none disables thinking only when model.thinking.can_disable is true. Unsupported efforts return 400 invalid_request_error. |
| thinking.effort | string | Thinking level saved for this session: low, medium, high, xhigh, or none to turn thinking off. Null or absent means the session inherits the agent default and then the model default. |
| forked_from | object | null | Praxis extension: source of a forked session; null for other sessions. Available only on /agent/v1. |
| forked_from.session_id | string | Id of the parent session this session was forked from; it is left unchanged by the fork. |
| forked_from.message_id | string | message_id of the agent message in the parent session up to which the conversation was copied. |
先调用「创建会话」,用返回的会话 ID 替换示例 ID。
/agent/v1/sessions/{session_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.
200
归档后的会话拒绝新消息(400 invalid_request_error,写明会话已归档),读取与事件历史仍可用;重复归档幂等,archived_at 保持首次归档时间。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
Successful response
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| id | string | Session id (sesn_...). Pass it as session_id in every session call. |
| agent | object | Resolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time. |
| 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.model | object | Model identifier and configuration. |
| agent.multiagent | null | object | Resolved coordinator topology with full agent definitions for each roster member. |
| 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> | Skill attachments are not supported: a nonempty skills array returns 400. Omit this field or send an empty array. The native Skill tool loads available runtime skills independently of this field. |
| 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; custom tool definitions are rejected with 400. Keep bash enabled to use codemode, Skill and subagents. |
| agent.type | string | Always `agent`. An agent definition. |
| 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 |
| budget | null | object | A hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`. |
| budget.max_list_cost | object | A monetary amount in a specific currency. |
| budget.type | string | Always `limit`. A spending limit. |
| created_at | string | A timestamp in RFC 3339 format |
| environment_id | string | Id of the environment recipe the session's sandbox was created from. Omitted when no recipe was selected, that is, for a light machine or the Computer chosen by computer_id. |
| metadata | object | Free-form string key/value pairs stored with the session, changed through sessions.update patch semantics. |
| outcome_evaluations | array<object> | Per-outcome evaluation state. One entry per `define_outcome` event sent to the session. |
| outcome_evaluations[].completed_at | null | string | A timestamp in RFC 3339 format |
| outcome_evaluations[].description | string | What the agent should produce. |
| outcome_evaluations[].explanation | null | string | Grader's verdict text from the most recent evaluation. For `satisfied`, explains why criteria are met; for `needs_revision` (intermediate), what's missing; for `failed`, why unrecoverable. |
| outcome_evaluations[].iteration | number | 0-indexed revision cycle the outcome is currently on. |
| outcome_evaluations[].outcome_id | string | Server-generated outc_ ID for this outcome. |
| outcome_evaluations[].result | string | Current evaluation state. `pending` before the agent begins work; `running` while producing or revising; `evaluating` while the grader scores; `satisfied`/`max_iterations_reached`/`failed`/`interrupted` are terminal. |
| outcome_evaluations[].type | string | Always `outcome_evaluation`. Record of one outcome evaluation. |
| resources | array<object> | Resources attached to the session, at most 500; each is a file reference mounted into the session's machine. |
| resources[].id | string | Resource id, the resource_id of sessions.resources calls. |
| resources[].created_at | string | A timestamp in RFC 3339 format |
| resources[].mount_path | string | null | string | Path inside the machine where the file is mounted; defaults to /mnt/session/uploads/<file_id>, and custom paths are rooted there. / Filesystem path where the store is mounted in the session container, e.g. /mnt/memory/user-preferences. Derived from the store's name. Output-only. |
| resources[].type | string | Always `github_repository`. A GitHub repository resource; not supported on this platform. / Always `file`. A file resource: an uploaded file mounted into the session's machine. / Always `memory_store`. A memory store resource; not supported on this platform. |
| resources[].updated_at | string | A timestamp in RFC 3339 format |
| resources[].url | string | Repository URL. |
| resources[].checkout | null | object | Branch or commit to check out. |
| resources[].file_id | string | Id of the uploaded file; it must exist and belong to your tenant. |
| resources[].memory_store_id | string | The memory store ID (memstore_...). Must belong to the caller's organization and workspace. |
| resources[].access | null | string | Access mode for an attached memory store. |
| resources[].description | string | Description of the memory store, snapshotted at attach time. Rendered into the agent's system prompt. Empty string when the store has no description. |
| resources[].instructions | null | string | Per-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars. |
| resources[].name | null | string | Display name of the memory store, snapshotted at attach time. Later edits to the store's name do not propagate to this resource. |
| stats | object | Timing statistics for a session. |
| stats.active_seconds | number | Cumulative time in seconds the session spent in `running` status. Excludes idle time. |
| stats.duration_seconds | number | Elapsed time since session creation in seconds. For terminated sessions, frozen at the final update. |
| status | string | SessionStatus enum - `rescheduling` - Transient error occurred, retrying automatically. - `running` - Agent is actively executing. - `idle` - Agent is waiting for input, including user messages or tool confirmations. Sessions start in idle. - `terminated` - Session has ended, either due to an error or completion. |
| title | null | string | Title of the session, set on create or through sessions.update; null when none was set. |
| type | string | Always `session`. A session, one conversation of an agent on a machine. |
| updated_at | string | A timestamp in RFC 3339 format |
| usage | object | Cumulative token usage for a session across all turns. |
| usage.active_seconds | number | Cumulative time in seconds during which the session had at least one thread in running status. Overlapping activity from concurrent threads is counted once, unlike `stats.active_seconds`, which sums each thread's own active time. This is the duration the session's runtime 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. |
| vault_ids | array<string> | Vault IDs attached to the session at creation. Empty when no vaults were supplied. |
| deployment_id | null | string | Deployment ID when the session was created from a deployment reference. Null otherwise. |
| cwd | string | Normalized session working directory; defaults to /home/user/workspace. Forks inherit this directory. |
| computer_id | string | Praxis extension: MA only has session-scoped temporary containers and memory_stores, not durable browsable computers. computer_id selects a tenant-owned active computer. Session selection overrides the agent default; a sandbox environment_id and computer_id cannot be combined. Omitted when no computer is selected. |
| model | object | Praxis extension: the currently selected session model. |
| model.id | string | Identifier of the object, as returned by the API; pass it in the path of follow-up calls on the same resource. |
| model.thinking | object | null | Supported thinking controls, or null when capability is unknown or unavailable. efforts lists selectable strengths; can_disable permits none; default_effort is nullable. |
| thinking | object | null | Praxis extension: explicit session thinking effort; null inherits the pinned agent default, then the model default. none disables thinking only when model.thinking.can_disable is true. Unsupported efforts return 400 invalid_request_error. |
| thinking.effort | string | Thinking level saved for this session: low, medium, high, xhigh, or none to turn thinking off. Null or absent means the session inherits the agent default and then the model default. |
| forked_from | object | null | Praxis extension: source of a forked session; null for other sessions. Available only on /agent/v1. |
| forked_from.session_id | string | Id of the parent session this session was forked from; it is left unchanged by the fork. |
| forked_from.message_id | string | message_id of the agent message in the parent session up to which the conversation was copied. |
先调用「创建会话」,用返回的会话 ID 替换示例 ID。
/agent/v1/sessions/{session_id}/threads◐ 部分支持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.
limitnumber可选query: Number of items per page.
pagestring可选query: Opaque pagination cursor: pass the next_page value of the previous response unchanged. Omit it for the first page. A cursor from a different query or a malformed one returns 400.
200
按 created_at 升序返回主线程及全部子线程。线程 id 为 sthr_ 加所属会话 id 的后缀;子线程的 parent_thread_id 指向主线程,session_id 始终为父会话。agent 是实际运行的定义,内置类型的 name 为类型名,未注册的 id/version 为 null。归档子线程的 status 为 terminated,archived_at 为归档时间;stats/usage 无线程级追踪时如实为 null。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
Successful response
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| data | array<object> | Items of this page, in the order requested by the call. |
| data[].id | string | Unique identifier for this thread. |
| data[].agent | object | The resolved agent a `session_thread` runs. |
| data[].archived_at | null | string | A timestamp in RFC 3339 format |
| data[].created_at | string | A timestamp in RFC 3339 format |
| data[].parent_thread_id | null | string | Parent thread that spawned this thread. Null for the primary thread. |
| data[].session_id | string | The session this thread belongs to. |
| data[].stats | null | object | Timing statistics for a session thread. |
| data[].status | string | SessionThreadStatus enum |
| data[].type | string | Always `session_thread`. An execution thread of a session. |
| data[].updated_at | string | A timestamp in RFC 3339 format |
| data[].usage | null | object | Cumulative token usage for a session thread across all turns. |
| next_page | string | null | Opaque cursor for the next page: pass it unchanged as page to continue. Null when this is the last page. |
先调用「创建会话」,用返回的会话 ID 替换示例 ID。
/agent/v1/sessions/{session_id}/threads/{thread_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.
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
返回本会话的主线程或子线程,与列表项逐字段一致。其他会话的线程、未知线程或非 sthr_ id 一律返回 404,不泄露其存在性。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
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> | Skill attachments are not supported: a nonempty skills array returns 400. Omit this field or send an empty array. The native Skill tool loads available runtime skills independently of this field. |
| 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; custom tool definitions are rejected with 400. Keep bash enabled to use codemode, Skill and subagents. |
| 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. |
先调用「创建会话」,用返回的会话 ID 替换示例 ID。
/agent/v1/sessions/{session_id}/threads/{thread_id}/events◐ 部分支持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.
limitnumber可选query: Number of items per page.
pagestring可选query: Opaque pagination cursor: pass the next_page value of the previous response unchanged. Omit it for the first page. A cursor from a different query or a malformed one returns 400.
200
读取所选线程自己的事件记录:主线程读主会话,子线程读对应子会话。沿用会话事件接口的查询参数、公开事件类型和 data + next_page 信封。使用网页工具时,两个接口均返回 search_result 块;回答 citations 为 /agent/v1 扩展,/anthropic 将引用显示为正文 [n]。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
Successful response
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| data | array<object> | Items of this page, in the order requested by the call. |
| data[].id | string | Unique identifier for this event. / Event id, unique within the session. Use it to refer to this event, for example in user.tool_confirmation or user.steer. / Event id, unique within the session. / Event id, unique within the session. Use it to refer to this event, for example in user.tool_confirmation or user.steer. / Event id, unique within the session. Use it to refer to this event, for example in user.tool_confirmation or user.steer. |
| data[].content | array<object> | Array of content blocks comprising the user message. / The result content returned by the tool. / Array of text blocks comprising the agent response. / The result content returned by the tool. / The result content returned by the tool. / Message content blocks. / Message content blocks. / The result content returned by the tool. / System content blocks. Text-only. |
| data[].type | string | Always `user.message`. A message from the user to the agent, with content blocks. / Always `user.interrupt`. The user interrupted the running turn. / Always `user.tool_confirmation`. The user's decision to allow or deny a tool call that waits for approval. / Always `user.custom_tool_result`. The user's result for a custom tool call. / Always `agent.custom_tool_use`. The agent called a custom tool defined by the client. / Always `agent.message`. A message from the agent, with text content blocks. / Always `agent.thinking`. The agent's thinking text for a step. / Always `agent.mcp_tool_use`. The agent called an MCP tool. / Always `agent.mcp_tool_result`. The result of an MCP tool call. / Always `agent.tool_use`. The agent called a tool. / Always `agent.tool_result`. The result of a tool call. / Always `agent.thread_message_received`. The agent received a message from another thread. / Always `agent.thread_message_sent`. The agent sent a message to another thread. / Always `agent.thread_context_compacted`. The thread's context was compacted into a summary. / Always `session.error`. The session hit an error. / Always `session.status_rescheduled`. The session will retry after a recoverable error. / Always `session.status_running`. The session started running a turn. / Always `session.status_idle`. The session stopped running; stop_reason says why. / Always `session.status_terminated`. The session ended and accepts no more work. / Always `session.thread_created`. A child thread was started. / Always `span.outcome_evaluation_start`. An outcome evaluation started. / Always `span.outcome_evaluation_end`. An outcome evaluation ended. / Always `span.model_request_start`. A model request started. / Always `span.model_request_end`. A model request ended, with its usage. / Always `span.outcome_evaluation_ongoing`. An outcome evaluation is still running. / Always `user.define_outcome`. The user defined the outcome the agent should reach. / Always `session.deleted`. The session was deleted. / Always `session.thread_status_running`. A thread started running. / Always `session.thread_status_idle`. A thread stopped running; stop_reason says why. / Always `session.thread_status_terminated`. A thread ended. / Always `user.tool_result`. The user's result for a client-side tool call. / Always `session.thread_status_rescheduled`. A thread will retry after a recoverable error. / Always `session.updated`. The session's model, title, metadata, agent or budget changed. / Always `system.message`. A message produced by the platform rather than the user or the agent. / Always `session.usage`. Cumulative usage of the session. / Always `session.forked`. The session was created by forking another session. / Always `session.goal_changed`. / Always `session.goal_verification`. / Always `user.steer`. Receipt that a queued user.message was injected into the running turn. |
| data[].processed_at | null | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | null | string | string | string | null | string | string | string | string | string | string | A timestamp in RFC 3339 format / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / When the event was recorded, RFC 3339. / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / RFC 3339 time at which the server processed the event; null while a queued input has not started running. |
| data[].message_id | string | UI transcript message ID. Use the last assistant message in a successfully completed turn as the fork target. / UI transcript message ID shared with this assistant's message parts. |
| data[].session_thread_id | null | string | string | string | string | string | null | string | string | If absent, interrupts every non-archived thread in a multiagent session (or the primary alone in a single-agent session). If present, interrupts only the named thread. / Set by the server to the subagent thread this confirmation was routed to. Omitted when it was routed to the primary thread. / Set by the server to the subagent thread this result was routed to. Omitted when it was routed to the primary thread. / When set, this event was cross-posted from a subagent's thread to surface its custom tool use on the primary thread's stream. Empty on the thread's own events. Informational only: the server routes the matching `user.custom_tool_result` by `custom_tool_use_id`, so clients do not send it back. / When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Informational only: the server routes the matching `user.tool_confirmation` by `tool_use_id`, so clients do not send it back. / When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Informational only: the server routes the matching `user.tool_confirmation` or `user.tool_result` by `tool_use_id`, so clients do not send it back. / Public `sthr_` ID of the newly created thread. / Public sthr_ ID of the thread that started running. / Public sthr_ ID of the thread that went idle. / Public sthr_ ID of the thread that terminated. / Set by the server to the subagent thread this result was routed to. Omitted when it was routed to the primary thread. / Public sthr_ ID of the thread that is retrying. |
| data[].result | string | UserToolConfirmationResult enum / Evaluation verdict. 'satisfied': criteria met, session goes idle. 'needs_revision': criteria not met, another revision cycle follows. 'max_iterations_reached': evaluation budget exhausted with criteria still unmet — one final acknowledgment turn follows before the session goes idle, but no further evaluation runs. 'failed': grader determined the rubric does not apply to the deliverables. 'interrupted': user sent an interrupt while evaluation was in progress. |
| data[].tool_use_id | string | The id of the `agent.tool_use` or `agent.mcp_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` event's `stop_reason.event_ids` field. / The id of the `agent.tool_use` event this result corresponds to. / The id of the `agent.tool_use` event this result corresponds to, which can be found in the last `session.status_idle` event's `stop_reason.event_ids` field. |
| data[].deny_message | null | string | Optional message providing context for a 'deny' decision. Only allowed when result is 'deny'. |
| data[].custom_tool_use_id | string | The id of the `agent.custom_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` event's `stop_reason.event_ids` field. |
| data[].is_error | null | boolean | Whether the tool execution resulted in an error. / Whether the model request resulted in an error. / Whether the tool execution resulted in an error. |
| data[].input | object | Input parameters for the tool call. |
| data[].name | string | Name of the custom tool being called. / Name of the MCP tool being used. / Name of the agent tool being used. |
| data[].mcp_server_name | string | Name of the MCP server providing the tool. |
| data[].evaluated_permission | string | AgentEvaluatedPermission enum |
| data[].evaluation | object | Names the resolved permission_policy that produced evaluated_permission, and under auto carries the judgement. Open union: clients must tolerate unknown variants. |
| data[].parent_tool_use_id | string | Praxis extension (MCP Apps, SEP-1865): present when `source` is `codemode`; the id of the codemode tool use whose program made this call. Absent otherwise. |
| data[]._meta | object | Praxis extension (MCP Apps, SEP-1865): the `ui` and `openai/ui` keys of the MCP tool definition's `_meta`, verbatim; other `_meta` keys are not exposed. When `ui.resourceUri` is a `ui://` URI, the tool has an interactive view: a client that implements MCP Apps can fetch that resource from the MCP server and render it for this call. Absent when the tool declares neither key. Clients that do not render MCP Apps ignore it. / Praxis extension (MCP Apps, SEP-1865): the MCP CallToolResult `_meta`, verbatim. Views use it for data that should not reach the model; absent when the tool returned none. |
| data[].source | string | Praxis extension (MCP Apps, SEP-1865): `app` when the call was made by an MCP Apps view, `codemode` when a program run by the codemode tool called an MCP tool that declares a view (the event pair exists so a client can render that view; the model already has the result in the codemode tool result); absent for the model's own calls. / What caused the change. |
| data[].mcp_tool_use_id | string | The id of the `agent.mcp_tool_use` event this result corresponds to. |
| data[].structured_content | any | Praxis extension (MCP Apps, SEP-1865): the MCP CallToolResult `structuredContent`, verbatim JSON. MCP Apps views read it as the data to render; absent when the tool returned none. |
| data[].from_session_thread_id | string | Public `sthr_` ID of the thread that sent the message. |
| data[].from_agent_name | null | string | Name of the callable agent this message came from. Absent when received from the primary agent. |
| data[].to_session_thread_id | string | Public `sthr_` ID of the thread the message was sent to. |
| data[].to_agent_name | null | string | Name of the callable agent this message was sent to. Absent when sent to the primary agent. |
| data[].error | object | Description of the error and what the client should do next. |
| data[].stop_reason | object | Why the session stopped running, with the variant data needed to continue. |
| data[].agent_name | string | Name of the callable agent the thread runs. / Name of the agent the thread runs. / Name of the agent the thread runs. / Name of the agent the thread runs. / Name of the agent the thread runs. |
| data[].iteration | number | 0-indexed revision cycle. 0 is the first evaluation; 1 is the re-evaluation after the first revision; etc. / 0-indexed revision cycle, matching the corresponding `span.outcome_evaluation_start`. / 0-indexed revision cycle, matching the corresponding `span.outcome_evaluation_start`. |
| data[].outcome_id | string | The `outc_` ID of the outcome being evaluated. / Server-generated `outc_` ID for this outcome. Referenced by `span.outcome_evaluation_*` events and the session's `outcome_evaluations` list. |
| data[].explanation | string | Human-readable explanation of the verdict. For `needs_revision`, describes which criteria failed and why. |
| data[].outcome_evaluation_start_id | string | The id of the corresponding `span.outcome_evaluation_start` event. |
| data[].usage | object | Token usage for a single model request. / Point-in-time snapshot of a session's cumulative usage. |
| data[].model_request_start_id | string | The id of the corresponding `span.model_request_start` event. |
| data[].model_usage | object | Token usage for a single model request. |
| data[].description | string | What the agent should produce. Copied from the input event. |
| data[].max_iterations | null | number | Evaluate-then-revise cycles before giving up. Default 3, max 20. |
| data[].rubric | object | Rubric for grading the quality of an outcome. |
| data[].agent | null | object | Resolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time. |
| data[].budget | null | object | A hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`. |
| data[].metadata | object | The session's full metadata bag after the update. Present when the update set non-empty metadata; absent when metadata was unchanged or cleared to empty. |
| data[].title | null | string | The session's new title. Present only when the update changed it. |
| data[].model | object | Praxis extension: the changed session model, present only on /agent/v1 session.updated events. Model-only updates are omitted on /anthropic. |
| data[].forked_from_session_id | string | Id of the parent session this session was forked from. |
| data[].forked_from_message_id | string | message_id of the agent message in the parent session up to which the conversation was copied. |
| data[].action | string | What changed in the goal. |
| data[].goal | object | null | The goal as the change left it, or null when the session has no goal. |
| data[].previous_goal | object | null | The goal before the change, or null when there was none. |
| data[].status | string | Where the check stands. Read `verification.passed` on the closing event to know whether the goal counts as done. |
| data[].goal_id | string | The goal this check belongs to. |
| data[].goal_iteration | integer | Which check of this goal, matching `iteration` on the goal. |
| data[].verification_id | string | Identifier shared by every event of one check. |
| data[].anchor_message_id | string | null | The assistant message the check follows, or null. |
| data[].verification | object | The verdict; absent on `started`. |
| data[].event_id | string | Id of the event this event refers to. |
| next_page | string | null | Opaque cursor for the next page: pass it unchanged as page to continue. Null when this is the last page. |
先调用「创建会话」,用返回的会话 ID 替换示例 ID。
/agent/v1/sessions/{session_id}/threads/{thread_id}/stream◐ 部分支持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.
event_deltasarray可选query: When set, this connection also receives streaming deltas (`event_start`, `event_delta`) while an event is being produced, before the event itself arrives. Deltas are best-effort; when the final event is produced it carries the complete content. A model request that ends early (an error or interrupt) produces no final event — its terminal `span.model_request_end` closes the preview. Accepts one or more event types to preview and may be repeated: `agent.message` streams `content_delta` fragments; `agent.thinking` is start-only — a signal that the agent has begun extended thinking, concluded by the `agent.thinking` event itself. Only previews of the requested event types are sent.
200
订阅所选线程自己的实时事件流。复用会话 SSE 实现;/agent 接口支持同址只读 WebSocket。主会话流同时包含子线程创建、状态和消息事件,子线程审批带 session_thread_id 上浮;确认或中断携带该字段时路由到所属子线程。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
Server-sent events
text/event-stream — chunk / 事件对象
| 名称 | 类型 | 说明 |
|---|---|---|
| id | string | Identifier of the object, as returned by the API; pass it in the path of follow-up calls on the same resource. |
| event | string | Server-Sent Events event name of this frame. / Always `user.message`. SSE event name of this frame; its data is a user.message payload. A message from the user to the agent, with content blocks. / Always `user.interrupt`. SSE event name of this frame; its data is a user.interrupt payload. The user interrupted the running turn. / Always `agent.message`. SSE event name of this frame; its data is a agent.message payload. A message from the agent, with text content blocks. / Always `agent.thinking`. SSE event name of this frame; its data is a agent.thinking payload. The agent's thinking text for a step. / Always `session.status_running`. SSE event name of this frame; its data is a session.status_running payload. The session started running a turn. / Always `session.status_rescheduled`. SSE event name of this frame; its data is a session.status_rescheduled payload. The session will retry after a recoverable error. / Always `session.status_idle`. SSE event name of this frame; its data is a session.status_idle payload. The session stopped running; stop_reason says why. / Always `session.status_terminated`. SSE event name of this frame; its data is a session.status_terminated payload. The session ended and accepts no more work. / Always `agent.thread_context_compacted`. SSE event name of this frame; its data is a agent.thread_context_compacted payload. The thread's context was compacted into a summary. / Always `agent.thread_context_reset`. SSE event name of this frame; its data is a agent.thread_context_reset payload. Content was removed from the model's context after a content-safety refusal. / Always `session.updated`. SSE event name of this frame; its data is a session.updated payload. The session's model, title, metadata, agent or budget changed. / Always `session.error`. SSE event name of this frame; its data is a session.error payload. The session hit an error. / Always `session.usage`. SSE event name of this frame; its data is a session.usage payload. Cumulative usage of the session. / Always `span.model_request_start`. SSE event name of this frame; its data is a span.model_request_start payload. A model request started. / Always `span.model_request_end`. SSE event name of this frame; its data is a span.model_request_end payload. A model request ended, with its usage. / Always `agent.tool_use`. SSE event name of this frame; its data is a agent.tool_use payload. The agent called a tool. / Always `agent.tool_result`. SSE event name of this frame; its data is a agent.tool_result payload. The result of a tool call. / Always `agent.mcp_tool_use`. SSE event name of this frame; its data is a agent.mcp_tool_use payload. The agent called an MCP tool. / Always `agent.mcp_tool_result`. SSE event name of this frame; its data is a agent.mcp_tool_result payload. The result of an MCP tool call. / Always `user.tool_confirmation`. SSE event name of this frame; its data is a user.tool_confirmation payload. The user's decision to allow or deny a tool call that waits for approval. / Always `session.thread_created`. SSE event name of this frame; its data is a session.thread_created payload. A child thread was started. / Always `session.thread_status_running`. SSE event name of this frame; its data is a session.thread_status_running payload. A thread started running. / Always `session.thread_status_idle`. SSE event name of this frame; its data is a session.thread_status_idle payload. A thread stopped running; stop_reason says why. / Always `session.thread_status_rescheduled`. SSE event name of this frame; its data is a session.thread_status_rescheduled payload. A thread will retry after a recoverable error. / Always `session.thread_status_terminated`. SSE event name of this frame; its data is a session.thread_status_terminated payload. A thread ended. / Always `agent.thread_message_sent`. SSE event name of this frame; its data is a agent.thread_message_sent payload. The agent sent a message to another thread. / Always `agent.thread_message_received`. SSE event name of this frame; its data is a agent.thread_message_received payload. The agent received a message from another thread. / Always `user.withdraw`. SSE event name of this frame; its data is a user.withdraw payload. A queued user.message was withdrawn before it ran. / Always `user.steer`. SSE event name of this frame; its data is a user.steer payload. Receipt that a queued user.message was injected into the running turn. / Always `system.notification`. SSE event name of this frame; its data is a system.notification payload. Background work woke the session with a notification. / Always `session.forked`. SSE event name of this frame; its data is a session.forked payload. The session was created by forking another session. / Always `session.goal_changed`. SSE event name of this frame; its data is a session.goal_changed payload. The session's goal was set, changed status, accounted usage or was cleared. / Always `session.goal_verification`. SSE event name of this frame; its data is a session.goal_verification payload. One completion check of the session's goal started or ended. / Always `event_start`. SSE event name of this frame; its data is a event_start payload. Preview that an event of the requested delta types has started. / Always `event_delta`. SSE event name of this frame; its data is a event_delta payload. Incremental fragment of the event being produced. / Always `ping`. SSE event name of this frame; its data is a ping payload. Keep-alive frame; carries no data. / Always `error`. SSE event name of this frame; its data is a error payload. A stream error. |
| data | object | Decoded JSON payload of this frame; its shape is selected by the event name. / Praxis extension (AskUserQuestion, own face only): the confirmation of an AskUserQuestion call, with the answers it carried. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Praxis extension (goal mode, own face only): the session's goal was set, moved to another status, accounted usage or was cleared. `goal` is the goal after the change, `previous_goal` the one before; each is null when there was none. / Praxis extension (goal mode, own face only): one completion check of the goal. A `started` event opens it; `completed`, `failed_closed` or `cancelled` closes it. Events of one check share `verification_id`. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. |
| data.id | string | Unique identifier for this event. / Text of the block. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Event id, unique within the session. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Text of the block. / Event id, unique within the session. Use it to refer to this event, for example in user.tool_confirmation or user.steer. / Text of the block. / Event id, unique within the session. Use it to refer to this event, for example in user.tool_confirmation or user.steer. / Event id, unique within the session. / Event id, unique within the session. Use it to refer to this event, for example in user.tool_confirmation or user.steer. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Text of the block. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Event id, unique within the session. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Text of the block. / Event id, unique within the session. Use it to refer to this event, for example in user.tool_confirmation or user.steer. / Text of the block. / Event id, unique within the session. Use it to refer to this event, for example in user.tool_confirmation or user.steer. / Event id, unique within the session. / Event id, unique within the session. Use it to refer to this event, for example in user.tool_confirmation or user.steer. |
| data.content | array<object> | Array of content blocks comprising the user message. / Array of text blocks comprising the agent response. / Content blocks of the event, in order. / The result content returned by the tool. / The result content returned by the tool. / Message content blocks. / Message content blocks. / Array of content blocks comprising the user message. / Array of text blocks comprising the agent response. / Content blocks of the event, in order. / The result content returned by the tool. / The result content returned by the tool. / Message content blocks. / Message content blocks. |
| data.type | string | Always `user.message`. A message from the user to the agent, with content blocks. / Always `user.interrupt`. The user interrupted the running turn. / Always `agent.message`. A message from the agent, with text content blocks. / Always `agent.thinking`. The agent's thinking text for a step. / Always `session.status_running`. The session started running a turn. / Always `session.status_rescheduled`. The session will retry after a recoverable error. / Always `session.status_idle`. The session stopped running; stop_reason says why. / Always `session.status_terminated`. The session ended and accepts no more work. / Always `agent.thread_context_compacted`. The thread's context was compacted into a summary. / Always `agent.thread_context_reset`. Content was removed from the model's context after a content-safety refusal. / Always `session.updated`. The session's model, title, metadata, agent or budget changed. / Always `session.error`. The session hit an error. / Always `session.usage`. Cumulative usage of the session. / Always `span.model_request_start`. A model request started. / Always `span.model_request_end`. A model request ended, with its usage. / Always `agent.tool_use`. The agent called a tool. / Always `agent.tool_result`. The result of a tool call. / Always `agent.mcp_tool_use`. The agent called an MCP tool. / Always `agent.mcp_tool_result`. The result of an MCP tool call. / Always `user.tool_confirmation`. / Always `session.thread_created`. A child thread was started. / Always `session.thread_status_running`. A thread started running. / Always `session.thread_status_idle`. A thread stopped running; stop_reason says why. / Always `session.thread_status_rescheduled`. A thread will retry after a recoverable error. / Always `session.thread_status_terminated`. A thread ended. / Always `agent.thread_message_sent`. The agent sent a message to another thread. / Always `agent.thread_message_received`. The agent received a message from another thread. / Always `user.withdraw`. A queued user.message was withdrawn before it ran. / Always `user.steer`. Receipt that a queued user.message was injected into the running turn. / Always `system.notification`. Background work woke the session with a notification. / Always `session.forked`. The session was created by forking another session. / Always `session.goal_changed`. / Always `session.goal_verification`. / Always `event_start`. Preview that an event of the requested delta types has started. / Always `event_delta`. Incremental fragment of the event being produced. / Always `ping`. Keep-alive frame; carries no data. / Always `error`. A stream error. / Always `user.message`. A message from the user to the agent, with content blocks. / Always `user.interrupt`. The user interrupted the running turn. / Always `agent.message`. A message from the agent, with text content blocks. / Always `agent.thinking`. The agent's thinking text for a step. / Always `session.status_running`. The session started running a turn. / Always `session.status_rescheduled`. The session will retry after a recoverable error. / Always `session.status_idle`. The session stopped running; stop_reason says why. / Always `session.status_terminated`. The session ended and accepts no more work. / Always `agent.thread_context_compacted`. The thread's context was compacted into a summary. / Always `agent.thread_context_reset`. Content was removed from the model's context after a content-safety refusal. / Always `session.updated`. The session's model, title, metadata, agent or budget changed. / Always `session.error`. The session hit an error. / Always `session.usage`. Cumulative usage of the session. / Always `span.model_request_start`. A model request started. / Always `span.model_request_end`. A model request ended, with its usage. / Always `agent.tool_use`. The agent called a tool. / Always `agent.tool_result`. The result of a tool call. / Always `agent.mcp_tool_use`. The agent called an MCP tool. / Always `agent.mcp_tool_result`. The result of an MCP tool call. / Always `user.tool_confirmation`. / Always `session.thread_created`. A child thread was started. / Always `session.thread_status_running`. A thread started running. / Always `session.thread_status_idle`. A thread stopped running; stop_reason says why. / Always `session.thread_status_rescheduled`. A thread will retry after a recoverable error. / Always `session.thread_status_terminated`. A thread ended. / Always `agent.thread_message_sent`. The agent sent a message to another thread. / Always `agent.thread_message_received`. The agent received a message from another thread. / Always `user.withdraw`. A queued user.message was withdrawn before it ran. / Always `user.steer`. Receipt that a queued user.message was injected into the running turn. / Always `system.notification`. Background work woke the session with a notification. / Always `session.forked`. The session was created by forking another session. / Always `session.goal_changed`. / Always `session.goal_verification`. / Always `event_start`. Preview that an event of the requested delta types has started. / Always `event_delta`. Incremental fragment of the event being produced. / Always `ping`. Keep-alive frame; carries no data. / Always `error`. A stream error. |
| data.processed_at | null | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | null | string | null | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | A timestamp in RFC 3339 format / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / When the event was recorded, RFC 3339. / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / When the event was recorded, RFC 3339. / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / When the event was recorded, RFC 3339. / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / When the event was recorded, RFC 3339. / RFC 3339 time at which the server processed the event; null while a queued input has not started running. |
| data.message_id | string | UI transcript message ID. Use the last assistant message in a successfully completed turn as the fork target. / UI transcript message ID shared with this assistant's message parts. / UI transcript message ID. Use the last assistant message in a successfully completed turn as the fork target. / UI transcript message ID. Use the last assistant message in a successfully completed turn as the fork target. / UI transcript message ID shared with this assistant's message parts. |
| data.session_thread_id | null | string | string | null | string | null | string | string | string | string | string | string | string | string | null | string | string | null | string | null | string | string | string | string | string | string | string | string | If absent, interrupts every non-archived thread in a multiagent session (or the primary alone in a single-agent session). If present, interrupts only the named thread. / Text of the block. / When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Informational only: the server routes the matching `user.tool_confirmation` or `user.tool_result` by `tool_use_id`, so clients do not send it back. / When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Informational only: the server routes the matching `user.tool_confirmation` by `tool_use_id`, so clients do not send it back. / Public `sthr_` ID of the newly created thread. / Public sthr_ ID of the thread that started running. / Public sthr_ ID of the thread that went idle. / Public sthr_ ID of the thread that is retrying. / Public sthr_ ID of the thread that terminated. / Text of the block. / Text of the block. / If absent, interrupts every non-archived thread in a multiagent session (or the primary alone in a single-agent session). If present, interrupts only the named thread. / Text of the block. / When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Informational only: the server routes the matching `user.tool_confirmation` or `user.tool_result` by `tool_use_id`, so clients do not send it back. / When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Informational only: the server routes the matching `user.tool_confirmation` by `tool_use_id`, so clients do not send it back. / Public `sthr_` ID of the newly created thread. / Public sthr_ ID of the thread that started running. / Public sthr_ ID of the thread that went idle. / Public sthr_ ID of the thread that is retrying. / Public sthr_ ID of the thread that terminated. / Text of the block. / Text of the block. |
| data.stop_reason | object | Why the session stopped running, with the variant data needed to continue. |
| data.removed | array<object> | Content removed from the model's context by this reset. |
| data.category | string | Text of the block. |
| data.stopped | boolean | True when the run was stopped instead of retried after the reset. |
| data.agent | null | object | Resolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time. |
| data.budget | null | object | A hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`. |
| data.metadata | object | The session's full metadata bag after the update. Present when the update set non-empty metadata; absent when metadata was unchanged or cleared to empty. |
| data.title | null | string | The session's new title. Present only when the update changed it. |
| data.model | object | Praxis extension: the changed session model, present only on /agent/v1 session.updated events. Model-only updates are omitted on /anthropic. |
| data.error | object | Description of the error and what the client should do next. / Error detail. / Description of the error and what the client should do next. / Error detail. |
| data.usage | object | Point-in-time snapshot of a session's cumulative usage. |
| data.is_error | null | boolean | Whether the model request resulted in an error. / Whether the tool execution resulted in an error. / Whether the tool execution resulted in an error. / Whether the model request resulted in an error. / Whether the tool execution resulted in an error. / Whether the tool execution resulted in an error. |
| data.model_request_start_id | string | The id of the corresponding `span.model_request_start` event. |
| data.model_usage | object | Token usage for a single model request. |
| data.input | object | Input parameters for the tool call. |
| data.name | string | Name of the agent tool being used. / Name of the MCP tool being used. / Name of the agent tool being used. / Name of the MCP tool being used. |
| data.evaluated_permission | string | AgentEvaluatedPermission enum |
| data.evaluation | object | Names the resolved permission_policy that produced evaluated_permission, and under auto carries the judgement. Open union: clients must tolerate unknown variants. |
| data.tool_use_id | string | The id of the `agent.tool_use` event this result corresponds to. / The id of the AskUserQuestion `agent.tool_use` event this answers. / The id of the `agent.tool_use` event this result corresponds to. / The id of the AskUserQuestion `agent.tool_use` event this answers. |
| data.mcp_server_name | string | Name of the MCP server providing the tool. |
| data._meta | object | Praxis extension (MCP Apps, SEP-1865): the `ui` and `openai/ui` keys of the MCP tool definition's `_meta`, verbatim; other `_meta` keys are not exposed. When `ui.resourceUri` is a `ui://` URI, the tool has an interactive view: a client that implements MCP Apps can fetch that resource from the MCP server and render it for this call. Absent when the tool declares neither key. Clients that do not render MCP Apps ignore it. / Praxis extension (MCP Apps, SEP-1865): the MCP CallToolResult `_meta`, verbatim. Views use it for data that should not reach the model; absent when the tool returned none. / Praxis extension (MCP Apps, SEP-1865): the `ui` and `openai/ui` keys of the MCP tool definition's `_meta`, verbatim; other `_meta` keys are not exposed. When `ui.resourceUri` is a `ui://` URI, the tool has an interactive view: a client that implements MCP Apps can fetch that resource from the MCP server and render it for this call. Absent when the tool declares neither key. Clients that do not render MCP Apps ignore it. / Praxis extension (MCP Apps, SEP-1865): the MCP CallToolResult `_meta`, verbatim. Views use it for data that should not reach the model; absent when the tool returned none. |
| data.source | string | Praxis extension (MCP Apps, SEP-1865): `app` when the call was made by an MCP Apps view, `codemode` when a program run by the codemode tool called an MCP tool that declares a view (the event pair exists so a client can render that view; the model already has the result in the codemode tool result); absent for the model's own calls. / What caused the change. / Praxis extension (MCP Apps, SEP-1865): `app` when the call was made by an MCP Apps view, `codemode` when a program run by the codemode tool called an MCP tool that declares a view (the event pair exists so a client can render that view; the model already has the result in the codemode tool result); absent for the model's own calls. / Praxis extension (MCP Apps, SEP-1865): `app` when the call was made by an MCP Apps view, `codemode` when a program run by the codemode tool called an MCP tool that declares a view (the event pair exists so a client can render that view; the model already has the result in the codemode tool result); absent for the model's own calls. / What caused the change. |
| data.parent_tool_use_id | string | Praxis extension (MCP Apps, SEP-1865): present when `source` is `codemode`; the id of the codemode tool use whose program made this call. Absent otherwise. |
| data.mcp_tool_use_id | string | The id of the `agent.mcp_tool_use` event this result corresponds to. |
| data.structured_content | any | Praxis extension (MCP Apps, SEP-1865): the MCP CallToolResult `structuredContent`, verbatim JSON. MCP Apps views read it as the data to render; absent when the tool returned none. |
| data.result | string | Always `allow`. |
| data.answers | object | The user's answer to each question, keyed by the question text; empty when the questions were dismissed. |
| data.annotations | object | Per-question notes, keyed by the question text. |
| data.agent_name | string | Name of the callable agent the thread runs. / Name of the agent the thread runs. / Name of the agent the thread runs. / Name of the agent the thread runs. / Name of the agent the thread runs. / Name of the callable agent the thread runs. / Name of the agent the thread runs. / Name of the agent the thread runs. / Name of the agent the thread runs. / Name of the agent the thread runs. |
| data.to_session_thread_id | string | Public `sthr_` ID of the thread the message was sent to. |
| data.to_agent_name | null | string | Name of the callable agent this message was sent to. Absent when sent to the primary agent. |
| data.from_session_thread_id | string | Public `sthr_` ID of the thread that sent the message. |
| data.from_agent_name | null | string | Name of the callable agent this message came from. Absent when received from the primary agent. |
| data.event_id | string | Text of the block. / Id of the event this event refers to. / Text of the block. / Text of the block. / Id of the event this event refers to. / Text of the block. |
| data.sources | array<object> | Background work that woke the session with this notification. |
| data.forked_from_session_id | string | Id of the parent session this session was forked from. |
| data.forked_from_message_id | string | message_id of the agent message in the parent session up to which the conversation was copied. |
| data.action | string | What changed in the goal. |
| data.goal | object | null | The goal as the change left it, or null when the session has no goal. |
| data.previous_goal | object | null | The goal before the change, or null when there was none. |
| data.status | string | Where the check stands. Read `verification.passed` on the closing event to know whether the goal counts as done. |
| data.goal_id | string | The goal this check belongs to. |
| data.goal_iteration | integer | Which check of this goal, matching `iteration` on the goal. |
| data.verification_id | string | Identifier shared by every event of one check. |
| data.anchor_message_id | string | null | The assistant message the check follows, or null. |
| data.verification | object | The verdict; absent on `started`. |
| data.event | object | Event name or event payload. |
| data.delta | object | Incremental fragment of the event being produced. |
先调用「创建会话」,用返回的会话 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),参见 错误码
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> | Skill attachments are not supported: a nonempty skills array returns 400. Omit this field or send an empty array. The native Skill tool loads available runtime skills independently of this field. |
| 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; custom tool definitions are rejected with 400. Keep bash enabled to use codemode, Skill and subagents. |
| 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. |
/agent/v1/environments◐ 部分支持include_archivedboolean可选query: Include archived environments in the response
limitnumber可选query: Number of items per page.
pagestring可选query: Opaque pagination cursor: pass the next_page value of the previous response unchanged. Omit it for the first page. A cursor from a different query or a malformed one returns 400.
200
支持租户自建 cloud 环境、配置更新与软归档;内置环境只读。列表支持 limit、page 和 include_archived。limited 网络在沙箱创建时生效;安装失败会终止会话,错误码为 ENVIRONMENT_PACKAGE_INSTALL_FAILED。self_hosted、scope 和跨会话包缓存尚不支持。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
Successful response
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| data | array<object> | Items of this page, in the order requested by the call. |
| data[].id | string | Environment identifier (e.g., 'env_...') |
| data[].archived_at | null | string | RFC 3339 timestamp when environment was archived, or null if not archived |
| data[].config | object | Environment configuration (either Anthropic Cloud or self-hosted) |
| data[].created_at | string | RFC 3339 timestamp when environment was created |
| data[].description | null | string | User-provided description for the environment; null when unset |
| data[].metadata | object | User-provided metadata key-value pairs |
| data[].name | string | Human-readable name for the environment |
| data[].type | string | The type of object (always 'environment') |
| data[].updated_at | string | RFC 3339 timestamp when environment was last updated |
| data[].scope | string | The visibility scope for this environment. 'organization' means visible to all accounts. 'account' means visible only to the owning account. |
| next_page | string | null | Opaque cursor for the next page: pass it unchanged as page to continue. Null when this is the last page. |
/agent/v1/environments/{environment_id}◐ 部分支持environment_idstring必填path: Environment id, as returned by environments.create or environments.list. Built-in environments can be read but not changed.
200
支持租户自建 cloud 环境、配置更新与软归档;内置环境只读。列表支持 limit、page 和 include_archived。limited 网络在沙箱创建时生效;安装失败会终止会话,错误码为 ENVIRONMENT_PACKAGE_INSTALL_FAILED。self_hosted、scope 和跨会话包缓存尚不支持。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
Successful response
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| id | string | Environment identifier (e.g., 'env_...') |
| archived_at | null | string | RFC 3339 timestamp when environment was archived, or null if not archived |
| config | object | Environment configuration (either Anthropic Cloud or self-hosted) |
| config.networking | object | Network configuration policy. |
| config.packages | object | Package manager configuration. |
| config.type | string | Environment type |
| created_at | string | RFC 3339 timestamp when environment was created |
| description | null | string | User-provided description for the environment; null when unset |
| metadata | object | User-provided metadata key-value pairs |
| name | string | Human-readable name for the environment |
| type | string | The type of object (always 'environment') |
| updated_at | string | RFC 3339 timestamp when environment was last updated |
| scope | string | The visibility scope for this environment. 'organization' means visible to all accounts. 'account' means visible only to the owning account. |
/agent/v1/toolsets● 支持200
返回工具集说明、插件名称与版本,以及每个工具的名称、说明、参数定义、是否只读和默认授权方式。通过 /agent/v1/toolsets 读取此目录;目录不会更改智能体配置。agent_toolset_20260401 包含全部 13 个原生工具;TaskOutput、TaskStop、Monitor、Agent、SendMessage 与其他工具一样可逐个开关及设置权限,它们都依赖 bash。兼容 API 只提供官方 8 个工具。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
Available toolsets
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| data | array<object> | Items of this page, in the order requested by the call. |
| data[].type | string | Toolset type id as used in an agent's tools entry, for example agent_toolset_20260401. |
| data[].plugin | object | Unit that registers the toolset, with its name and version. |
| data[].description | string | Free-text description; null when none was set. |
| data[].environment | string | Environment in which the toolset's tools run, for example node22. |
| data[].tools | array<object> | Tools offered to the model. |
| next_page | null | Opaque cursor for the next page: pass it unchanged as page to continue. Null when this is the last page. |