查询Agent详情
更新时间:2026-11-24
接口说明
- 本接口用于按 Agent 名称或资源 ID 查询单个 Agent 的完整定义与状态。
- 两个寻址字段至少传一个;同时传时按合取关系定位。
- 返回的 def 字段是用户提交的 Agent 定义原文,键名已归一为 lowerCamelCase。
- 本接口不返回 accountId,账号由鉴权凭据隐含。
请求结构
Plain Text
1POST /v1/agents/get 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,ag- 前缀。 |
| agentName | String | Agent 名称。 |
| description | String | Agent 描述,可为空串。 |
| version | Long | 配置版本。 |
| harnessType | String | 内核类型。 |
| createTime | String | 创建时间,RFC3339 UTC。 |
| updateTime | String | 更新时间,RFC3339 UTC。 |
| status | String | Agent 状态:creating、created、failed、deleting。 |
| def | AgentDef | 完整 Agent 定义。 |
错误码
| 错误码 | 错误描述 | HTTP状态码 | 中文解释 |
|---|---|---|---|
| InvalidArgument | The request parameters are invalid. | 400 | 两个寻址字段都未传,或请求体含未识别字段。 |
| Forbidden | Operation requires an admin caller. | 403 | 缺少鉴权账号或跨账号访问他人资源。 |
| AgentDefNotFound | Agent def not found. | 404 | 目标 Agent 不存在,或 name 与 agentId 合取不匹配。 |
| PersistFailed | Failed to load the agent def. | 500 | 服务端存储读取失败,可重试。 |
| Internal | Internal server error. | 500 | 服务端内部错误,保留 requestId 联系维护方。 |
请求示例
Plain Text
1POST http://aw-harness.bj.baidubce.com/v1/agents/get
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 "description": "示例 Agent",
11 "version": 3,
12 "harnessType": "opencode",
13 "status": "created",
14 "createTime": "2026-09-09T10:00:00Z",
15 "updateTime": "2026-09-09T11:23:45Z",
16 "def": {
17 "metadata": {
18 "name": "my-agent",
19 "description": "示例 Agent"
20 },
21 "spec": {
22 "harnessType": "opencode",
23 "model": {
24 "modelId": "deepseek-v4.1-flash"
25 }
26 }
27 }
28 },
29 "requestId": "9f3d0e6a-1c2b-4d5e-8a7f-0b1c2d3e4f5a"
30}
评价此篇文章
