删除Agent
更新时间:2026-11-24
接口说明
- 本接口用于删除一个 Agent 定义,返回被删除记录的标识。
- 其下所有会话必须已结束,否则返回 409 AgentDefInUse,需先删除会话。
- status=creating 时返回 409 AgentDefNotReady;status=failed 可直接删除。
- status=deleting 的残留可再次调用删除补完。
- 声明跨 VPC 的 Agent 删除后 status 变为 deleting,运行时回收网关后才变为 deleted。
请求结构
Plain Text
1POST /v1/agents/delete HTTP/1.1
2Host: aw-harness.bj.baidubce.com
3Authorization: authorization string
4
5{
6 "agentName": "my-agent",
7 "agentId": "ag-7f3c9b2e"
8}
请求头域
除公共头域外,无其它特殊头域。
请求参数
| 参数名称 | 类型 | 是否必需 | 参数位置 | 描述 |
|---|---|---|---|---|
| agentName | String | 条件必需 | RequestBody参数 | Agent 名称寻址,与 agentId 至少传一个。 |
| agentId | String | 条件必需 | RequestBody参数 | 资源 ID 寻址(ag- 前缀),与 agentName 至少传一个。 |
返回头域
除公共头域,无其它特殊头域。
返回参数
| 参数名称 | 类型 | 描述 |
|---|---|---|
| agentId | String | 被删除记录的资源 ID。 |
| agentName | String | 被删除记录的名称。 |
错误码
| 错误码 | 错误描述 | HTTP状态码 | 中文解释 |
|---|---|---|---|
| InvalidArgument | The request parameters are invalid. | 400 | 两个寻址字段都未传,或请求体含未识别字段。 |
| Forbidden | Operation requires an admin caller. | 403 | 缺少鉴权账号、跨账号访问他人资源,或携带 Actor 头调用仅限管理员的写接口。 |
| AgentDefNotFound | Agent def not found. | 404 | 目标 Agent 不存在。 |
| AgentDefInUse | Agent def is in use. | 409 | 其下仍有未结束的会话,需先删除会话。 |
| AgentDefNotReady | Agent def is not ready. | 409 | Agent 处于 creating 状态,稍后重试。 |
| PersistFailed | Failed to delete the agent def. | 500 | 服务端存储写失败,可重试。 |
| Internal | Internal server error. | 500 | 服务端内部错误,保留 requestId 联系维护方。 |
请求示例
Plain Text
1POST http://aw-harness.bj.baidubce.com/v1/agents/delete
2Host: aw-harness.bj.baidubce.com
3Authorization: bce-auth-v1/f81d3b34e48048fbb2634dc7882d7e21/2015-08-11T04:17:29Z/3600/host/74c506f68c65e26c633bfa104c863fffac5190fdec1ec24b7c03eb5d67d2e1de
4Content-Type: application/json
5
6{
7 "agentName": "my-agent"
8}
返回示例
Plain Text
1HTTP/1.1 200 OK
2Content-Type: application/json;charset=UTF-8
3x-bce-request-id: 9f3d0e6a-1c2b-4d5e-8a7f-0b1c2d3e4f5a
4Server: BWS
5
6{
7 "result": {
8 "agentId": "ag-7f3c9b2e",
9 "agentName": "my-agent"
10 },
11 "requestId": "9f3d0e6a-1c2b-4d5e-8a7f-0b1c2d3e4f5a"
12}
评价此篇文章
