智能体 API

2026-10-20

智能体 API

(待译)

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.

基础地址

加载中…

接入

加载中…

智能体域的概念与整体介绍见智能体服务;鉴权方式见鉴权。

端点

电脑(10 个端点,10 个可用)

方法路径说明支持
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上传电脑附件● 支持

会话资源(4 个端点,4 个可用)

方法路径说明支持
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}删除会话资源◐ 部分支持

智能体(6 个端点,6 个可用)

方法路径说明支持
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归档智能体● 支持

会话与事件(16 个端点,16 个可用)

方法路径说明支持
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归档会话● 支持

会话线程(5 个端点,5 个可用)

方法路径说明支持
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归档线程◐ 部分支持

执行环境(5 个端点,5 个可用)

方法路径说明支持
POST/v1/environments创建环境◐ 部分支持
POST/v1/environments/{environment_id}更新环境◐ 部分支持
POST/v1/environments/{environment_id}/archive归档环境◐ 部分支持
GET/v1/environments列出环境◐ 部分支持
GET/v1/environments/{environment_id}读取环境◐ 部分支持

工具集(1 个端点,1 个可用)

方法路径说明支持
GET/v1/toolsets列出工具集● 支持

与官方的差异

  • 本面只声明列出的 30 个端点(含工具集目录、上下文快照、压缩操作与后台任务):官方其余 Managed Agents 操作不在本面,调用得到 404。需要 Anthropic 协议兼容接入时用兼容面 /anthropic —— 官方有、平台未支持的操作在那里如实返回 501(not_implemented_error),不产生任何副作用。
  • 创建环境:支持租户自建 cloud 环境、配置更新与软归档;内置环境只读。列表支持 limit、page 和 include_archived。limited 网络在沙箱创建时生效;安装失败会终止会话,错误码为 ENVIRONMENT_PACKAGE_INSTALL_FAILED。self_hosted、scope 和跨会话包缓存尚不支持。
  • 更新环境:支持租户自建 cloud 环境、配置更新与软归档;内置环境只读。列表支持 limit、page 和 include_archived。limited 网络在沙箱创建时生效;安装失败会终止会话,错误码为 ENVIRONMENT_PACKAGE_INSTALL_FAILED。self_hosted、scope 和跨会话包缓存尚不支持。
  • 归档环境:支持租户自建 cloud 环境、配置更新与软归档;内置环境只读。列表支持 limit、page 和 include_archived。limited 网络在沙箱创建时生效;安装失败会终止会话,错误码为 ENVIRONMENT_PACKAGE_INSTALL_FAILED。self_hosted、scope 和跨会话包缓存尚不支持。
  • 创建电脑:Praxis 超集:MA 只有会话级临时容器与 memory_stores,没有可长期存续、可浏览的整台电脑。归档后文件仍可读,但不能用于新会话。environment_id 是可空配方引用;电脑默认使用 light sandbox,sandbox_id 为 SDK 可用的公开 ID。分页包含归档电脑。
  • 列出电脑:Praxis 超集:MA 只有会话级临时容器与 memory_stores,没有可长期存续、可浏览的整台电脑。归档后文件仍可读,但不能用于新会话。environment_id 是可空配方引用;电脑默认使用 light sandbox,sandbox_id 为 SDK 可用的公开 ID。分页包含归档电脑。
  • 读取电脑:Praxis 超集:MA 只有会话级临时容器与 memory_stores,没有可长期存续、可浏览的整台电脑。归档后文件仍可读,但不能用于新会话。environment_id 是可空配方引用;电脑默认使用 light sandbox,sandbox_id 为 SDK 可用的公开 ID。分页包含归档电脑。
  • 更新电脑:Praxis 超集:MA 只有会话级临时容器与 memory_stores,没有可长期存续、可浏览的整台电脑。归档后文件仍可读,但不能用于新会话。environment_id 是可空配方引用;电脑默认使用 light sandbox,sandbox_id 为 SDK 可用的公开 ID。分页包含归档电脑。
  • 归档电脑:Praxis 超集:MA 只有会话级临时容器与 memory_stores,没有可长期存续、可浏览的整台电脑。归档后文件仍可读,但不能用于新会话。environment_id 是可空配方引用;电脑默认使用 light sandbox,sandbox_id 为 SDK 可用的公开 ID。分页包含归档电脑。
  • 删除已归档电脑:Praxis 扩展:Managed Agents 没有持久 Computer 的删除生命周期。仅允许已归档的电脑;active 返回 400 COMPUTER_ACTIVE(先归档),先销毁电脑数据再删除登记,成功返回 id 和 type=computer_deleted;不存在或跨租户返回 404。
  • 浏览电脑文件:Praxis 超集:MA 只有会话级临时容器与 memory_stores,没有可长期存续、可浏览的整台电脑。归档后文件仍可读,但不能用于新会话。environment_id 是可空配方引用;电脑默认使用 light sandbox,sandbox_id 为 SDK 可用的公开 ID。分页包含归档电脑。
  • 读取电脑文件内容:Praxis 超集:MA 只有会话级临时容器与 memory_stores,没有可长期存续、可浏览的整台电脑。归档后文件仍可读,但不能用于新会话。environment_id 是可空配方引用;电脑默认使用 light sandbox,sandbox_id 为 SDK 可用的公开 ID。分页包含归档电脑。
  • 连接电脑:Praxis 自有扩展:Managed Agents 没有持久 Computer 连接。返回 SDK 可用的公开 sandbox_id、envd_access_token 和 template_id。归档电脑仍可连接;跨租户或不存在返回 404。连接凭证不可缓存。
  • 上传电脑附件:Praxis 扩展:Managed Agents 没有持久 Computer 附件目录。用户上传可以覆盖同名附件,智能体始终只读;运行令牌调用上传返回 403 READ_ONLY。name 是单个文件名、最多 255 UTF-8 字节,MIME 始终按扩展名推断,上传的 Content-Type 不持久保存,digest 可省略。上限 16 MiB,超限 413、非法名字 400;归档电脑也可上传,跨租户 404。
  • 添加会话资源:支持 file 类型资源的持久化、查询和解除关联,单会话最多 500 条。文件须属于当前租户且有效。默认路径为 /mnt/session/uploads/<file_id>,自定义路径归一到该目录,拒绝父目录遍历。不修改文件内容;本批尚不将资源同步到沙箱。
  • 列出会话资源:支持 file 类型资源的持久化、查询和解除关联,单会话最多 500 条。文件须属于当前租户且有效。默认路径为 /mnt/session/uploads/<file_id>,自定义路径归一到该目录,拒绝父目录遍历。不修改文件内容;本批尚不将资源同步到沙箱。
  • 读取会话资源:支持 file 类型资源的持久化、查询和解除关联,单会话最多 500 条。文件须属于当前租户且有效。默认路径为 /mnt/session/uploads/<file_id>,自定义路径归一到该目录,拒绝父目录遍历。不修改文件内容;本批尚不将资源同步到沙箱。
  • 删除会话资源:支持 file 类型资源的持久化、查询和解除关联,单会话最多 500 条。文件须属于当前租户且有效。默认路径为 /mnt/session/uploads/<file_id>,自定义路径归一到该目录,拒绝父目录遍历。不修改文件内容;本批尚不将资源同步到沙箱。
  • 创建智能体: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 不接受或返回此字段。
  • 读取智能体:tools 在一个 agent_toolset_20260401 条目中返回全部原生工具的有效配置,可原样用于更新。将示例中的资源 ID 替换成你创建的资源 ID。
  • 更新智能体:通过 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 不接受或返回此字段。
  • 列出版本:将示例中的资源 ID 替换成你创建的资源 ID。
  • 归档智能体:归档后保留查询与历史版本,不能继续更新。请只归档自己的测试智能体。
  • 列出会话:支持 limit、page 与 agent_id;agent_version、时间范围、deployment_id、memory_store_id、include_archived、order、statuses 尚不支持,传入返回 400。
  • 创建会话:可在创建时传 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>,自定义路径归一到该目录,拒绝父目录遍历。不修改文件内容;本批尚不将资源同步到沙箱。
  • 读取会话:将示例中的资源 ID 替换成你创建的资源 ID。
  • 分支会话(扩展):仅在 /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。初始化失败时不公开新会话,并回收已分出的沙箱。
  • 读取会话上下文(扩展):扩展:仅在 /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。
  • 列出后台任务(扩展):仅在 /agent/v1 提供。kind 是开放字符串。subagent 行的 thread_id 指向对应子线程,其他 kind 为 null。completed 且 delivery=pending 显示 result_pending。notified_at 是系统通知批次被受理开轮的时间,无则 null。trigger_count 仅监视器返回已受理的事件批次数,无记录则 null。时间为 RFC3339。会话不存在或不可见返回 404。
  • 读取后台任务输出(扩展):offset 默认 0;max_bytes 默认 65536,上限 262144。返回 text、next_offset、eof。沙箱已暂停或不存在时返回空 text、原 offset、eof=true、unavailable=true。读取不确认模型结果。
  • 停止后台任务(扩展):复用 TaskStop:持久化 stop_requested_at 并终止进程组。返回 BackgroundTask;终止尚未观察到时仍可为 running,但不可取消。已结束或不支持停止的任务返回 409。
  • 压缩会话(扩展):仅在 /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。
  • 读取压缩操作(扩展):仅在 /agent/v1 提供。响应为 { type: session_compaction, id, status, reason? },所有状态均返回 200。操作不存在或会话不可见时返回 404 not_found_error。
  • 列出压缩历史(扩展):仅在 /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。
  • 列出事件:先发送消息再读取历史;处理完成前可能只看到已接纳的输入。支持分页、事件类型和时间过滤。会话等待工具授权时停在 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]。
  • 发送事件:将 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]。
  • 订阅事件:保持 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]。
  • 更新会话:可选 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。
  • 归档会话:归档后的会话拒绝新消息(400 invalid_request_error,写明会话已归档),读取与事件历史仍可用;重复归档幂等,archived_at 保持首次归档时间。
  • 列出线程:按 created_at 升序返回主线程及全部子线程。线程 id 为 sthr_ 加所属会话 id 的后缀;子线程的 parent_thread_id 指向主线程,session_id 始终为父会话。agent 是实际运行的定义,内置类型的 name 为类型名,未注册的 id/version 为 null。归档子线程的 status 为 terminated,archived_at 为归档时间;stats/usage 无线程级追踪时如实为 null。
  • 读取线程:返回本会话的主线程或子线程,与列表项逐字段一致。其他会话的线程、未知线程或非 sthr_ id 一律返回 404,不泄露其存在性。
  • 列出线程事件:读取所选线程自己的事件记录:主线程读主会话,子线程读对应子会话。沿用会话事件接口的查询参数、公开事件类型和 data + next_page 信封。使用网页工具时,两个接口均返回 search_result 块;回答 citations 为 /agent/v1 扩展,/anthropic 将引用显示为正文 [n]。
  • 订阅线程事件:订阅所选线程自己的实时事件流。复用会话 SSE 实现;/agent 接口支持同址只读 WebSocket。主会话流同时包含子线程创建、状态和消息事件,子线程审批带 session_thread_id 上浮;确认或中断携带该字段时路由到所属子线程。
  • 归档线程:主线程沿用会话归档动作;子线程仅归档对应子会话,不归档父会话或其他子线程。子线程归档后 status 为 terminated,带 archived_at;历史事件仍可读。
  • 列出环境:支持租户自建 cloud 环境、配置更新与软归档;内置环境只读。列表支持 limit、page 和 include_archived。limited 网络在沙箱创建时生效;安装失败会终止会话,错误码为 ENVIRONMENT_PACKAGE_INSTALL_FAILED。self_hosted、scope 和跨会话包缓存尚不支持。
  • 读取环境:支持租户自建 cloud 环境、配置更新与软归档;内置环境只读。列表支持 limit、page 和 include_archived。limited 网络在沙箱创建时生效;安装失败会终止会话,错误码为 ENVIRONMENT_PACKAGE_INSTALL_FAILED。self_hosted、scope 和跨会话包缓存尚不支持。
  • 列出工具集:返回工具集说明、插件名称与版本,以及每个工具的名称、说明、参数定义、是否只读和默认授权方式。通过 /agent/v1/toolsets 读取此目录;目录不会更改智能体配置。agent_toolset_20260401 包含全部 13 个原生工具;TaskOutput、TaskStop、Monitor、Agent、SendMessage 与其他工具一样可逐个开关及设置权限,它们都依赖 bash。兼容 API 只提供官方 8 个工具。

原生工具与参数以本站各端点说明及 /meta/v1/openapi.yaml 为准;Claude Managed Agents 官方文档描述兼容 API 的官方字段。

错误按 Anthropic 错误格式返回(type / message / request_id),参见错误;额度与响应头参见限流。

POST /agent/v1/environments◐ 部分支持

请求体

  • namestring必填

    Human-readable name for the environment

  • metadataobject可选

    User-provided metadata key-value pairs

  • configobject可选

    Environment configuration

    ▸ 展开子字段(3)
    • typestring必填

      Self-hosted environment selector; unsupported here and rejected with 400. Use a cloud environment instead.

      取值 self_hosted
    • 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),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringEnvironment identifier (e.g., 'env_...')
archived_atnull | stringRFC 3339 timestamp when environment was archived, or null if not archived
configobjectEnvironment configuration (either Anthropic Cloud or self-hosted)
config.networkingobjectNetwork configuration policy.
config.packagesobjectPackage manager configuration.
config.typestringEnvironment type
created_atstringRFC 3339 timestamp when environment was created
descriptionnull | stringUser-provided description for the environment; null when unset
metadataobjectUser-provided metadata key-value pairs
namestringHuman-readable name for the environment
typestringThe type of object (always 'environment')
updated_atstringRFC 3339 timestamp when environment was last updated
scopestringThe visibility scope for this environment. 'organization' means visible to all accounts. 'account' means visible only to the owning account.

先调用「创建环境」,用返回的环境 ID 替换 env_123。

POST /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

    ▸ 展开子字段(3)
    • typestring必填

      Self-hosted environment selector; unsupported here and rejected with 400. Use a cloud environment instead.

      取值 self_hosted
    • 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),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringEnvironment identifier (e.g., 'env_...')
archived_atnull | stringRFC 3339 timestamp when environment was archived, or null if not archived
configobjectEnvironment configuration (either Anthropic Cloud or self-hosted)
config.networkingobjectNetwork configuration policy.
config.packagesobjectPackage manager configuration.
config.typestringEnvironment type
created_atstringRFC 3339 timestamp when environment was created
descriptionnull | stringUser-provided description for the environment; null when unset
metadataobjectUser-provided metadata key-value pairs
namestringHuman-readable name for the environment
typestringThe type of object (always 'environment')
updated_atstringRFC 3339 timestamp when environment was last updated
scopestringThe visibility scope for this environment. 'organization' means visible to all accounts. 'account' means visible only to the owning account.

先调用「创建环境」,用返回的环境 ID 替换 env_123。

POST /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),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringEnvironment identifier (e.g., 'env_...')
archived_atnull | stringRFC 3339 timestamp when environment was archived, or null if not archived
configobjectEnvironment configuration (either Anthropic Cloud or self-hosted)
config.networkingobjectNetwork configuration policy.
config.packagesobjectPackage manager configuration.
config.typestringEnvironment type
created_atstringRFC 3339 timestamp when environment was created
descriptionnull | stringUser-provided description for the environment; null when unset
metadataobjectUser-provided metadata key-value pairs
namestringHuman-readable name for the environment
typestringThe type of object (always 'environment')
updated_atstringRFC 3339 timestamp when environment was last updated
scopestringThe visibility scope for this environment. 'organization' means visible to all accounts. 'account' means visible only to the owning account.

创建电脑

POST /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),参见 错误码

响应

HTTP 201

Computer result

application/json

名称类型说明
typestringAlways `computer`. A computer.
idstringComputer id (cmp_...), the computer_id of computer calls.
namestringDisplay name of the computer, 1 to 255 characters.
sandbox_idstring | nullPublic id of the sandbox that backs the computer, usable with the sandbox API; null while none has been created.
environment_idstring | nullEnvironment recipe the computer was created with; null when none.
statusstringactive computers can be used by new sessions; archived ones keep their files readable but cannot start new sessions.
created_atstringRFC 3339 time at which the computer was created.
updated_atstringRFC 3339 time at which the computer was last modified.
archived_atstring | nullRFC 3339 time at which the computer was archived; null while active.

列出电脑

GET /agent/v1/computers● 支持

请求参数

  • limitinteger可选
    默认 20

    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),参见 错误码

响应

HTTP 200

Computer result

application/json

名称类型说明
dataarray<object>Items of this page, in the order requested by the call.
data[].typestringAlways `computer`. A computer.
data[].idstringComputer id (cmp_...), the computer_id of computer calls.
data[].namestringDisplay name of the computer, 1 to 255 characters.
data[].sandbox_idstring | nullPublic id of the sandbox that backs the computer, usable with the sandbox API; null while none has been created.
data[].environment_idstring | nullEnvironment recipe the computer was created with; null when none.
data[].statusstringactive computers can be used by new sessions; archived ones keep their files readable but cannot start new sessions.
data[].created_atstringRFC 3339 time at which the computer was created.
data[].updated_atstringRFC 3339 time at which the computer was last modified.
data[].archived_atstring | nullRFC 3339 time at which the computer was archived; null while active.
has_morebooleanWhether more items exist beyond this page.
next_pagestring | nullOpaque cursor for the next page: pass it unchanged as page to continue. Null when this is the last page.

读取电脑

先调用「创建计算机」,用返回的计算机 ID 替换 cmp_123。

GET /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),参见 错误码

响应

HTTP 200

Computer result

application/json

名称类型说明
typestringAlways `computer`. A computer.
idstringComputer id (cmp_...), the computer_id of computer calls.
namestringDisplay name of the computer, 1 to 255 characters.
sandbox_idstring | nullPublic id of the sandbox that backs the computer, usable with the sandbox API; null while none has been created.
environment_idstring | nullEnvironment recipe the computer was created with; null when none.
statusstringactive computers can be used by new sessions; archived ones keep their files readable but cannot start new sessions.
created_atstringRFC 3339 time at which the computer was created.
updated_atstringRFC 3339 time at which the computer was last modified.
archived_atstring | nullRFC 3339 time at which the computer was archived; null while active.
implementationstringHow the computer is backed: a virtual file store or a real sandbox.
storage_bytesintegerBytes stored on the computer.
file_countintegerNumber of files stored on the computer.

更新电脑

先调用「创建计算机」,用返回的计算机 ID 替换 cmp_123。

POST /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),参见 错误码

响应

HTTP 200

Computer result

application/json

名称类型说明
typestringAlways `computer`. A computer.
idstringComputer id (cmp_...), the computer_id of computer calls.
namestringDisplay name of the computer, 1 to 255 characters.
sandbox_idstring | nullPublic id of the sandbox that backs the computer, usable with the sandbox API; null while none has been created.
environment_idstring | nullEnvironment recipe the computer was created with; null when none.
statusstringactive computers can be used by new sessions; archived ones keep their files readable but cannot start new sessions.
created_atstringRFC 3339 time at which the computer was created.
updated_atstringRFC 3339 time at which the computer was last modified.
archived_atstring | nullRFC 3339 time at which the computer was archived; null while active.

归档电脑

先调用「创建计算机」,用返回的计算机 ID 替换 cmp_123。

POST /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),参见 错误码

响应

HTTP 200

Computer result

application/json

名称类型说明
typestringAlways `computer`. A computer.
idstringComputer id (cmp_...), the computer_id of computer calls.
namestringDisplay name of the computer, 1 to 255 characters.
sandbox_idstring | nullPublic id of the sandbox that backs the computer, usable with the sandbox API; null while none has been created.
environment_idstring | nullEnvironment recipe the computer was created with; null when none.
statusstringactive computers can be used by new sessions; archived ones keep their files readable but cannot start new sessions.
created_atstringRFC 3339 time at which the computer was created.
updated_atstringRFC 3339 time at which the computer was last modified.
archived_atstring | nullRFC 3339 time at which the computer was archived; null while active.

删除已归档电脑

先调用「创建计算机」,用返回的计算机 ID 替换 cmp_123。

DELETE /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),参见 错误码

响应

HTTP 200

Computer result

application/json

名称类型说明
idstringId of the deleted computer.
typestringAlways `computer_deleted`. Confirms that a computer was deleted.

浏览电脑文件

先调用「创建计算机」,用返回的计算机 ID 替换 cmp_123。

GET /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),参见 错误码

响应

HTTP 200

Computer result

application/json

名称类型说明
dataarray<object>Items of this page, in the order requested by the call.
data[].pathstringAbsolute path of the entry on the computer.
data[].namestringName of the entry or object.
data[].typestringKind of entry: a file, a directory or a symbolic link.
data[].sizeintegerSize in bytes.
data[].mime_typestringMIME type of the file.
data[].read_onlybooleanTrue when the entry cannot be modified through the API.
data[].digeststring | nullContent digest of the file; null when not computed.
data[].updated_atstring | nullRFC 3339 time at which the object was last modified.
has_morebooleanWhether more items exist beyond this page.

读取电脑文件内容

先调用「创建计算机」,用返回的计算机 ID 替换 cmp_123。

GET /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),参见 错误码

响应

HTTP 200

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)

HTTP 206

Single byte range

application/octet-stream

名称类型说明
$string (binary)

连接电脑

先调用「创建计算机」,用返回的计算机 ID 替换 cmp_123。

POST /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),参见 错误码

响应

HTTP 200

Computer result

application/json

名称类型说明
sandbox_idstringPublic id of the sandbox that backs the computer, usable with the sandbox API; null while none has been created.
envd_access_tokenstringAccess token for the sandbox's environment daemon, returned by the connect call; treat it as a secret.
template_idstringSandbox template the computer's sandbox was created from.

上传电脑附件

先调用「创建计算机」,用返回的计算机 ID 替换 cmp_123。

POST /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),参见 错误码

响应

HTTP 201

Computer result

application/json

名称类型说明
pathstringAbsolute path of the entry on the computer.
namestringName of the entry or object.
typestringKind of entry: a file, a directory or a symbolic link.
sizeintegerSize in bytes.
mime_typestringMIME type of the file.
read_onlybooleanTrue when the entry cannot be modified through the API.
digeststring | nullContent digest of the file; null when not computed.
updated_atstring | nullRFC 3339 time at which the object was last modified.

先调用「上传文件」,用返回的文件 ID 替换示例文件 ID。 先调用「创建会话」,用返回的会话 ID 替换示例 ID。

POST /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
  • 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),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringResource id, the resource_id of sessions.resources calls.
created_atstringA timestamp in RFC 3339 format
file_idstringId of the uploaded file; it must exist and belong to your tenant.
mount_pathstringPath inside the machine where the file is mounted; defaults to /mnt/session/uploads/<file_id>, and custom paths are rooted there.
typestringAlways `file`. A file resource: an uploaded file mounted into the session's machine.
updated_atstringA timestamp in RFC 3339 format

先调用「创建会话」,用返回的会话 ID 替换示例 ID。

GET /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),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
dataarray<object>Items of this page, in the order requested by the call.
data[].idstringResource id, the resource_id of sessions.resources calls.
data[].created_atstringA timestamp in RFC 3339 format
data[].mount_pathstring | null | stringPath 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[].typestringAlways `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_atstringA timestamp in RFC 3339 format
data[].urlstringRepository URL.
data[].checkoutnull | objectBranch or commit to check out.
data[].file_idstringId of the uploaded file; it must exist and belong to your tenant.
data[].memory_store_idstringThe memory store ID (memstore_...). Must belong to the caller's organization and workspace.
data[].accessnull | stringAccess mode for an attached memory store.
data[].descriptionstringDescription of the memory store, snapshotted at attach time. Rendered into the agent's system prompt. Empty string when the store has no description.
data[].instructionsnull | stringPer-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars.
data[].namenull | stringDisplay name of the memory store, snapshotted at attach time. Later edits to the store's name do not propagate to this resource.
next_pagestring | nullOpaque cursor for the next page: pass it unchanged as page to continue. Null when this is the last page.

先调用「创建会话」,用返回的会话 ID 替换示例 ID。 先调用「添加会话资源」,用返回的资源 ID 替换 sesrsc_123。

GET /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),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringResource id, the resource_id of sessions.resources calls.
created_atstringA timestamp in RFC 3339 format
mount_pathstring | null | stringPath 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.
typestringAlways `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_atstringA timestamp in RFC 3339 format
urlstringRepository URL.
checkoutnull | objectBranch or commit to check out.
checkout.namestringBranch name to check out.
checkout.typestringAlways `branch`. Check out the named branch. / Always `commit`. Check out the commit with the given SHA.
checkout.shastringFull commit SHA to check out.
file_idstringId of the uploaded file; it must exist and belong to your tenant.
memory_store_idstringThe memory store ID (memstore_...). Must belong to the caller's organization and workspace.
accessnull | stringAccess mode for an attached memory store.
descriptionstringDescription of the memory store, snapshotted at attach time. Rendered into the agent's system prompt. Empty string when the store has no description.
instructionsnull | stringPer-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars.
namenull | stringDisplay 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。

DELETE /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),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringIdentifier of the object, as returned by the API; pass it in the path of follow-up calls on the same resource.
typestringAlways `session_resource_deleted`. Confirms that a resource was detached from the session.

列出智能体

GET /agent/v1/agents● 支持

Claude 官方文档 ↗

请求参数

  • 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),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
dataarray<object>Items of this page, in the order requested by the call.
data[].idstringAgent id (agent_...). Pass it as agent when creating a session and as agent_id in agent calls.
data[].archived_atnull | stringA timestamp in RFC 3339 format
data[].created_atstringA timestamp in RFC 3339 format
data[].descriptionnull | stringFree-text description of what the agent is for; null when none was set.
data[].mcp_serversarray<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[].metadataobjectFree-form string key/value pairs stored with the agent for your own bookkeeping.
data[].modelobjectModel identifier and configuration.
data[].multiagentnull | objectResolved coordinator topology with a concrete agent roster.
data[].namestringDisplay name of the agent, as set on create or update. It is a label, not a unique key.
data[].skillsarray<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[].systemnull | stringSystem prompt given to the model at the start of every session of this agent; null when none was set.
data[].toolsarray<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[].typestringAlways `agent`. An agent definition.
data[].updated_atstringA timestamp in RFC 3339 format
data[].versionnumberThe agent's current version. Starts at 1 and increments when the agent is modified.
data[].computer_idstringPraxis 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_modelstring | nullPraxis 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[].modelsobjectPraxis extension: switchable model ids on /agent/v1 only. The default model must be included. When omitted, only the default model is selectable.
next_pagestring | nullOpaque cursor for the next page: pass it unchanged as page to continue. Null when this is the last page.

POST /agent/v1/agents◐ 部分支持

Claude 官方文档 ↗

请求体

  • namestring必填

    智能体名称,1–255 个字符,工作区内可读。

  • modelstring | object必填

    智能体使用的模型:直接写模型名字符串(如 claude-opus-5),或传对象做附加配置(见子字段)。

    ▸ 展开子字段(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 引用,否则整笔请求被拒。

    ▸ 展开子字段(3)
    • typestring必填

      服务器类型,目前只支持 url。

      取值 url
    • namestring必填

      MCP 服务器在本列表内的唯一名称,1–255 个字符,供 mcp_toolset 配置引用。

    • urlstring必填

      MCP 服务器的端点地址。

  • multiagentobject可选◐ 部分支持

    多智能体协作拓扑:会话主线程作为协调者,从 agents 名单派生会话线程执行工作。

    ▸ 展开子字段(2)
    • agentsarray必填

      协调者可以派生为会话线程的智能体名单,1–20 项;支持 ID 字符串、{type: agent, id, version?} 和最多一个 {type: self}。创建/更新时固定版本。成员须唯一、存在且未归档,不能自身带 multiagent。每个 coordinator 最多一个 advisor,模型须可用且不同于智能体模型;仅主会话可咨询,每次咨询为独立 advisor 线程,建议以 agent.thread_message_received 返回。

    • typestring必填

      拓扑类型,目前只有 coordinator。

      取值 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.

  • ▸ 更多参数(2)
    • subagent_modelstring可选

      /agent/v1 扩展:智能体级子智能体默认模型 ID,随修订固定。省略保持,null 清除。调用 model 优先,其次本字段,再其次名册成员模型或内置类型的父会话模型。/anthropic 不接受或返回此字段。

    • modelsobject可选

      扩展:可切换模型列表,仅 /agent/v1 支持。

      ▸ 展开子字段(1)
      • 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),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringAgent id (agent_...). Pass it as agent when creating a session and as agent_id in agent calls.
archived_atnull | stringA timestamp in RFC 3339 format
created_atstringA timestamp in RFC 3339 format
descriptionnull | stringFree-text description of what the agent is for; null when none was set.
mcp_serversarray<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[].typestringAlways `url`. An MCP server reached over a URL.
mcp_servers[].namestringName of the MCP server; the mcp_toolset entry that refers to it uses the same name in mcp_server_name.
mcp_servers[].urlstringhttp(s) endpoint of the MCP server, at most 2048 characters.
metadataobjectFree-form string key/value pairs stored with the agent for your own bookkeeping.
modelobjectModel identifier and configuration.
model.idstringThe model that will power your agent. See models for additional details and options.
model.effortobjectHow hard Claude works on each turn. Sets `output_config.effort` on every Messages call the session makes.
model.inference_geostringGeographic region for model inference. When unset, requests fall through to the workspace's default_inference_geo.
model.speedstringInference 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.settingsobjectPlatform model settings. Only reasoning is supported; other model controls return 400.
multiagentnull | objectResolved coordinator topology with a concrete agent roster.
multiagent.agentsarray<object>Agents the coordinator may spawn as session threads, each resolved to a specific version.
multiagent.typestringAlways `coordinator`. The agent coordinates the roster in agents and can delegate to its members.
namestringDisplay name of the agent, as set on create or update. It is a label, not a unique key.
skillsarray<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_idstringId of the skill to attach.
skills[].typestringAlways `anthropic`. A skill provided by Anthropic, identified by skill_id. / Always `custom`. A skill created by you, identified by skill_id.
skills[].versionstringVersion of the skill; a string.
systemnull | stringSystem prompt given to the model at the start of every session of this agent; null when none was set.
toolsarray<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[].configsarray<object> | array | nullPer-tool settings that override default_config. Tools that are not listed follow default_config.
tools[].default_configobject | object | nullResolved 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[].typestringAlways `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_namestringName of the MCP server in mcp_servers whose tools this entry exposes.
tools[].descriptionstringWhat the custom tool does and when the model should call it.
tools[].input_schemaobjectJSON Schema for custom tool input parameters.
tools[].namestringName of the custom tool, as the model sees and calls it.
typestringAlways `agent`. An agent definition.
updated_atstringA timestamp in RFC 3339 format
versionnumberThe agent's current version. Starts at 1 and increments when the agent is modified.
computer_idstringPraxis 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_modelstring | nullPraxis 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.
modelsobjectPraxis extension: switchable model ids on /agent/v1 only. The default model must be included. When omitted, only the default model is selectable.
models.allowedarray<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。

GET /agent/v1/agents/{agent_id}● 支持

Claude 官方文档 ↗

请求参数

  • 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),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringAgent id (agent_...). Pass it as agent when creating a session and as agent_id in agent calls.
archived_atnull | stringA timestamp in RFC 3339 format
created_atstringA timestamp in RFC 3339 format
descriptionnull | stringFree-text description of what the agent is for; null when none was set.
mcp_serversarray<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[].typestringAlways `url`. An MCP server reached over a URL.
mcp_servers[].namestringName of the MCP server; the mcp_toolset entry that refers to it uses the same name in mcp_server_name.
mcp_servers[].urlstringhttp(s) endpoint of the MCP server, at most 2048 characters.
metadataobjectFree-form string key/value pairs stored with the agent for your own bookkeeping.
modelobjectModel identifier and configuration.
model.idstringThe model that will power your agent. See models for additional details and options.
model.effortobjectHow hard Claude works on each turn. Sets `output_config.effort` on every Messages call the session makes.
model.inference_geostringGeographic region for model inference. When unset, requests fall through to the workspace's default_inference_geo.
model.speedstringInference 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.settingsobjectPlatform model settings. Only reasoning is supported; other model controls return 400.
multiagentnull | objectResolved coordinator topology with a concrete agent roster.
multiagent.agentsarray<object>Agents the coordinator may spawn as session threads, each resolved to a specific version.
multiagent.typestringAlways `coordinator`. The agent coordinates the roster in agents and can delegate to its members.
namestringDisplay name of the agent, as set on create or update. It is a label, not a unique key.
skillsarray<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_idstringId of the skill to attach.
skills[].typestringAlways `anthropic`. A skill provided by Anthropic, identified by skill_id. / Always `custom`. A skill created by you, identified by skill_id.
skills[].versionstringVersion of the skill; a string.
systemnull | stringSystem prompt given to the model at the start of every session of this agent; null when none was set.
toolsarray<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[].configsarray<object> | array | nullPer-tool settings that override default_config. Tools that are not listed follow default_config.
tools[].default_configobject | object | nullResolved 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[].typestringAlways `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_namestringName of the MCP server in mcp_servers whose tools this entry exposes.
tools[].descriptionstringWhat the custom tool does and when the model should call it.
tools[].input_schemaobjectJSON Schema for custom tool input parameters.
tools[].namestringName of the custom tool, as the model sees and calls it.
typestringAlways `agent`. An agent definition.
updated_atstringA timestamp in RFC 3339 format
versionnumberThe agent's current version. Starts at 1 and increments when the agent is modified.
computer_idstringPraxis 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_modelstring | nullPraxis 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.
modelsobjectPraxis extension: switchable model ids on /agent/v1 only. The default model must be included. When omitted, only the default model is selectable.
models.allowedarray<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。

POST /agent/v1/agents/{agent_id}◐ 部分支持

Claude 官方文档 ↗

请求参数

  • 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),或传对象做附加配置(见子字段)。

    ▸ 展开子字段(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 名单派生会话线程执行工作。

    ▸ 展开子字段(2)
    • agentsarray必填

      协调者可以派生为会话线程的智能体名单,1–20 项;支持 ID 字符串、{type: agent, id, version?} 和最多一个 {type: self}。创建/更新时固定版本。成员须唯一、存在且未归档,不能自身带 multiagent。每个 coordinator 最多一个 advisor,模型须可用且不同于智能体模型;仅主会话可咨询,每次咨询为独立 advisor 线程,建议以 agent.thread_message_received 返回。

    • typestring必填

      拓扑类型,目前只有 coordinator。

      取值 coordinator
  • skillsarray可选

    整体替换的 Skill 列表;省略保持不变,传空数组或 null 清除。

  • ▸ 更多参数(4)
    • 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 支持。

      ▸ 展开子字段(1)
      • 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),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringAgent id (agent_...). Pass it as agent when creating a session and as agent_id in agent calls.
archived_atnull | stringA timestamp in RFC 3339 format
created_atstringA timestamp in RFC 3339 format
descriptionnull | stringFree-text description of what the agent is for; null when none was set.
mcp_serversarray<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[].typestringAlways `url`. An MCP server reached over a URL.
mcp_servers[].namestringName of the MCP server; the mcp_toolset entry that refers to it uses the same name in mcp_server_name.
mcp_servers[].urlstringhttp(s) endpoint of the MCP server, at most 2048 characters.
metadataobjectFree-form string key/value pairs stored with the agent for your own bookkeeping.
modelobjectModel identifier and configuration.
model.idstringThe model that will power your agent. See models for additional details and options.
model.effortobjectHow hard Claude works on each turn. Sets `output_config.effort` on every Messages call the session makes.
model.inference_geostringGeographic region for model inference. When unset, requests fall through to the workspace's default_inference_geo.
model.speedstringInference 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.settingsobjectPlatform model settings. Only reasoning is supported; other model controls return 400.
multiagentnull | objectResolved coordinator topology with a concrete agent roster.
multiagent.agentsarray<object>Agents the coordinator may spawn as session threads, each resolved to a specific version.
multiagent.typestringAlways `coordinator`. The agent coordinates the roster in agents and can delegate to its members.
namestringDisplay name of the agent, as set on create or update. It is a label, not a unique key.
skillsarray<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_idstringId of the skill to attach.
skills[].typestringAlways `anthropic`. A skill provided by Anthropic, identified by skill_id. / Always `custom`. A skill created by you, identified by skill_id.
skills[].versionstringVersion of the skill; a string.
systemnull | stringSystem prompt given to the model at the start of every session of this agent; null when none was set.
toolsarray<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[].configsarray<object> | array | nullPer-tool settings that override default_config. Tools that are not listed follow default_config.
tools[].default_configobject | object | nullResolved 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[].typestringAlways `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_namestringName of the MCP server in mcp_servers whose tools this entry exposes.
tools[].descriptionstringWhat the custom tool does and when the model should call it.
tools[].input_schemaobjectJSON Schema for custom tool input parameters.
tools[].namestringName of the custom tool, as the model sees and calls it.
typestringAlways `agent`. An agent definition.
updated_atstringA timestamp in RFC 3339 format
versionnumberThe agent's current version. Starts at 1 and increments when the agent is modified.
computer_idstringPraxis 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_modelstring | nullPraxis 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.
modelsobjectPraxis extension: switchable model ids on /agent/v1 only. The default model must be included. When omitted, only the default model is selectable.
models.allowedarray<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。

GET /agent/v1/agents/{agent_id}/versions● 支持

Claude 官方文档 ↗

请求参数

  • 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),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
dataarray<object>Items of this page, in the order requested by the call.
data[].idstringAgent id (agent_...). Pass it as agent when creating a session and as agent_id in agent calls.
data[].archived_atnull | stringA timestamp in RFC 3339 format
data[].created_atstringA timestamp in RFC 3339 format
data[].descriptionnull | stringFree-text description of what the agent is for; null when none was set.
data[].mcp_serversarray<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[].metadataobjectFree-form string key/value pairs stored with the agent for your own bookkeeping.
data[].modelobjectModel identifier and configuration.
data[].multiagentnull | objectResolved coordinator topology with a concrete agent roster.
data[].namestringDisplay name of the agent, as set on create or update. It is a label, not a unique key.
data[].skillsarray<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[].systemnull | stringSystem prompt given to the model at the start of every session of this agent; null when none was set.
data[].toolsarray<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[].typestringAlways `agent`. An agent definition.
data[].updated_atstringA timestamp in RFC 3339 format
data[].versionnumberThe agent's current version. Starts at 1 and increments when the agent is modified.
data[].computer_idstringPraxis 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_modelstring | nullPraxis 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[].modelsobjectPraxis extension: switchable model ids on /agent/v1 only. The default model must be included. When omitted, only the default model is selectable.
next_pagestring | nullOpaque cursor for the next page: pass it unchanged as page to continue. Null when this is the last page.

归档智能体

先调用「创建智能体」,用返回的智能体 ID 替换示例 ID。

POST /agent/v1/agents/{agent_id}/archive● 支持

Claude 官方文档 ↗

请求参数

  • 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),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringAgent id (agent_...). Pass it as agent when creating a session and as agent_id in agent calls.
archived_atnull | stringA timestamp in RFC 3339 format
created_atstringA timestamp in RFC 3339 format
descriptionnull | stringFree-text description of what the agent is for; null when none was set.
mcp_serversarray<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[].typestringAlways `url`. An MCP server reached over a URL.
mcp_servers[].namestringName of the MCP server; the mcp_toolset entry that refers to it uses the same name in mcp_server_name.
mcp_servers[].urlstringhttp(s) endpoint of the MCP server, at most 2048 characters.
metadataobjectFree-form string key/value pairs stored with the agent for your own bookkeeping.
modelobjectModel identifier and configuration.
model.idstringThe model that will power your agent. See models for additional details and options.
model.effortobjectHow hard Claude works on each turn. Sets `output_config.effort` on every Messages call the session makes.
model.inference_geostringGeographic region for model inference. When unset, requests fall through to the workspace's default_inference_geo.
model.speedstringInference 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.settingsobjectPlatform model settings. Only reasoning is supported; other model controls return 400.
multiagentnull | objectResolved coordinator topology with a concrete agent roster.
multiagent.agentsarray<object>Agents the coordinator may spawn as session threads, each resolved to a specific version.
multiagent.typestringAlways `coordinator`. The agent coordinates the roster in agents and can delegate to its members.
namestringDisplay name of the agent, as set on create or update. It is a label, not a unique key.
skillsarray<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_idstringId of the skill to attach.
skills[].typestringAlways `anthropic`. A skill provided by Anthropic, identified by skill_id. / Always `custom`. A skill created by you, identified by skill_id.
skills[].versionstringVersion of the skill; a string.
systemnull | stringSystem prompt given to the model at the start of every session of this agent; null when none was set.
toolsarray<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[].configsarray<object> | array | nullPer-tool settings that override default_config. Tools that are not listed follow default_config.
tools[].default_configobject | object | nullResolved 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[].typestringAlways `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_namestringName of the MCP server in mcp_servers whose tools this entry exposes.
tools[].descriptionstringWhat the custom tool does and when the model should call it.
tools[].input_schemaobjectJSON Schema for custom tool input parameters.
tools[].namestringName of the custom tool, as the model sees and calls it.
typestringAlways `agent`. An agent definition.
updated_atstringA timestamp in RFC 3339 format
versionnumberThe agent's current version. Starts at 1 and increments when the agent is modified.
computer_idstringPraxis 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_modelstring | nullPraxis 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.
modelsobjectPraxis extension: switchable model ids on /agent/v1 only. The default model must be included. When omitted, only the default model is selectable.
models.allowedarray<string>Model ids a session may select with its model field; it must be non-empty and must contain the agent's default model.

GET /agent/v1/sessions◐ 部分支持

Claude 官方文档 ↗

请求参数

  • 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 从新到旧(默认)。

  • ▸ 更多参数(3)
    • 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),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
dataarray<object>Items of this page, in the order requested by the call.
data[].idstringSession id (sesn_...). Pass it as session_id in every session call.
data[].agentobjectResolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time.
data[].archived_atnull | stringA timestamp in RFC 3339 format
data[].budgetnull | objectA hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`.
data[].created_atstringA timestamp in RFC 3339 format
data[].environment_idstringId 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[].metadataobjectFree-form string key/value pairs stored with the session, changed through sessions.update patch semantics.
data[].outcome_evaluationsarray<object>Per-outcome evaluation state. One entry per `define_outcome` event sent to the session.
data[].resourcesarray<object>Resources attached to the session, at most 500; each is a file reference mounted into the session's machine.
data[].statsobjectTiming statistics for a session.
data[].statusstringSessionStatus 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[].titlenull | stringTitle of the session, set on create or through sessions.update; null when none was set.
data[].typestringAlways `session`. A session, one conversation of an agent on a machine.
data[].updated_atstringA timestamp in RFC 3339 format
data[].usageobjectCumulative token usage for a session across all turns.
data[].vault_idsarray<string>Vault IDs attached to the session at creation. Empty when no vaults were supplied.
data[].deployment_idnull | stringDeployment ID when the session was created from a deployment reference. Null otherwise.
data[].cwdstringNormalized session working directory; defaults to /home/user/workspace. Forks inherit this directory.
data[].computer_idstringPraxis 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[].modelobjectPraxis extension: the currently selected session model.
data[].thinkingobject | nullPraxis 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_fromobject | nullPraxis extension: source of a forked session; null for other sessions. Available only on /agent/v1.
next_pagestring | nullOpaque cursor for the next page: pass it unchanged as page to continue. Null when this is the last page.

先调用「创建智能体」,用返回的智能体 ID 替换示例 ID。

POST /agent/v1/sessions◐ 部分支持

Claude 官方文档 ↗

请求体

  • modelstring可选

    智能体使用的模型:直接写模型名字符串(如 claude-opus-5),或传对象做附加配置(见子字段)。

  • agentstring | object必填

    会话要运行的智能体:直接写智能体 ID 字符串(固定用最新版本),或传对象指定 id 与 version(见子字段)。

    ▸ 展开子字段(8)
    • idstring必填

      会话要运行的智能体 ID。

    • typestring必填

      引用类型,目前只有 agent。

      取值 agent_with_overrides
    • versionnumber可选

      固定使用的智能体版本;省略用最新版本。

    • mcp_serversarray可选

      替换本会话的 MCP 服务器列表:传入的数组整体生效;传空数组清除,省略沿用智能体的配置。

    • modelstring | object可选

      替换本会话的模型:模型名字符串(如 claude-opus-5)或配置对象;省略沿用智能体自身的模型。

    • skillsarray可选

      替换本会话的 Skill 列表;传空数组清除,省略沿用智能体的配置。

    • systemstring可选

      替换本会话的系统提示词,最长 100,000 字符;传 null 清除,省略沿用智能体的。

    • toolsarray可选

      替换本会话的工具配置;传空数组清除,省略沿用智能体的配置。

  • environment_idstring可选

    会话运行所在的环境 ID,决定容器的基础环境。

  • titlestring可选

    会话标题,便于在控制台辨认。

  • metadataobject可选

    会话的自定义元数据键值对。

  • budgetobject可选

    会话的预算上限设置。

    ▸ 展开子字段(2)
    • max_list_costobject必填

      预算内列表类调用的花费上限。

    • typestring必填

      预算类型,目前只有 max_list_cost。

      取值 limit
  • initial_eventsarray可选

    创建时按顺序发给会话的初始事件,支持 user.message 与 user.define_outcome,一次最多 50 条。

  • resourcesarray可选

    要挂载进会话容器的资源(如代码仓库、文件)。

  • vault_idsarray可选

    保险库 ID 列表:会话里智能体可以使用这些已存凭据。

  • cwdstring可选
    默认 "/home/user/workspace"

    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.

  • ▸ 更多参数(3)
    • 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可选
      默认 "UTC"

      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.

      ▸ 展开子字段(1)
      • 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.

        取值 lowmediumhighxhighnone

返回

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),参见 错误码

响应

HTTP 201

Successful response

application/json

名称类型说明
idstringSession id (sesn_...). Pass it as session_id in every session call.
agentobjectResolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time.
agent.idstringAgent id (agent_...). Pass it as agent when creating a session and as agent_id in agent calls.
agent.descriptionnull | stringFree-text description of what the agent is for; null when none was set.
agent.mcp_serversarray<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.modelobjectModel identifier and configuration.
agent.multiagentnull | objectResolved coordinator topology with full agent definitions for each roster member.
agent.namestringDisplay name of the agent, as set on create or update. It is a label, not a unique key.
agent.skillsarray<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.systemnull | stringSystem prompt given to the model at the start of every session of this agent; null when none was set.
agent.toolsarray<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.typestringAlways `agent`. An agent definition.
agent.versionnumberThe agent's current version. Starts at 1 and increments each time the agent is modified.
archived_atnull | stringA timestamp in RFC 3339 format
budgetnull | objectA hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`.
budget.max_list_costobjectA monetary amount in a specific currency.
budget.typestringAlways `limit`. A spending limit.
created_atstringA timestamp in RFC 3339 format
environment_idstringId 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.
metadataobjectFree-form string key/value pairs stored with the session, changed through sessions.update patch semantics.
outcome_evaluationsarray<object>Per-outcome evaluation state. One entry per `define_outcome` event sent to the session.
outcome_evaluations[].completed_atnull | stringA timestamp in RFC 3339 format
outcome_evaluations[].descriptionstringWhat the agent should produce.
outcome_evaluations[].explanationnull | stringGrader'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[].iterationnumber0-indexed revision cycle the outcome is currently on.
outcome_evaluations[].outcome_idstringServer-generated outc_ ID for this outcome.
outcome_evaluations[].resultstringCurrent 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[].typestringAlways `outcome_evaluation`. Record of one outcome evaluation.
resourcesarray<object>Resources attached to the session, at most 500; each is a file reference mounted into the session's machine.
resources[].idstringResource id, the resource_id of sessions.resources calls.
resources[].created_atstringA timestamp in RFC 3339 format
resources[].mount_pathstring | null | stringPath 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[].typestringAlways `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_atstringA timestamp in RFC 3339 format
resources[].urlstringRepository URL.
resources[].checkoutnull | objectBranch or commit to check out.
resources[].file_idstringId of the uploaded file; it must exist and belong to your tenant.
resources[].memory_store_idstringThe memory store ID (memstore_...). Must belong to the caller's organization and workspace.
resources[].accessnull | stringAccess mode for an attached memory store.
resources[].descriptionstringDescription of the memory store, snapshotted at attach time. Rendered into the agent's system prompt. Empty string when the store has no description.
resources[].instructionsnull | stringPer-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars.
resources[].namenull | stringDisplay name of the memory store, snapshotted at attach time. Later edits to the store's name do not propagate to this resource.
statsobjectTiming statistics for a session.
stats.active_secondsnumberCumulative time in seconds the session spent in `running` status. Excludes idle time.
stats.duration_secondsnumberElapsed time since session creation in seconds. For terminated sessions, frozen at the final update.
statusstringSessionStatus 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.
titlenull | stringTitle of the session, set on create or through sessions.update; null when none was set.
typestringAlways `session`. A session, one conversation of an agent on a machine.
updated_atstringA timestamp in RFC 3339 format
usageobjectCumulative token usage for a session across all turns.
usage.active_secondsnumberCumulative 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_creationobjectPrompt-cache creation token usage broken down by cache lifetime.
usage.cache_read_input_tokensnumberTotal tokens read from prompt cache.
usage.input_tokensnumberTotal input tokens consumed across all turns.
usage.list_costnull | objectA monetary amount in a specific currency.
usage.output_tokensnumberTotal output tokens generated across all turns.
usage.server_tool_usenull | objectCumulative count of server-executed tool invocations, broken down by tool.
vault_idsarray<string>Vault IDs attached to the session at creation. Empty when no vaults were supplied.
deployment_idnull | stringDeployment ID when the session was created from a deployment reference. Null otherwise.
cwdstringNormalized session working directory; defaults to /home/user/workspace. Forks inherit this directory.
computer_idstringPraxis 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.
modelobjectPraxis extension: the currently selected session model.
model.idstringIdentifier of the object, as returned by the API; pass it in the path of follow-up calls on the same resource.
model.thinkingobject | nullSupported thinking controls, or null when capability is unknown or unavailable. efforts lists selectable strengths; can_disable permits none; default_effort is nullable.
thinkingobject | nullPraxis 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.effortstringThinking 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_fromobject | nullPraxis extension: source of a forked session; null for other sessions. Available only on /agent/v1.
forked_from.session_idstringId of the parent session this session was forked from; it is left unchanged by the fork.
forked_from.message_idstringmessage_id of the agent message in the parent session up to which the conversation was copied.

读取会话

先调用「创建会话」,用返回的会话 ID 替换示例 ID。

GET /agent/v1/sessions/{session_id}● 支持

Claude 官方文档 ↗

请求参数

  • 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),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringSession id (sesn_...). Pass it as session_id in every session call.
agentobjectResolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time.
agent.idstringAgent id (agent_...). Pass it as agent when creating a session and as agent_id in agent calls.
agent.descriptionnull | stringFree-text description of what the agent is for; null when none was set.
agent.mcp_serversarray<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.modelobjectModel identifier and configuration.
agent.multiagentnull | objectResolved coordinator topology with full agent definitions for each roster member.
agent.namestringDisplay name of the agent, as set on create or update. It is a label, not a unique key.
agent.skillsarray<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.systemnull | stringSystem prompt given to the model at the start of every session of this agent; null when none was set.
agent.toolsarray<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.typestringAlways `agent`. An agent definition.
agent.versionnumberThe agent's current version. Starts at 1 and increments each time the agent is modified.
archived_atnull | stringA timestamp in RFC 3339 format
budgetnull | objectA hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`.
budget.max_list_costobjectA monetary amount in a specific currency.
budget.typestringAlways `limit`. A spending limit.
created_atstringA timestamp in RFC 3339 format
environment_idstringId 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.
metadataobjectFree-form string key/value pairs stored with the session, changed through sessions.update patch semantics.
outcome_evaluationsarray<object>Per-outcome evaluation state. One entry per `define_outcome` event sent to the session.
outcome_evaluations[].completed_atnull | stringA timestamp in RFC 3339 format
outcome_evaluations[].descriptionstringWhat the agent should produce.
outcome_evaluations[].explanationnull | stringGrader'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[].iterationnumber0-indexed revision cycle the outcome is currently on.
outcome_evaluations[].outcome_idstringServer-generated outc_ ID for this outcome.
outcome_evaluations[].resultstringCurrent 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[].typestringAlways `outcome_evaluation`. Record of one outcome evaluation.
resourcesarray<object>Resources attached to the session, at most 500; each is a file reference mounted into the session's machine.
resources[].idstringResource id, the resource_id of sessions.resources calls.
resources[].created_atstringA timestamp in RFC 3339 format
resources[].mount_pathstring | null | stringPath 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[].typestringAlways `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_atstringA timestamp in RFC 3339 format
resources[].urlstringRepository URL.
resources[].checkoutnull | objectBranch or commit to check out.
resources[].file_idstringId of the uploaded file; it must exist and belong to your tenant.
resources[].memory_store_idstringThe memory store ID (memstore_...). Must belong to the caller's organization and workspace.
resources[].accessnull | stringAccess mode for an attached memory store.
resources[].descriptionstringDescription of the memory store, snapshotted at attach time. Rendered into the agent's system prompt. Empty string when the store has no description.
resources[].instructionsnull | stringPer-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars.
resources[].namenull | stringDisplay name of the memory store, snapshotted at attach time. Later edits to the store's name do not propagate to this resource.
statsobjectTiming statistics for a session.
stats.active_secondsnumberCumulative time in seconds the session spent in `running` status. Excludes idle time.
stats.duration_secondsnumberElapsed time since session creation in seconds. For terminated sessions, frozen at the final update.
statusstringSessionStatus 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.
titlenull | stringTitle of the session, set on create or through sessions.update; null when none was set.
typestringAlways `session`. A session, one conversation of an agent on a machine.
updated_atstringA timestamp in RFC 3339 format
usageobjectCumulative token usage for a session across all turns.
usage.active_secondsnumberCumulative 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_creationobjectPrompt-cache creation token usage broken down by cache lifetime.
usage.cache_read_input_tokensnumberTotal tokens read from prompt cache.
usage.input_tokensnumberTotal input tokens consumed across all turns.
usage.list_costnull | objectA monetary amount in a specific currency.
usage.output_tokensnumberTotal output tokens generated across all turns.
usage.server_tool_usenull | objectCumulative count of server-executed tool invocations, broken down by tool.
vault_idsarray<string>Vault IDs attached to the session at creation. Empty when no vaults were supplied.
deployment_idnull | stringDeployment ID when the session was created from a deployment reference. Null otherwise.
cwdstringNormalized session working directory; defaults to /home/user/workspace. Forks inherit this directory.
computer_idstringPraxis 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.
modelobjectPraxis extension: the currently selected session model.
model.idstringIdentifier of the object, as returned by the API; pass it in the path of follow-up calls on the same resource.
model.thinkingobject | nullSupported thinking controls, or null when capability is unknown or unavailable. efforts lists selectable strengths; can_disable permits none; default_effort is nullable.
thinkingobject | nullPraxis 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.effortstringThinking 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_fromobject | nullPraxis extension: source of a forked session; null for other sessions. Available only on /agent/v1.
forked_from.session_idstringId of the parent session this session was forked from; it is left unchanged by the fork.
forked_from.message_idstringmessage_id of the agent message in the parent session up to which the conversation was copied.

分支会话(扩展)

POST /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),参见 错误码

响应

HTTP 201

Forked session (same shape as session retrieval)

application/json

名称类型说明
idstringSession id (sesn_...). Pass it as session_id in every session call.
agentobjectResolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time.
agent.idstringAgent id (agent_...). Pass it as agent when creating a session and as agent_id in agent calls.
agent.descriptionnull | stringFree-text description of what the agent is for; null when none was set.
agent.mcp_serversarray<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.modelobjectModel identifier and configuration.
agent.multiagentnull | objectResolved coordinator topology with full agent definitions for each roster member.
agent.namestringDisplay name of the agent, as set on create or update. It is a label, not a unique key.
agent.skillsarray<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.systemnull | stringSystem prompt given to the model at the start of every session of this agent; null when none was set.
agent.toolsarray<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.typestringAlways `agent`. An agent definition.
agent.versionnumberThe agent's current version. Starts at 1 and increments each time the agent is modified.
archived_atnull | stringA timestamp in RFC 3339 format
budgetnull | objectA hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`.
budget.max_list_costobjectA monetary amount in a specific currency.
budget.typestringAlways `limit`. A spending limit.
created_atstringA timestamp in RFC 3339 format
environment_idstringId 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.
metadataobjectFree-form string key/value pairs stored with the session, changed through sessions.update patch semantics.
outcome_evaluationsarray<object>Per-outcome evaluation state. One entry per `define_outcome` event sent to the session.
outcome_evaluations[].completed_atnull | stringA timestamp in RFC 3339 format
outcome_evaluations[].descriptionstringWhat the agent should produce.
outcome_evaluations[].explanationnull | stringGrader'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[].iterationnumber0-indexed revision cycle the outcome is currently on.
outcome_evaluations[].outcome_idstringServer-generated outc_ ID for this outcome.
outcome_evaluations[].resultstringCurrent 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[].typestringAlways `outcome_evaluation`. Record of one outcome evaluation.
resourcesarray<object>Resources attached to the session, at most 500; each is a file reference mounted into the session's machine.
resources[].idstringResource id, the resource_id of sessions.resources calls.
resources[].created_atstringA timestamp in RFC 3339 format
resources[].mount_pathstring | null | stringPath 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[].typestringAlways `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_atstringA timestamp in RFC 3339 format
resources[].urlstringRepository URL.
resources[].checkoutnull | objectBranch or commit to check out.
resources[].file_idstringId of the uploaded file; it must exist and belong to your tenant.
resources[].memory_store_idstringThe memory store ID (memstore_...). Must belong to the caller's organization and workspace.
resources[].accessnull | stringAccess mode for an attached memory store.
resources[].descriptionstringDescription of the memory store, snapshotted at attach time. Rendered into the agent's system prompt. Empty string when the store has no description.
resources[].instructionsnull | stringPer-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars.
resources[].namenull | stringDisplay name of the memory store, snapshotted at attach time. Later edits to the store's name do not propagate to this resource.
statsobjectTiming statistics for a session.
stats.active_secondsnumberCumulative time in seconds the session spent in `running` status. Excludes idle time.
stats.duration_secondsnumberElapsed time since session creation in seconds. For terminated sessions, frozen at the final update.
statusstringSessionStatus 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.
titlenull | stringTitle of the session, set on create or through sessions.update; null when none was set.
typestringAlways `session`. A session, one conversation of an agent on a machine.
updated_atstringA timestamp in RFC 3339 format
usageobjectCumulative token usage for a session across all turns.
usage.active_secondsnumberCumulative 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_creationobjectPrompt-cache creation token usage broken down by cache lifetime.
usage.cache_read_input_tokensnumberTotal tokens read from prompt cache.
usage.input_tokensnumberTotal input tokens consumed across all turns.
usage.list_costnull | objectA monetary amount in a specific currency.
usage.output_tokensnumberTotal output tokens generated across all turns.
usage.server_tool_usenull | objectCumulative count of server-executed tool invocations, broken down by tool.
vault_idsarray<string>Vault IDs attached to the session at creation. Empty when no vaults were supplied.
deployment_idnull | stringDeployment ID when the session was created from a deployment reference. Null otherwise.
cwdstringNormalized session working directory; defaults to /home/user/workspace. Forks inherit this directory.
computer_idstringPraxis 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.
modelobjectPraxis extension: the currently selected session model.
model.idstringIdentifier of the object, as returned by the API; pass it in the path of follow-up calls on the same resource.
model.thinkingobject | nullSupported thinking controls, or null when capability is unknown or unavailable. efforts lists selectable strengths; can_disable permits none; default_effort is nullable.
thinkingobject | nullPraxis 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.effortstringThinking 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_fromobject | nullPraxis extension: source of a forked session; null for other sessions. Available only on /agent/v1.
forked_from.session_idstringId of the parent session this session was forked from; it is left unchanged by the fork.
forked_from.message_idstringmessage_id of the agent message in the parent session up to which the conversation was copied.

读取会话上下文(扩展)

GET /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),参见 错误码

响应

HTTP 200

Current model and latest context measurement

application/json

名称类型说明
typestringAlways `session_context`. Snapshot of a session's context window usage.
session_idstringSession whose context this snapshot describes.
modelobjectModel of the session and its context window facts.
model.idstringIdentifier of the object, as returned by the API; pass it in the path of follow-up calls on the same resource.
model.display_namestringHuman-readable name of the model.
model.thinkingobject | nullThinking capability of the model: supported efforts, whether thinking can be disabled, and the default. Null when the capability is unknown.
total_tokensnumber | nullTokens currently occupying the context window; null before the first measurement.
total_tokens_sourcestring | nullWhether total_tokens is the provider-reported input usage (actual) or a local estimate (estimated); null before the first measurement.
max_tokensnumber | nullContext window of the model in tokens; null when the model does not state one.
max_input_tokensnumber | nullMaximum input tokens the model accepts per request; null when not stated.
percentagenumberShare of the context window in use, as a whole-number percent; 0 when the window or usage is unknown.
auto_compact_thresholdnumber | nullToken count at which automatic compaction starts; null when the window is unknown.
is_auto_compact_enabledbooleanWhether automatic compaction is enabled for this session.
clear_tool_results_atnumberToken count at which old tool results are cleared from the context.
detailstringLevel of detail of the snapshot.
categoriesarray<object>Context usage by category; each row has a stable key and a kind.
categories[].keystringPraxis 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[].namestringDisplay name of the category.
categories[].tokensnumberTokens used by the category.
categories[].kindstringHow the category counts against the window.
mcp_toolsarray<object>Tokens spent on the tool definitions of each MCP server.
mcp_tools[].namestringName of the MCP tool.
mcp_tools[].server_namestringName of the MCP server that provides the tool.
mcp_tools[].tokensnumberTokens used by the tool definition.
plugin_blocksarray<object>Tokens spent on context blocks injected by each mod.
plugin_blocks[].namestringName of the mod that injected the block.
plugin_blocks[].tokensnumberTokens used by the block.
message_breakdownobjectTokens in the conversation messages, split by role and tool traffic.
message_breakdown.user_message_tokensnumberTokens of user messages.
message_breakdown.assistant_message_tokensnumberTokens of assistant text messages.
message_breakdown.tool_call_tokensnumberTokens of tool-call arguments.
message_breakdown.tool_result_tokensnumberTokens of tool results.
message_breakdown.reasoning_tokensnumberTokens of reasoning content.
message_breakdown.tool_calls_by_typearray<object>Tool-call and tool-result tokens grouped by tool name.
compaction_summaryobject | nullTokens held by the latest compaction summary; null when the session was never compacted.
compaction_summary.tokensnumberTokens of the compaction summary.
excluded_itemsobjectItems removed from the context for content safety, kept for audit only and not counted as usage.
excluded_items.countnumberNumber of excluded items.
excluded_items.tokensnumberTokens of the excluded items.
measured_atstring | nullRFC 3339 time of the measurement; null before the first measurement.

列出后台任务(扩展)

GET /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),参见 错误码

响应

HTTP 200

Session background tasks

application/json

名称类型说明
dataarray<object>Items of this page, in the order requested by the call.
data[].idstringIdentifier of the object, as returned by the API; pass it in the path of follow-up calls on the same resource.
data[].kindstringKind of background task: bash for a command started with run_in_background, monitor for a Monitor watch.
data[].titlestringShort human-readable title of the task or object.
data[].thread_idstring | nullExecution thread the task belongs to; null for the primary thread.
data[].statusstringCurrent lifecycle state.
data[].started_atstringRFC 3339 time at which the task started.
data[].ended_atstring | nullRFC 3339 time at which the task ended; null while it is running.
data[].cancellablebooleanWhether the task can still be stopped.
data[].notified_atstring | nullRFC 3339 time of the latest run that the task's notification started; null while no notification has been delivered.
data[].trigger_countinteger | nullFor a monitor task, how many times its matches woke the session; null for other kinds or before the first notification.

读取后台任务输出(扩展)

GET /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可选
    默认 0

    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可选
    默认 65536

    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),参见 错误码

响应

HTTP 200

Background task output byte page

application/json

名称类型说明
textstringText of the block.
next_offsetintegerByte offset to pass as offset to continue reading the output.
eofbooleanTrue when the output has ended and no more bytes will follow.
unavailablebooleanTrue when the output could not be read; text is then empty.

停止后台任务(扩展)

POST /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),参见 错误码

响应

HTTP 200

Current task after stop request

application/json

名称类型说明
idstringIdentifier of the object, as returned by the API; pass it in the path of follow-up calls on the same resource.
kindstringKind of background task: bash for a command started with run_in_background, monitor for a Monitor watch.
titlestringShort human-readable title of the task or object.
thread_idstring | nullExecution thread the task belongs to; null for the primary thread.
statusstringCurrent lifecycle state.
started_atstringRFC 3339 time at which the task started.
ended_atstring | nullRFC 3339 time at which the task ended; null while it is running.
cancellablebooleanWhether the task can still be stopped.
notified_atstring | nullRFC 3339 time of the latest run that the task's notification started; null while no notification has been delivered.
trigger_countinteger | nullFor a monitor task, how many times its matches woke the session; null for other kinds or before the first notification.

压缩会话(扩展)

先调用「创建会话」,用返回的会话 ID 替换示例 ID。

POST /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),参见 错误码

响应

HTTP 200

Skipped, succeeded or failed compaction

application/json

名称类型说明
typestringAlways `session_compaction`. Result of a compaction request.
idstringCompaction operation id; pass it as operation_id to sessions.compact.retrieve.
statusstringState of the compaction operation: queued and running are in progress, skipped means nothing needed compaction, succeeded and failed are final.
reasonstringWhy the compaction was skipped or failed; absent otherwise.

HTTP 202

Queued or running compaction

application/json

名称类型说明
typestringAlways `session_compaction`. Result of a compaction request.
idstringCompaction operation id; pass it as operation_id to sessions.compact.retrieve.
statusstringState of the compaction operation: queued and running are in progress, skipped means nothing needed compaction, succeeded and failed are final.
reasonstringWhy the compaction was skipped or failed; absent otherwise.

读取压缩操作(扩展)

先调用「创建会话」,用返回的会话 ID 替换示例 ID。

GET /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),参见 错误码

响应

HTTP 200

Compaction operation

application/json

名称类型说明
typestringAlways `session_compaction`. Result of a compaction request.
idstringCompaction operation id; pass it as operation_id to sessions.compact.retrieve.
statusstringState of the compaction operation: queued and running are in progress, skipped means nothing needed compaction, succeeded and failed are final.
reasonstringWhy the compaction was skipped or failed; absent otherwise.

列出压缩历史(扩展)

先调用「创建会话」,用返回的会话 ID 替换示例 ID。

GET /agent/v1/sessions/{session_id}/compactions● 支持

请求参数

  • session_idstring必填

    path: Session id (sesn_...), as returned by sessions.create or sessions.list. The same id is also accepted as the session_id query parameter on resource and thread calls, where it must equal the path value.

返回

200

仅在 /agent/v1 提供。返回 { data: [...] }。每项包含 type、id、event_id、trigger、status、model、compacted_message_count、input_tokens_before、input_tokens_after、summary、error、created_at,字段按服务记录原样返回。不存在或不可见的托管会话返回 404 not_found_error。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Compaction history

application/json

名称类型说明
dataarray<object>Items of this page, in the order requested by the call.
data[].typestringAlways `context_compaction`. Record of one past compaction.
data[].idstringCompaction record id.
data[].event_idstring | nullId of the agent.thread_context_compacted event emitted for this compaction; null when none.
data[].triggerstringWhat started the compaction.
data[].statusstringFinal outcome of the compaction.
data[].modelstringModel that wrote the summary.
data[].compacted_message_countnumberNumber of messages replaced by the summary.
data[].input_tokens_beforenumberContext tokens before the compaction.
data[].input_tokens_afternumber | nullContext tokens after the compaction; null when not measured.
data[].summarystring | nullSummary text that replaced the messages; null when the compaction failed.
data[].errorstring | nullFailure reason; null when the compaction succeeded.
data[].created_atstringRFC 3339 time at which the compaction was recorded.

列出事件

先调用「创建会话」,用返回的会话 ID 替换示例 ID。

GET /agent/v1/sessions/{session_id}/events● 支持

Claude 官方文档 ↗

请求参数

  • 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),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
dataarray<object>Items of this page, in the order requested by the call.
data[].idstringUnique 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[].contentarray<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[].typestringAlways `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_atnull | 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 | stringA 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_idstringUI 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_idnull | string | string | string | string | string | null | string | stringIf 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[].resultstringUserToolConfirmationResult 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_idstringThe 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_messagenull | stringOptional message providing context for a 'deny' decision. Only allowed when result is 'deny'.
data[].custom_tool_use_idstringThe 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_errornull | booleanWhether the tool execution resulted in an error. / Whether the model request resulted in an error. / Whether the tool execution resulted in an error.
data[].inputobjectInput parameters for the tool call.
data[].namestringName of the custom tool being called. / Name of the MCP tool being used. / Name of the agent tool being used.
data[].mcp_server_namestringName of the MCP server providing the tool.
data[].evaluated_permissionstringAgentEvaluatedPermission enum
data[].evaluationobjectNames the resolved permission_policy that produced evaluated_permission, and under auto carries the judgement. Open union: clients must tolerate unknown variants.
data[]._metaobjectPraxis 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[].sourcestringPraxis 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_idstringPraxis 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_idstringThe id of the `agent.mcp_tool_use` event this result corresponds to.
data[].structured_contentanyPraxis 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_idstringPublic `sthr_` ID of the thread that sent the message.
data[].from_agent_namenull | stringName of the callable agent this message came from. Absent when received from the primary agent.
data[].to_session_thread_idstringPublic `sthr_` ID of the thread the message was sent to.
data[].to_agent_namenull | stringName of the callable agent this message was sent to. Absent when sent to the primary agent.
data[].errorobjectDescription of the error and what the client should do next.
data[].stop_reasonobjectWhy the session stopped running, with the variant data needed to continue.
data[].agent_namestringName 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[].iterationnumber0-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_idstringThe `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[].explanationstringHuman-readable explanation of the verdict. For `needs_revision`, describes which criteria failed and why.
data[].outcome_evaluation_start_idstringThe id of the corresponding `span.outcome_evaluation_start` event.
data[].usageobjectToken usage for a single model request. / Point-in-time snapshot of a session's cumulative usage.
data[].model_request_start_idstringThe id of the corresponding `span.model_request_start` event.
data[].model_usageobjectToken usage for a single model request.
data[].descriptionstringWhat the agent should produce. Copied from the input event.
data[].max_iterationsnull | numberEvaluate-then-revise cycles before giving up. Default 3, max 20.
data[].rubricobjectRubric for grading the quality of an outcome.
data[].agentnull | objectResolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time.
data[].budgetnull | objectA hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`.
data[].metadataobjectThe 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[].titlenull | stringThe session's new title. Present only when the update changed it.
data[].modelobjectPraxis extension: the changed session model, present only on /agent/v1 session.updated events. Model-only updates are omitted on /anthropic.
data[].forked_from_session_idstringId of the parent session this session was forked from.
data[].forked_from_message_idstringmessage_id of the agent message in the parent session up to which the conversation was copied.
data[].actionstringWhat changed in the goal.
data[].goalobject | nullThe goal as the change left it, or null when the session has no goal.
data[].previous_goalobject | nullThe goal before the change, or null when there was none.
data[].statusstringWhere the check stands. Read `verification.passed` on the closing event to know whether the goal counts as done.
data[].goal_idstringThe goal this check belongs to.
data[].goal_iterationintegerWhich check of this goal, matching `iteration` on the goal.
data[].verification_idstringIdentifier shared by every event of one check.
data[].anchor_message_idstring | nullThe assistant message the check follows, or null.
data[].verificationobjectThe verdict; absent on `started`.
data[].event_idstringId of the event this event refers to.
data[].answersobjectThe user's answer to each question, keyed by the question text; empty when the questions were dismissed.
data[].annotationsobjectPer-question notes, keyed by the question text.
next_pagestring | nullOpaque cursor for the next page: pass it unchanged as page to continue. Null when this is the last page.

先调用「创建会话」,用返回的会话 ID 替换示例 ID。

POST /agent/v1/sessions/{session_id}/events◐ 部分支持

Claude 官方文档 ↗

请求参数

  • 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),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
dataarray<object>Sent events
data[].idstringUnique 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[].contentarray<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[].typestringAlways `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_atnull | string | string | null | string | null | string | string | stringA 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_idnull | stringIf 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[].resultstringUserToolConfirmationResult enum / Always `allow`.
data[].tool_use_idstringThe 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_messagenull | stringOptional message providing context for a 'deny' decision. Only allowed when result is 'deny'.
data[].custom_tool_use_idstringThe 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_errornull | booleanWhether the tool execution resulted in an error.
data[].descriptionstringWhat the agent should produce. Copied from the input event.
data[].max_iterationsnull | numberEvaluate-then-revise cycles before giving up. Default 3, max 20.
data[].outcome_idstringServer-generated `outc_` ID for this outcome. Referenced by `span.outcome_evaluation_*` events and the session's `outcome_evaluations` list.
data[].rubricobjectRubric for grading the quality of an outcome.
data[].event_idstringId of the event this event refers to.
data[].answersobjectThe user's answer to each question, keyed by the question text; empty when the questions were dismissed.
data[].annotationsobjectPer-question notes, keyed by the question text.

先调用「创建会话」,用返回的会话 ID 替换示例 ID。

GET /agent/v1/sessions/{session_id}/events/stream◐ 部分支持

Claude 官方文档 ↗

请求参数

  • 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),参见 错误码

响应

HTTP 200

Server-sent events

text/event-stream — chunk / 事件对象

名称类型说明
idstringIdentifier of the object, as returned by the API; pass it in the path of follow-up calls on the same resource.
eventstringServer-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.
dataobjectDecoded 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.idstringUnique 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.contentarray<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.typestringAlways `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_atnull | 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 | stringA 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_idstringUI 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_idnull | 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 | stringIf 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_reasonobjectWhy the session stopped running, with the variant data needed to continue.
data.removedarray<object>Content removed from the model's context by this reset.
data.categorystringText of the block.
data.stoppedbooleanTrue when the run was stopped instead of retried after the reset.
data.agentnull | objectResolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time.
data.budgetnull | objectA hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`.
data.metadataobjectThe 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.titlenull | stringThe session's new title. Present only when the update changed it.
data.modelobjectPraxis extension: the changed session model, present only on /agent/v1 session.updated events. Model-only updates are omitted on /anthropic.
data.errorobjectDescription 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.usageobjectPoint-in-time snapshot of a session's cumulative usage.
data.is_errornull | booleanWhether 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_idstringThe id of the corresponding `span.model_request_start` event.
data.model_usageobjectToken usage for a single model request.
data.inputobjectInput parameters for the tool call.
data.namestringName 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_permissionstringAgentEvaluatedPermission enum
data.evaluationobjectNames the resolved permission_policy that produced evaluated_permission, and under auto carries the judgement. Open union: clients must tolerate unknown variants.
data.tool_use_idstringThe 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_namestringName of the MCP server providing the tool.
data._metaobjectPraxis 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.sourcestringPraxis 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_idstringPraxis 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_idstringThe id of the `agent.mcp_tool_use` event this result corresponds to.
data.structured_contentanyPraxis 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.resultstringAlways `allow`.
data.answersobjectThe user's answer to each question, keyed by the question text; empty when the questions were dismissed.
data.annotationsobjectPer-question notes, keyed by the question text.
data.agent_namestringName 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_idstringPublic `sthr_` ID of the thread the message was sent to.
data.to_agent_namenull | stringName of the callable agent this message was sent to. Absent when sent to the primary agent.
data.from_session_thread_idstringPublic `sthr_` ID of the thread that sent the message.
data.from_agent_namenull | stringName of the callable agent this message came from. Absent when received from the primary agent.
data.event_idstringText 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.sourcesarray<object>Background work that woke the session with this notification.
data.forked_from_session_idstringId of the parent session this session was forked from.
data.forked_from_message_idstringmessage_id of the agent message in the parent session up to which the conversation was copied.
data.actionstringWhat changed in the goal.
data.goalobject | nullThe goal as the change left it, or null when the session has no goal.
data.previous_goalobject | nullThe goal before the change, or null when there was none.
data.statusstringWhere the check stands. Read `verification.passed` on the closing event to know whether the goal counts as done.
data.goal_idstringThe goal this check belongs to.
data.goal_iterationintegerWhich check of this goal, matching `iteration` on the goal.
data.verification_idstringIdentifier shared by every event of one check.
data.anchor_message_idstring | nullThe assistant message the check follows, or null.
data.verificationobjectThe verdict; absent on `started`.
data.eventobjectEvent name or event payload.
data.deltaobjectIncremental fragment of the event being produced.

用 WebSocket 接收

同一地址也可以用 wss:// 建立只读 WebSocket,每个事件一帧,适合服务端长连接。连接、帧格式、关闭码与限额见用 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":"好"}]}}
字段说明
typesession.events.ready(就绪,只出现一次)或 session.event(一个事件)
event仅 session.event 帧有;结构与事件列表返回的单个事件相同

同一个事件可能送达不止一次。例如一条 user.message 会先以 processed_at: null(已接纳、待处理)出现,被处理后再以带时间的形式出现一次。请按 event.id 去重,以最后一次为准。

关闭码

关闭码含义你该做什么
1000服务端正常结束订阅需要继续接收就重新连接
1008客户端向连接发送了消息这条连接只读;不要发送任何帧
1011服务端内部中断重新连接,并用事件列表回填
1013暂时超出限额(见下)重新连接,并用事件列表回填

限额

  • 一条连接累计最多推送约 512 KB 的事件,超出后以 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。

POST /agent/v1/sessions/{session_id}◐ 部分支持

Claude 官方文档 ↗

请求参数

  • 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(见子字段)。

    ▸ 展开子字段(2)
    • 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`.

    ▸ 展开子字段(2)
    • max_list_costobject必填

      预算内列表类调用的花费上限。

    • typestring必填

      预算类型,目前只有 max_list_cost。

      取值 limit
  • 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.

    ▸ 展开子字段(1)
    • 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.

      取值 lowmediumhighxhighnone

返回

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),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringSession id (sesn_...). Pass it as session_id in every session call.
agentobjectResolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time.
agent.idstringAgent id (agent_...). Pass it as agent when creating a session and as agent_id in agent calls.
agent.descriptionnull | stringFree-text description of what the agent is for; null when none was set.
agent.mcp_serversarray<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.modelobjectModel identifier and configuration.
agent.multiagentnull | objectResolved coordinator topology with full agent definitions for each roster member.
agent.namestringDisplay name of the agent, as set on create or update. It is a label, not a unique key.
agent.skillsarray<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.systemnull | stringSystem prompt given to the model at the start of every session of this agent; null when none was set.
agent.toolsarray<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.typestringAlways `agent`. An agent definition.
agent.versionnumberThe agent's current version. Starts at 1 and increments each time the agent is modified.
archived_atnull | stringA timestamp in RFC 3339 format
budgetnull | objectA hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`.
budget.max_list_costobjectA monetary amount in a specific currency.
budget.typestringAlways `limit`. A spending limit.
created_atstringA timestamp in RFC 3339 format
environment_idstringId 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.
metadataobjectFree-form string key/value pairs stored with the session, changed through sessions.update patch semantics.
outcome_evaluationsarray<object>Per-outcome evaluation state. One entry per `define_outcome` event sent to the session.
outcome_evaluations[].completed_atnull | stringA timestamp in RFC 3339 format
outcome_evaluations[].descriptionstringWhat the agent should produce.
outcome_evaluations[].explanationnull | stringGrader'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[].iterationnumber0-indexed revision cycle the outcome is currently on.
outcome_evaluations[].outcome_idstringServer-generated outc_ ID for this outcome.
outcome_evaluations[].resultstringCurrent 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[].typestringAlways `outcome_evaluation`. Record of one outcome evaluation.
resourcesarray<object>Resources attached to the session, at most 500; each is a file reference mounted into the session's machine.
resources[].idstringResource id, the resource_id of sessions.resources calls.
resources[].created_atstringA timestamp in RFC 3339 format
resources[].mount_pathstring | null | stringPath 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[].typestringAlways `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_atstringA timestamp in RFC 3339 format
resources[].urlstringRepository URL.
resources[].checkoutnull | objectBranch or commit to check out.
resources[].file_idstringId of the uploaded file; it must exist and belong to your tenant.
resources[].memory_store_idstringThe memory store ID (memstore_...). Must belong to the caller's organization and workspace.
resources[].accessnull | stringAccess mode for an attached memory store.
resources[].descriptionstringDescription of the memory store, snapshotted at attach time. Rendered into the agent's system prompt. Empty string when the store has no description.
resources[].instructionsnull | stringPer-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars.
resources[].namenull | stringDisplay name of the memory store, snapshotted at attach time. Later edits to the store's name do not propagate to this resource.
statsobjectTiming statistics for a session.
stats.active_secondsnumberCumulative time in seconds the session spent in `running` status. Excludes idle time.
stats.duration_secondsnumberElapsed time since session creation in seconds. For terminated sessions, frozen at the final update.
statusstringSessionStatus 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.
titlenull | stringTitle of the session, set on create or through sessions.update; null when none was set.
typestringAlways `session`. A session, one conversation of an agent on a machine.
updated_atstringA timestamp in RFC 3339 format
usageobjectCumulative token usage for a session across all turns.
usage.active_secondsnumberCumulative 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_creationobjectPrompt-cache creation token usage broken down by cache lifetime.
usage.cache_read_input_tokensnumberTotal tokens read from prompt cache.
usage.input_tokensnumberTotal input tokens consumed across all turns.
usage.list_costnull | objectA monetary amount in a specific currency.
usage.output_tokensnumberTotal output tokens generated across all turns.
usage.server_tool_usenull | objectCumulative count of server-executed tool invocations, broken down by tool.
vault_idsarray<string>Vault IDs attached to the session at creation. Empty when no vaults were supplied.
deployment_idnull | stringDeployment ID when the session was created from a deployment reference. Null otherwise.
cwdstringNormalized session working directory; defaults to /home/user/workspace. Forks inherit this directory.
computer_idstringPraxis 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.
modelobjectPraxis extension: the currently selected session model.
model.idstringIdentifier of the object, as returned by the API; pass it in the path of follow-up calls on the same resource.
model.thinkingobject | nullSupported thinking controls, or null when capability is unknown or unavailable. efforts lists selectable strengths; can_disable permits none; default_effort is nullable.
thinkingobject | nullPraxis 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.effortstringThinking 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_fromobject | nullPraxis extension: source of a forked session; null for other sessions. Available only on /agent/v1.
forked_from.session_idstringId of the parent session this session was forked from; it is left unchanged by the fork.
forked_from.message_idstringmessage_id of the agent message in the parent session up to which the conversation was copied.

归档会话

先调用「创建会话」,用返回的会话 ID 替换示例 ID。

POST /agent/v1/sessions/{session_id}/archive● 支持

Claude 官方文档 ↗

请求参数

  • 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),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringSession id (sesn_...). Pass it as session_id in every session call.
agentobjectResolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time.
agent.idstringAgent id (agent_...). Pass it as agent when creating a session and as agent_id in agent calls.
agent.descriptionnull | stringFree-text description of what the agent is for; null when none was set.
agent.mcp_serversarray<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.modelobjectModel identifier and configuration.
agent.multiagentnull | objectResolved coordinator topology with full agent definitions for each roster member.
agent.namestringDisplay name of the agent, as set on create or update. It is a label, not a unique key.
agent.skillsarray<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.systemnull | stringSystem prompt given to the model at the start of every session of this agent; null when none was set.
agent.toolsarray<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.typestringAlways `agent`. An agent definition.
agent.versionnumberThe agent's current version. Starts at 1 and increments each time the agent is modified.
archived_atnull | stringA timestamp in RFC 3339 format
budgetnull | objectA hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`.
budget.max_list_costobjectA monetary amount in a specific currency.
budget.typestringAlways `limit`. A spending limit.
created_atstringA timestamp in RFC 3339 format
environment_idstringId 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.
metadataobjectFree-form string key/value pairs stored with the session, changed through sessions.update patch semantics.
outcome_evaluationsarray<object>Per-outcome evaluation state. One entry per `define_outcome` event sent to the session.
outcome_evaluations[].completed_atnull | stringA timestamp in RFC 3339 format
outcome_evaluations[].descriptionstringWhat the agent should produce.
outcome_evaluations[].explanationnull | stringGrader'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[].iterationnumber0-indexed revision cycle the outcome is currently on.
outcome_evaluations[].outcome_idstringServer-generated outc_ ID for this outcome.
outcome_evaluations[].resultstringCurrent 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[].typestringAlways `outcome_evaluation`. Record of one outcome evaluation.
resourcesarray<object>Resources attached to the session, at most 500; each is a file reference mounted into the session's machine.
resources[].idstringResource id, the resource_id of sessions.resources calls.
resources[].created_atstringA timestamp in RFC 3339 format
resources[].mount_pathstring | null | stringPath 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[].typestringAlways `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_atstringA timestamp in RFC 3339 format
resources[].urlstringRepository URL.
resources[].checkoutnull | objectBranch or commit to check out.
resources[].file_idstringId of the uploaded file; it must exist and belong to your tenant.
resources[].memory_store_idstringThe memory store ID (memstore_...). Must belong to the caller's organization and workspace.
resources[].accessnull | stringAccess mode for an attached memory store.
resources[].descriptionstringDescription of the memory store, snapshotted at attach time. Rendered into the agent's system prompt. Empty string when the store has no description.
resources[].instructionsnull | stringPer-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars.
resources[].namenull | stringDisplay name of the memory store, snapshotted at attach time. Later edits to the store's name do not propagate to this resource.
statsobjectTiming statistics for a session.
stats.active_secondsnumberCumulative time in seconds the session spent in `running` status. Excludes idle time.
stats.duration_secondsnumberElapsed time since session creation in seconds. For terminated sessions, frozen at the final update.
statusstringSessionStatus 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.
titlenull | stringTitle of the session, set on create or through sessions.update; null when none was set.
typestringAlways `session`. A session, one conversation of an agent on a machine.
updated_atstringA timestamp in RFC 3339 format
usageobjectCumulative token usage for a session across all turns.
usage.active_secondsnumberCumulative 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_creationobjectPrompt-cache creation token usage broken down by cache lifetime.
usage.cache_read_input_tokensnumberTotal tokens read from prompt cache.
usage.input_tokensnumberTotal input tokens consumed across all turns.
usage.list_costnull | objectA monetary amount in a specific currency.
usage.output_tokensnumberTotal output tokens generated across all turns.
usage.server_tool_usenull | objectCumulative count of server-executed tool invocations, broken down by tool.
vault_idsarray<string>Vault IDs attached to the session at creation. Empty when no vaults were supplied.
deployment_idnull | stringDeployment ID when the session was created from a deployment reference. Null otherwise.
cwdstringNormalized session working directory; defaults to /home/user/workspace. Forks inherit this directory.
computer_idstringPraxis 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.
modelobjectPraxis extension: the currently selected session model.
model.idstringIdentifier of the object, as returned by the API; pass it in the path of follow-up calls on the same resource.
model.thinkingobject | nullSupported thinking controls, or null when capability is unknown or unavailable. efforts lists selectable strengths; can_disable permits none; default_effort is nullable.
thinkingobject | nullPraxis 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.effortstringThinking 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_fromobject | nullPraxis extension: source of a forked session; null for other sessions. Available only on /agent/v1.
forked_from.session_idstringId of the parent session this session was forked from; it is left unchanged by the fork.
forked_from.message_idstringmessage_id of the agent message in the parent session up to which the conversation was copied.

先调用「创建会话」,用返回的会话 ID 替换示例 ID。

GET /agent/v1/sessions/{session_id}/threads◐ 部分支持

Claude 官方文档 ↗

请求参数

  • 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),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
dataarray<object>Items of this page, in the order requested by the call.
data[].idstringUnique identifier for this thread.
data[].agentobjectThe resolved agent a `session_thread` runs.
data[].archived_atnull | stringA timestamp in RFC 3339 format
data[].created_atstringA timestamp in RFC 3339 format
data[].parent_thread_idnull | stringParent thread that spawned this thread. Null for the primary thread.
data[].session_idstringThe session this thread belongs to.
data[].statsnull | objectTiming statistics for a session thread.
data[].statusstringSessionThreadStatus enum
data[].typestringAlways `session_thread`. An execution thread of a session.
data[].updated_atstringA timestamp in RFC 3339 format
data[].usagenull | objectCumulative token usage for a session thread across all turns.
next_pagestring | nullOpaque cursor for the next page: pass it unchanged as page to continue. Null when this is the last page.

先调用「创建会话」,用返回的会话 ID 替换示例 ID。

GET /agent/v1/sessions/{session_id}/threads/{thread_id}◐ 部分支持

Claude 官方文档 ↗

请求参数

  • 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),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringUnique identifier for this thread.
agentobjectThe resolved agent a `session_thread` runs.
agent.modelstring | objectThe advisor model id. / Model identifier and configuration.
agent.typestringAlways `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.idstringAgent id (agent_...). Pass it as agent when creating a session and as agent_id in agent calls.
agent.descriptionnull | stringFree-text description of what the agent is for; null when none was set.
agent.mcp_serversarray<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.namestringDisplay name of the agent, as set on create or update. It is a label, not a unique key.
agent.skillsarray<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.systemnull | stringSystem prompt given to the model at the start of every session of this agent; null when none was set.
agent.toolsarray<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.versionnumberThe agent's current version. Starts at 1 and increments each time the agent is modified.
archived_atnull | stringA timestamp in RFC 3339 format
created_atstringA timestamp in RFC 3339 format
parent_thread_idnull | stringParent thread that spawned this thread. Null for the primary thread.
session_idstringThe session this thread belongs to.
statsnull | objectTiming statistics for a session thread.
stats.active_secondsnumberCumulative time in seconds the thread spent actively running. Excludes idle time.
stats.duration_secondsnumberElapsed time since thread creation in seconds. For archived threads, frozen at the final update.
stats.startup_secondsnumberTime in seconds for the thread to begin running. Zero for child threads, which start immediately.
statusstringSessionThreadStatus enum
typestringAlways `session_thread`. An execution thread of a session.
updated_atstringA timestamp in RFC 3339 format
usagenull | objectCumulative token usage for a session thread across all turns.
usage.active_secondsnumberCumulative 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_creationobjectPrompt-cache creation token usage broken down by cache lifetime.
usage.cache_read_input_tokensnumberTotal tokens read from prompt cache.
usage.input_tokensnumberTotal input tokens consumed across all turns.
usage.list_costnull | objectA monetary amount in a specific currency.
usage.output_tokensnumberTotal output tokens generated across all turns.
usage.server_tool_usenull | objectCumulative count of server-executed tool invocations, broken down by tool.

先调用「创建会话」,用返回的会话 ID 替换示例 ID。

GET /agent/v1/sessions/{session_id}/threads/{thread_id}/events◐ 部分支持

Claude 官方文档 ↗

请求参数

  • 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),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
dataarray<object>Items of this page, in the order requested by the call.
data[].idstringUnique 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[].contentarray<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[].typestringAlways `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_atnull | 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 | stringA 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_idstringUI 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_idnull | string | string | string | string | string | null | string | stringIf 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[].resultstringUserToolConfirmationResult 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_idstringThe 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_messagenull | stringOptional message providing context for a 'deny' decision. Only allowed when result is 'deny'.
data[].custom_tool_use_idstringThe 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_errornull | booleanWhether the tool execution resulted in an error. / Whether the model request resulted in an error. / Whether the tool execution resulted in an error.
data[].inputobjectInput parameters for the tool call.
data[].namestringName of the custom tool being called. / Name of the MCP tool being used. / Name of the agent tool being used.
data[].mcp_server_namestringName of the MCP server providing the tool.
data[].evaluated_permissionstringAgentEvaluatedPermission enum
data[].evaluationobjectNames 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_idstringPraxis 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[]._metaobjectPraxis 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[].sourcestringPraxis 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_idstringThe id of the `agent.mcp_tool_use` event this result corresponds to.
data[].structured_contentanyPraxis 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_idstringPublic `sthr_` ID of the thread that sent the message.
data[].from_agent_namenull | stringName of the callable agent this message came from. Absent when received from the primary agent.
data[].to_session_thread_idstringPublic `sthr_` ID of the thread the message was sent to.
data[].to_agent_namenull | stringName of the callable agent this message was sent to. Absent when sent to the primary agent.
data[].errorobjectDescription of the error and what the client should do next.
data[].stop_reasonobjectWhy the session stopped running, with the variant data needed to continue.
data[].agent_namestringName 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[].iterationnumber0-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_idstringThe `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[].explanationstringHuman-readable explanation of the verdict. For `needs_revision`, describes which criteria failed and why.
data[].outcome_evaluation_start_idstringThe id of the corresponding `span.outcome_evaluation_start` event.
data[].usageobjectToken usage for a single model request. / Point-in-time snapshot of a session's cumulative usage.
data[].model_request_start_idstringThe id of the corresponding `span.model_request_start` event.
data[].model_usageobjectToken usage for a single model request.
data[].descriptionstringWhat the agent should produce. Copied from the input event.
data[].max_iterationsnull | numberEvaluate-then-revise cycles before giving up. Default 3, max 20.
data[].rubricobjectRubric for grading the quality of an outcome.
data[].agentnull | objectResolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time.
data[].budgetnull | objectA hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`.
data[].metadataobjectThe 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[].titlenull | stringThe session's new title. Present only when the update changed it.
data[].modelobjectPraxis extension: the changed session model, present only on /agent/v1 session.updated events. Model-only updates are omitted on /anthropic.
data[].forked_from_session_idstringId of the parent session this session was forked from.
data[].forked_from_message_idstringmessage_id of the agent message in the parent session up to which the conversation was copied.
data[].actionstringWhat changed in the goal.
data[].goalobject | nullThe goal as the change left it, or null when the session has no goal.
data[].previous_goalobject | nullThe goal before the change, or null when there was none.
data[].statusstringWhere the check stands. Read `verification.passed` on the closing event to know whether the goal counts as done.
data[].goal_idstringThe goal this check belongs to.
data[].goal_iterationintegerWhich check of this goal, matching `iteration` on the goal.
data[].verification_idstringIdentifier shared by every event of one check.
data[].anchor_message_idstring | nullThe assistant message the check follows, or null.
data[].verificationobjectThe verdict; absent on `started`.
data[].event_idstringId of the event this event refers to.
next_pagestring | nullOpaque cursor for the next page: pass it unchanged as page to continue. Null when this is the last page.

先调用「创建会话」,用返回的会话 ID 替换示例 ID。

GET /agent/v1/sessions/{session_id}/threads/{thread_id}/stream◐ 部分支持

Claude 官方文档 ↗

请求参数

  • 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),参见 错误码

响应

HTTP 200

Server-sent events

text/event-stream — chunk / 事件对象

名称类型说明
idstringIdentifier of the object, as returned by the API; pass it in the path of follow-up calls on the same resource.
eventstringServer-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.
dataobjectDecoded 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.idstringUnique 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.contentarray<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.typestringAlways `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_atnull | 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 | stringA 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_idstringUI 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_idnull | 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 | stringIf 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_reasonobjectWhy the session stopped running, with the variant data needed to continue.
data.removedarray<object>Content removed from the model's context by this reset.
data.categorystringText of the block.
data.stoppedbooleanTrue when the run was stopped instead of retried after the reset.
data.agentnull | objectResolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time.
data.budgetnull | objectA hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`.
data.metadataobjectThe 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.titlenull | stringThe session's new title. Present only when the update changed it.
data.modelobjectPraxis extension: the changed session model, present only on /agent/v1 session.updated events. Model-only updates are omitted on /anthropic.
data.errorobjectDescription 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.usageobjectPoint-in-time snapshot of a session's cumulative usage.
data.is_errornull | booleanWhether 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_idstringThe id of the corresponding `span.model_request_start` event.
data.model_usageobjectToken usage for a single model request.
data.inputobjectInput parameters for the tool call.
data.namestringName 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_permissionstringAgentEvaluatedPermission enum
data.evaluationobjectNames the resolved permission_policy that produced evaluated_permission, and under auto carries the judgement. Open union: clients must tolerate unknown variants.
data.tool_use_idstringThe 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_namestringName of the MCP server providing the tool.
data._metaobjectPraxis 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.sourcestringPraxis 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_idstringPraxis 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_idstringThe id of the `agent.mcp_tool_use` event this result corresponds to.
data.structured_contentanyPraxis 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.resultstringAlways `allow`.
data.answersobjectThe user's answer to each question, keyed by the question text; empty when the questions were dismissed.
data.annotationsobjectPer-question notes, keyed by the question text.
data.agent_namestringName 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_idstringPublic `sthr_` ID of the thread the message was sent to.
data.to_agent_namenull | stringName of the callable agent this message was sent to. Absent when sent to the primary agent.
data.from_session_thread_idstringPublic `sthr_` ID of the thread that sent the message.
data.from_agent_namenull | stringName of the callable agent this message came from. Absent when received from the primary agent.
data.event_idstringText 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.sourcesarray<object>Background work that woke the session with this notification.
data.forked_from_session_idstringId of the parent session this session was forked from.
data.forked_from_message_idstringmessage_id of the agent message in the parent session up to which the conversation was copied.
data.actionstringWhat changed in the goal.
data.goalobject | nullThe goal as the change left it, or null when the session has no goal.
data.previous_goalobject | nullThe goal before the change, or null when there was none.
data.statusstringWhere the check stands. Read `verification.passed` on the closing event to know whether the goal counts as done.
data.goal_idstringThe goal this check belongs to.
data.goal_iterationintegerWhich check of this goal, matching `iteration` on the goal.
data.verification_idstringIdentifier shared by every event of one check.
data.anchor_message_idstring | nullThe assistant message the check follows, or null.
data.verificationobjectThe verdict; absent on `started`.
data.eventobjectEvent name or event payload.
data.deltaobjectIncremental fragment of the event being produced.

先调用「创建会话」,用返回的会话 ID 替换示例 ID。

POST /agent/v1/sessions/{session_id}/threads/{thread_id}/archive◐ 部分支持

Claude 官方文档 ↗

请求参数

  • session_idstring必填

    path: Session id (sesn_...), as returned by sessions.create or sessions.list. The same id is also accepted as the session_id query parameter on resource and thread calls, where it must equal the path value.

  • thread_idstring必填

    path: Execution thread id (sthr_...), as listed by sessions.threads.list; the primary thread id equals the session's own thread. Unknown or foreign ids return 404.

  • session_idstring必填

    query: Session id (sesn_...), as returned by sessions.create or sessions.list. The same id is also accepted as the session_id query parameter on resource and thread calls, where it must equal the path value.

返回

200

主线程沿用会话归档动作;子线程仅归档对应子会话,不归档父会话或其他子线程。子线程归档后 status 为 terminated,带 archived_at;历史事件仍可读。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringUnique identifier for this thread.
agentobjectThe resolved agent a `session_thread` runs.
agent.modelstring | objectThe advisor model id. / Model identifier and configuration.
agent.typestringAlways `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.idstringAgent id (agent_...). Pass it as agent when creating a session and as agent_id in agent calls.
agent.descriptionnull | stringFree-text description of what the agent is for; null when none was set.
agent.mcp_serversarray<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.namestringDisplay name of the agent, as set on create or update. It is a label, not a unique key.
agent.skillsarray<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.systemnull | stringSystem prompt given to the model at the start of every session of this agent; null when none was set.
agent.toolsarray<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.versionnumberThe agent's current version. Starts at 1 and increments each time the agent is modified.
archived_atnull | stringA timestamp in RFC 3339 format
created_atstringA timestamp in RFC 3339 format
parent_thread_idnull | stringParent thread that spawned this thread. Null for the primary thread.
session_idstringThe session this thread belongs to.
statsnull | objectTiming statistics for a session thread.
stats.active_secondsnumberCumulative time in seconds the thread spent actively running. Excludes idle time.
stats.duration_secondsnumberElapsed time since thread creation in seconds. For archived threads, frozen at the final update.
stats.startup_secondsnumberTime in seconds for the thread to begin running. Zero for child threads, which start immediately.
statusstringSessionThreadStatus enum
typestringAlways `session_thread`. An execution thread of a session.
updated_atstringA timestamp in RFC 3339 format
usagenull | objectCumulative token usage for a session thread across all turns.
usage.active_secondsnumberCumulative 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_creationobjectPrompt-cache creation token usage broken down by cache lifetime.
usage.cache_read_input_tokensnumberTotal tokens read from prompt cache.
usage.input_tokensnumberTotal input tokens consumed across all turns.
usage.list_costnull | objectA monetary amount in a specific currency.
usage.output_tokensnumberTotal output tokens generated across all turns.
usage.server_tool_usenull | objectCumulative count of server-executed tool invocations, broken down by tool.

GET /agent/v1/environments◐ 部分支持

Claude 官方文档 ↗

请求参数

  • 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),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
dataarray<object>Items of this page, in the order requested by the call.
data[].idstringEnvironment identifier (e.g., 'env_...')
data[].archived_atnull | stringRFC 3339 timestamp when environment was archived, or null if not archived
data[].configobjectEnvironment configuration (either Anthropic Cloud or self-hosted)
data[].created_atstringRFC 3339 timestamp when environment was created
data[].descriptionnull | stringUser-provided description for the environment; null when unset
data[].metadataobjectUser-provided metadata key-value pairs
data[].namestringHuman-readable name for the environment
data[].typestringThe type of object (always 'environment')
data[].updated_atstringRFC 3339 timestamp when environment was last updated
data[].scopestringThe visibility scope for this environment. 'organization' means visible to all accounts. 'account' means visible only to the owning account.
next_pagestring | nullOpaque cursor for the next page: pass it unchanged as page to continue. Null when this is the last page.

GET /agent/v1/environments/{environment_id}◐ 部分支持

Claude 官方文档 ↗

请求参数

  • 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),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringEnvironment identifier (e.g., 'env_...')
archived_atnull | stringRFC 3339 timestamp when environment was archived, or null if not archived
configobjectEnvironment configuration (either Anthropic Cloud or self-hosted)
config.networkingobjectNetwork configuration policy.
config.packagesobjectPackage manager configuration.
config.typestringEnvironment type
created_atstringRFC 3339 timestamp when environment was created
descriptionnull | stringUser-provided description for the environment; null when unset
metadataobjectUser-provided metadata key-value pairs
namestringHuman-readable name for the environment
typestringThe type of object (always 'environment')
updated_atstringRFC 3339 timestamp when environment was last updated
scopestringThe visibility scope for this environment. 'organization' means visible to all accounts. 'account' means visible only to the owning account.

列出工具集

GET /agent/v1/toolsets● 支持

返回

200

返回工具集说明、插件名称与版本,以及每个工具的名称、说明、参数定义、是否只读和默认授权方式。通过 /agent/v1/toolsets 读取此目录;目录不会更改智能体配置。agent_toolset_20260401 包含全部 13 个原生工具;TaskOutput、TaskStop、Monitor、Agent、SendMessage 与其他工具一样可逐个开关及设置权限,它们都依赖 bash。兼容 API 只提供官方 8 个工具。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Available toolsets

application/json

名称类型说明
dataarray<object>Items of this page, in the order requested by the call.
data[].typestringToolset type id as used in an agent's tools entry, for example agent_toolset_20260401.
data[].pluginobjectUnit that registers the toolset, with its name and version.
data[].descriptionstringFree-text description; null when none was set.
data[].environmentstringEnvironment in which the toolset's tools run, for example node22.
data[].toolsarray<object>Tools offered to the model.
next_pagenullOpaque cursor for the next page: pass it unchanged as page to continue. Null when this is the last page.