跳转到内容
EN

更新智能体

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

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

Claude 官方文档 ↗

请求参数

  • agent_idstring必填

    path: 按智能体 ID 过滤结果。

  • namestring可选

    新的显示名称,1–256 个字符;只是标签,不要求唯一。省略保持不变。

  • modelstring | object可选

    智能体使用的模型:从 Praxis 模型目录(praxis.model.models.list)取得 ID 字符串,或传 model_config 对象。与 Anthropic 不同,不在目录中的 Claude 模型 ID 会被拒绝。

    展开子字段 (4)
    • idstring必填

      模型 ID,取自 Praxis 模型目录(praxis.model.models.list)。

    • effortstring | object可选

      每次推理的思考力度:可传级别字符串(如 high)或 {type: high} 对象。创建时省略取该模型的默认值;更新时省略保持不变。

    • inference_geostring可选

      模型推理的地理区域;不传沿用工作区默认。model 是整体替换字段,更新时省略子字段即清除该项。

    • speedstring可选

      推理速度模式:fast 出字显著更快但按溢价计费;并非所有模型都支持,不支持的组合在创建时被拒。

  • systemstring可选

    系统提示词;省略保持不变,传空串或 null 清除。

  • descriptionstring可选

    用途说明;省略保持不变,传空串或 null 清除。

  • mcp_serversarray可选

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

  • metadataobject可选

    元数据补丁:键设为字符串即写入,设为 null 即删除;省略该字段保持不变。存储上限 16 个键、每个值 512 字符。

  • 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可选◐ 部分支持

    整体替换的自定义技能列表,形状同创建;省略保持不变,传空数组或 null 清除。

  • toolsarray可选

    整体替换的工具配置;省略保持不变,传 [] 清除全部工具;传 null 返回 400。

  • 更多参数 (1)
    • versionnumber可选

      智能体当前版本号,用于并发保护:必须与最近一次创建/读取返回的版本一致,否则返回冲突。

返回

200

version 可用于乐观并发控制,版本冲突返回 409;无变化的更新不增加版本。支持 custom 工具定义,限制与创建一致;省略 tools 保留,传 [] 清空全部工具声明,tools 为 null 返回 400。MCP 尚不支持。skills 以 [{type:"custom",skill_id,version?}] 挂载已上传的技能,只支持 custom(type 为 anthropic 返回 400);最多 20 个,skill_id 不得重复,技能及固定的版本须存在于本组织且未删除。省略 version 或传 "latest" 表示创建会话时该技能的最新版本;之后上传的新版本不影响已运行的会话。更新时省略 skills 保留,传数组整体替换,传 null 清空。会话带机器时,每个技能在会话启动时安装到 /home/user/.praxis/skills/<name>/;机器上已有同名技能时不覆盖,会话收到一条提示。无机器的会话不安装。 兼容 API 的响应总会填 version:固定的版本号或 "latest"。 multiagent 接受 null 或 coordinator 名册,1–20 项:智能体 ID、{type:"agent",id,version?} 或最多一个 {type:"self"}。创建/更新时固定版本:省略 version 时固定为名册成员保存当时的生效版本,只传字符串 ID 会被接受并改写为对象形式;成员去重且须存在、未归档、不能自身带 multiagent。兼容 API 只提供 bash、edit、glob、grep、read、write、web_search、web_fetch 这 8 个官方工具;configs 不接受其他工具名,经此入口创建的会话不提供后台任务、Monitor 或子智能体。完整原生工具请使用 /agent/v1。 智能体在 /agent/v1 上存有未应用的版本时,本接口返回 409(conflict_error),请先在 /agent/v1 应用该版本;本接口看不到的原生工具(如 codemode)在 tools 更新中原样保留,只能在 /agent/v1 移除。mcp_servers[].headers 的值只写不读:响应显示 "[redacted]",回传 "[redacted]" 表示保留已存的值。每个 coordinator 最多一个 advisor,模型须可用且不同于智能体模型;仅主会话可咨询,每次咨询为独立 advisor 线程,建议以 agent.thread_message_received 返回。

错误按 Claude Managed Agents 格式返回,参见 错误码

请求示例

curl
# 先调用「创建智能体」,用返回的智能体 ID 替换示例 ID。
curl https://api.deepraxis.com/anthropic/v1/agents/agent_123 \
  -H "x-api-key: $PRAXIS_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "anthropic-beta: managed-agents-2026-04-01" \
  -H "Content-Type: application/json" \
  -d '{"name":"文档助手(已更新)","version":1}'
Python
# 先调用「创建智能体」,用返回的智能体 ID 替换示例 ID。
from anthropic import Anthropic

client = Anthropic(
    base_url="https://api.deepraxis.com/anthropic",
    api_key="$PRAXIS_API_KEY",
)

result = client.beta.agents.update("agent_123", name="文档助手(已更新)", version=1)
print(result)
TypeScript
// 先调用「创建智能体」,用返回的智能体 ID 替换示例 ID。
import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({
  baseURL: "https://api.deepraxis.com/anthropic",
  apiKey: "$PRAXIS_API_KEY",
});

const result = await client.beta.agents.update("agent_123", {
  "name": "文档助手(已更新)",
  "version": 1
});
console.log(result);

响应示例 200

{
  "id": "agent_d491cb4e-690a-4f8e-8977-d8186eee6919",
  "type": "agent",
  "name": "文档助手(已更新)",
  "description": null,
  "system": "用一句话简短回答。",
  "model": {
    "id": "deepseek-flash"
  },
  "metadata": {},
  "tools": [
    {
      "type": "agent_toolset_20260401",
      "default_config": {
        "enabled": true,
        "permission_policy": {
          "type": "always_allow"
        }
      },
      "configs": [
        {
          "name": "bash",
          "enabled": true,
          "permission_policy": null
        },
        {
          "name": "edit",
          "enabled": true,
          "permission_policy": null
        },
        {
          "name": "glob",
          "enabled": true,
          "permission_policy": null
        },
        {
          "name": "grep",
          "enabled": true,
          "permission_policy": null
        },
        {
          "name": "read",
          "enabled": true,
          "permission_policy": null
        },
        {
          "name": "write",
          "enabled": true,
          "permission_policy": null
        },
        {
          "name": "web_search",
          "type": "web_search",
          "enabled": true,
          "permission_policy": null
        },
        {
          "name": "web_fetch",
          "type": "web_fetch",
          "enabled": true,
          "permission_policy": null
        }
      ]
    }
  ],
  "mcp_servers": [],
  "skills": [],
  "multiagent": null,
  "version": 2,
  "created_at": "2026-10-23T01:35:25.425Z",
  "updated_at": "2026-10-23T01:35:29.901Z",
  "archived_at": null
}

响应

HTTP 200

Successful response

application/json

名称 类型 说明
id string
archived_at null | string A timestamp in RFC 3339 format
created_at string A timestamp in RFC 3339 format
description null | string
mcp_servers array<object>
mcp_servers[].type string
mcp_servers[].name string
mcp_servers[].url string
metadata object
model object Model identifier and configuration.
model.id string A model id from the Praxis model catalog (praxis.model.models.list). Unlike Anthropic, Claude model ids other than those in the catalog are rejected.
model.effort object How hard Claude works on each turn. Sets output_config.effort on every Messages call the session makes.
model.inference_geo string Geographic region for model inference. When unset, requests fall through to the workspace's default_inference_geo.
model.speed string Inference speed mode. fast provides significantly faster output token generation at premium pricing. Not all models support fast; invalid combinations are rejected at create time.
multiagent null | object Resolved coordinator topology with a concrete agent roster.
multiagent.agents array<object> Agents the coordinator may spawn as session threads, each resolved to a specific version.
multiagent.type string
name string
skills array<object>
skills[].skill_id string
skills[].type string
skills[].version string
system null | string
tools array<object>
tools[].configs array<object> | array | null
tools[].default_config object | object | null Resolved default configuration for agent tools.
tools[].type string
tools[].mcp_server_name string
tools[].description string
tools[].input_schema object JSON Schema for custom tool input parameters.
tools[].name string
type string
updated_at string A timestamp in RFC 3339 format
version number The agent's current version. Starts at 1 and increments when the agent is modified.