错误码
更新时间:2026-11-23
当用户访问 API 出现错误时,会返回相应的错误码和错误信息,便于定位问题并做出适当的处理。请求发生错误时通过 Response Body 返回详细错误信息,遵循如下格式:
| 参数名 | 类型 | 说明 |
|---|---|---|
| code | String | 表示具体错误类型 |
| message | String | 有关该错误的详细说明 |
| requestId | String | 本次请求的 requestId,排查问题时请提供该值 |
| details | List<Object> | 字段校验失败时的明细,可通过 details[].field 定位具体字段 |
示例:
Plain Text
1{
2 "requestId" : "ae2225f7-1c2e-427a-a1ad-5413b762957d",
3 "code" : "AgentDefNotFound",
4 "message" : "Agent def not found."
5}
调用方应根据 code 判断处理方式,并保留 requestId 用于排查。状态码族约定如下:
| 状态码族 | 含义 |
|---|---|
| 4xx | 调用方可自行处理,如修改参数、更换凭据、开通服务或等待后重试。 |
| 424 Failed Dependency | 下游依赖暂态失败,可重试。刻意不占用 5xx,因此重试策略应按 code 而非仅按状态码族决定。 |
| 499 | 调用方已断开,响应无人接收。 |
| 5xx | 服务端确有故障,重试无用。 |
公共错误码
下表列出了 AgentWorks API 的公共错误码,所有接口都可能返回。
| 错误码 | 错误消息 | HTTP状态码 | 描述 |
|---|---|---|---|
| InvalidArgument | The request parameters are invalid. | 400 | 请求参数不合法。字段错误可通过 details[].field 定位具体字段。 |
| Forbidden | Operation requires an admin caller. | 403 | 缺少鉴权账号、跨账号访问他人资源,或携带 Actor 头调用仅限管理员的写接口。 |
| PersistFailed | Failed to persist the resource. | 500 | 服务端存储读写失败,可重试。 |
| Internal | Internal server error. | 500 | 服务端内部错误,保留 requestId 联系维护方。 |
业务错误码
下表列出了 AgentWorks API 的业务错误码,各错误码对应的接口见「错误码」列所属接口文档。
| 错误码 | 错误消息 | HTTP状态码 | 描述 |
|---|---|---|---|
| ModelAuthFailed | Model auth failed. | 400 | 下游模型或网关拒绝了所提供的凭据,重试同一个坏 key 不会成功。 |
| AgentDefQuotaExceeded | Agent def quota exceeded. | 403 | Agent 数量已达配额上限,需删除不用的 Agent 或申请调高上限。 |
| CrossVPCAgentDefQuotaExceeded | Cross-VPC agent def quota exceeded. | 403 | 跨 VPC Agent 数量已达独立配额上限。该配额与总配额分别生效。 |
| FileQuotaExceeded | File quota exceeded. | 403 | 账号上传文件数已达上限,需删除不用的文件。 |
| KnowledgeDisabled | Knowledge capability is not enabled in this region. | 403 | 企业 RAG 检索在当前地域不可用;或声明了 knowledge 能力但该地域不支持。 |
| MemorySpaceQuotaExceeded | Memory space quota exceeded. | 403 | Agent 绑定的记忆空间数超限。 |
| SessionQuotaExceeded | Session quota exceeded. | 403 | 该 Agent 名下的活跃会话数已达配额上限,需结束或删除旧会话。 |
| StarpointNotActivated | Starpoint is not activated. | 403 | 该账号未开通星点通道,无法使用平台预置模型。 |
| AgentDefNotFound | Agent def not found. | 404 | 目标 Agent 不存在,或 name 与 agentId 合取不匹配。 |
| FileNotFound | File not found. | 404 | 指定的文件不存在或不属于当前账号。 |
| McpNotFound | MCP not found. | 404 | 传入的 mcpId 不存在。 |
| MemorySpaceNotFound | Memory space not found. | 404 | 引用的记忆空间不存在或不属于本账号。 |
| MessageNotFound | Message not found. | 404 | 记录不存在或不属于当前账号。 |
| ModelServiceNotFound | Model service not found. | 404 | 传入的 serviceId 不存在。 |
| SessionNotFound | Session not found. | 404 | 会话不存在或不属于当前账号。 |
| AgentDefAlreadyExists | Agent def already exists. | 409 | 创建的目标名字下已有 Agent,不覆盖。 |
| AgentDefFailed | Agent def creation failed. | 409 | Agent 处于 failed 状态,需删除后重建。 |
| AgentDefInUse | Agent def is in use. | 409 | 其下仍有未结束的会话,需先删除会话。 |
| AgentDefNotReady | Agent def is not ready. | 409 | Agent 处于 creating 状态,稍后重试。 |
| IdempotencyKeyConflict | Idempotency key conflict. | 409 | 幂等键复用在已结束会话、不同 Agent 或不同平台,需换新键。 |
| McpAlreadyExists | MCP already exists. | 409 | 本账号本地域已有同名 MCP,需换名。 |
| McpInUse | MCP is in use. | 409 | MCP 仍被 Agent 绑定,需先解绑。 |
| McpVersionConflict | MCP version conflict. | 409 | 配置已被他人修改,需重新读取后再改。 |
| MemorySpaceNotReady | Memory space is not ready. | 409 | 记忆空间处于 CREATING、FAILED 或 DELETING,此刻不可绑定。 |
| ModelServiceAlreadyExists | Model service already exists. | 409 | 模型名称已存在或与星点模型重名。 |
| ModelServiceInUse | Model service is in use. | 409 | 模型仍被 Agent 引用,需先解除引用。 |
| SessionBusy | Session is busy. | 409 | 同一会话已有一次交互在进行中,或会话仍在创建;应等上一轮结束后再发。 |
| SessionExpired | Session expired. | 410 | 会话已结束、已删除或初始化失败,不能继续对话。 |
| FileTooLarge | The file is too large. | 413 | 上传文件超过 100MB 上限。 |
| HarnessRequestFailed | Harness request failed. | 424 | 命令非零退出、baseURL 不可达、响应解析失败等,非超时。 |
| HarnessTimeout | Harness request timed out. | 424 | 模型回复超过单轮上限,属下游暂态问题,可重试。 |
| HistoryQueryTimeout | Conversation history query timed out. | 424 | 聊天记录检索超时,属下游存储暂态问题,可退避重试。 |
| McpConnectFailed | Failed to connect to the remote MCP. | 424 | 远程 MCP 拉取工具列表失败,如超时、鉴权失败、不可达或协议错误。下游报文不回显。 |
| ModelCredentialFetchFailed | Failed to fetch model credential. | 424 | 向凭据服务申领模型密钥失败,可重试。 |
| SandboxProvisionFailed | Failed to provision sandbox. | 424 | 沙箱初始化失败,可稍后重试。 |
| SetupScriptFailed | Setup script failed. | 424 | 初始化脚本执行失败,修正 Agent 的 setupScript 后创建新会话。 |
| HistoryRateLimited | Too many conversation history queries. | 429 | 会话聊天记录查询并发超限(按账号计),可退避后重试。 |
评价此篇文章
