BEEOS CLOUD / DEVELOPER REFERENCE
A2A
Agent-to-Agent 的 JSON-RPC 请求、agent card 与任务。
概览
A2A domain 通过 Agent-to-Agent 协议暴露智能体:向智能体发送 JSON-RPC 请求,提供 agent card,并列出、读取和取消 A2A 任务。
6 个操作 · SDK 资源:TypeScript cloud.a2a · Python cloud.a2a · Go cloud.A2a · API 总览
主要对象
A2AAgentCard:描述智能体的 card。RuntimeMethodResponse:JSON-RPC 请求的结果。a2aTaskView:任务,包含A2ATaskStatus、A2AMessage和A2AArtifact。
A2AAgentCard
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
name | string | 是 | 智能体的显示名称。 |
description | string | 是 | 智能体的描述。 |
url | string | 否 | 智能体 JSON-RPC 端点的 URL。仅当请求发送 A2A-Version: 0.3 时返回;1.0 版本在 supportedInterfaces 中列出该端点。 |
version | string | 是 | 智能体的版本:其资源版本,十进制数字。 |
protocolVersion | string | 否 | url 所使用的 A2A 协议版本。仅当请求发送 A2A-Version: 0.3 时返回。 |
defaultInputModes | array<string> | 是 | 智能体接受作为输入的媒体类型,例如 text/plain。 |
defaultOutputModes | array<string> | 是 | 智能体产出的输出媒体类型,例如 text/plain。 |
supportedInterfaces | array<object> | 否 | 可以访问该智能体的接口。除非请求发送 A2A-Version: 0.3,否则返回。 |
supportedInterfaces[].url | string | 是 | 接口的 URL。 |
supportedInterfaces[].protocolBinding | string | 是 | 该接口使用的传输方式:JSONRPC。 |
supportedInterfaces[].protocolVersion | string | 是 | 该接口使用的 A2A 协议版本。 |
完整字段和使用该对象的方法见附录。
RuntimeMethodResponse
JSON-RPC 2.0 响应。成功时携带 result,失败时携带 error,二者不会同时出现。错误以 HTTP 状态 200 返回。
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
jsonrpc | string | 是 | JSON-RPC 协议版本:始终为 2.0。 可选值: "2.0" — JSON-RPC 2.0 版本. |
id | string | integer | 是 | 该响应所回答的请求的 ID。请求无法读取时为 null。 可为 null。 |
result | JSONValue | 否 | 方法的结果。仅在成功时出现;其结构取决于方法。 可为 null。 |
error | object | 否 | 调用的错误。仅在失败时出现。 |
error.code | integer | 是 | 错误码。-32700 解析错误,-32600 无效请求,-32601 方法不存在,-32602 无效参数,-32603 内部错误,-32001 任务不存在,-32002 任务不可取消,-32003 不支持推送通知,-32004 不支持的操作,-32005 不支持的内容类型,-32006 智能体响应无效,-32007 未配置 agent card,-32008 智能体繁忙,-32009 A2A-Version 不兼容,-32010 任务派发之后连接断开(请读取该任务,不要再次发送),-32011 任务超时,-32012 派发之前连接断开(没有任何运行;可以安全重试)。 |
error.message | string | 是 | 错误的可读描述。 |
error.data | JSONValue | 否 | 错误的机器可读详情:包含一个 type.googleapis.com/google.rpc.ErrorInfo 类型对象的列表。其 reason 为错误名称,例如 TASK_NOT_FOUND,其 metadata 重复 code 和 message。 可为 null。 |
完整字段和使用该对象的方法见附录。
a2aTaskView
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
id | string | 是 | 任务的 ID。 |
contextId | string | 是 | 任务所属的上下文(会话)的 ID。 |
status | A2ATaskStatus | 是 | 任务的当前状态。 |
artifacts | array<A2AArtifact> | 否 | 智能体为该任务产出的输出。没有时省略。 |
history | array<A2AMessage> | 否 | 任务的消息。读取单个任务时最多返回其中 history_length 条。没有存储历史时,包含原始请求这一条消息。没有时省略。 |
metadata | map<string, JSONValue> | 否 | 任务的额外元数据。没有时省略。 |
caller_principal_id | string | 是 | 提交该任务的主体的 ID。 |
caller_agent_id | string | 是 | 提交该任务的智能体的 ID(如果有)。 |
caller_owner_id | string | 是 | 提交方所有者的 ID。Cloud 根据凭证的组织和应用派生该值。调用方不发送终端用户 ID。 |
target_principal_id | string | 是 | 任务所发送给的主体的 ID。 |
target_agent_id | string | 是 | 任务所发送给的智能体的 ID。 |
target_owner_id | string | 是 | 接收方所有者的 ID。 |
channel_id | string | 否 | 承载该任务流式回复的通道的 ID。任务不使用基于通道的投递时省略。 |
created_at | string | 否 | 任务的创建时间,UTC 时间戳,例如 2026-01-02T15:04:05.000Z。未知时省略。 |
updated_at | string | 否 | 任务最后一次更新的时间,格式与 created_at 相同。未知时省略。 |
completed_at | string | 否 | 任务结束的时间,格式与 created_at 相同。任务结束之前省略。 |
完整字段和使用该对象的方法见附录。
A2ATaskStatus
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
state | string | 是 | 任务的当前状态。 取值见下表 A2ATaskStatus.state 取值。 |
message | A2AMessage | 否 | 说明该状态的消息,例如错误文本。它是带一个文本 part 的智能体消息。没有需要报告的内容时省略。 可为 null。 |
timestamp | string | 否 | 任务最后一次更新的时间;从未更新过则为创建时间,UTC 时间戳,例如 2026-01-02T15:04:05.000Z。 |
A2ATaskStatus.state 取值
| 取值 | 含义 |
|---|---|
"TASK_STATE_SUBMITTED" | 任务已创建,正在等待智能体开始处理。消息送达智能体后也会报告该状态。 |
"TASK_STATE_WORKING" | 智能体正在处理该任务。 |
"TASK_STATE_COMPLETED" | 最终状态。任务成功完成。 |
"TASK_STATE_FAILED" | 最终状态。任务因错误或超时而结束。 |
"TASK_STATE_CANCELED" | 最终状态。任务在完成前被取消。 |
"TASK_STATE_INPUT_REQUIRED" | 任务已暂停:智能体需要调用方提供更多输入才能继续。 |
"TASK_STATE_REJECTED" | 最终状态。智能体拒绝了该任务。 |
"TASK_STATE_AUTH_REQUIRED" | 任务已暂停:智能体需要额外的身份验证才能继续。 |
完整字段和使用该对象的方法见附录。
A2AMessage
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
messageId | string | 是 | 消息的 ID。服务器为每条渲染的消息生成新的 ID。 |
role | string | 是 | 消息的作者:ROLE_USER 为调用方,ROLE_AGENT 为智能体。 可选值: "ROLE_USER" — 该消息由调用方撰写; "ROLE_AGENT" — 该消息由智能体撰写. (枚举表) |
parts | array<A2AOutputPart> | 是 | 消息的内容,按顺序排列的 part。每个 part 是文本 part、文件 part 或数据 part。 |
contextId | string | 否 | 消息所属的上下文(会话)的 ID。未设置时省略。 |
taskId | string | 否 | 消息所属任务的 ID。未设置时省略。 |
referenceTaskIds | array<string> | 否 | 该消息所引用的其他任务的 ID。没有时省略。 |
metadata | map<string, JSONValue> | 否 | 附加在消息上的额外元数据。没有时省略。 |
完整字段和使用该对象的方法见附录。
A2AArtifact
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
artifactId | string | 是 | 产物的 ID。智能体未提供时,服务器使用 <task ID>-a<index>,index 从 0 开始计数。 |
name | string | 否 | 产物的显示名称。未设置时省略。 |
description | string | 否 | 产物的描述。未设置时省略。 |
parts | array<A2AOutputPart> | 是 | 产物的内容,按顺序排列的 part。每个 part 是文本 part、文件 part 或数据 part。 |
metadata | map<string, JSONValue> | 否 | 附加在产物上的额外元数据。没有时省略。 |
extensions | array<string> | 否 | 适用于该产物的协议扩展的 URI。没有时省略。 |
完整字段和使用该对象的方法见附录。
典型流程
- 用
a2a.getAgentCard读取 agent card(a2a.getAgentCardLegacy提供旧路径)。 - 用
a2a.invoke发送 JSON-RPC 请求。 - 用
a2a.listTasks与a2a.getTask跟踪工作,用a2a.cancelTask停止。
方法
| 方法 | HTTP | 摘要 |
|---|---|---|
| a2a.invoke | POST /v1/a2a/{agentId} | 发送 A2A JSON-RPC 请求 |
| a2a.getAgentCard | GET /v1/a2a/{agentId}/.well-known/agent-card.json | 获取 A2A agent card |
| a2a.getAgentCardLegacy | GET /v1/a2a/{agentId}/.well-known/agent.json | 获取 A2A agent card(旧路径) |
| a2a.listTasks | GET /v1/a2a/{agentId}/tasks | 列出 A2A 任务 |
| a2a.getTask | GET /v1/a2a/{agentId}/tasks/{taskId} | 获取一个 A2A 任务 |
| a2a.cancelTask | POST /v1/a2a/{agentId}/tasks/{taskId}/cancel | 取消一个 A2A 任务 |
a2a.invoke
POST /v1/a2a/{agentId} · Operation ID invokeA2A
发送 A2A JSON-RPC 请求
SDK 方法
| 语言 | 方法 | 签名 |
|---|---|---|
| TypeScript | cloud.a2a.invoke | invoke(agentId: string, input: Models.InvokeA2ARequest): Promise<Models.InvokeA2AResponse> |
| Python | cloud.a2a.invoke | def invoke(self, agent_id: str, input: InvokeA2ARequest) -> RuntimeMethodResponse |
| Go | cloud.A2a.Invoke | func (r *A2aResource) Invoke(ctx context.Context, agentId string, input InvokeA2ARequest) (RuntimeMethodResponse, error) |
参数
| 参数 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
agentId | path | string | 是 | 智能体的 ID。它必须属于你的应用。对于 JSON-RPC 和 agent card 请求,该智能体还必须启用其 A2A 协议,否则请求返回 403 a2a_disabled;读取任务则不受此限制。 |
请求体
application/json · 必填
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
jsonrpc | string | 是 | JSON-RPC 协议版本:必须为 2.0。 可选值: "2.0". |
id | string | 否 | 请求的 ID,在响应的 id 中原样返回。 |
method | string | 是 | 要调用的 A2A 方法。每个方法都有 A2A 1.0 名称和 A2A 0.3 别名:SendMessage(message/send)向智能体发送消息并创建任务;SendStreamingMessage(message/stream)同上,并以 server-sent events 流式返回更新;SubscribeToTask(tasks/resubscribe)恢复任务的更新流;GetTask(tasks/get)、CancelTask(tasks/cancel)和 ListTasks(tasks/list)读取和取消任务;CompleteTask(tasks/complete)以结果或错误消息结束任务;UpdateStatus(tasks/updateStatus)设置任务状态;CreateTaskPushNotificationConfig(SetPushNotificationConfig、tasks/pushNotification/set)、GetTaskPushNotificationConfig(GetPushNotificationConfig、tasks/pushNotification/get)、ListTaskPushNotificationConfigs(ListPushNotificationConfigs、tasks/pushNotification/list)和 DeleteTaskPushNotificationConfig(DeletePushNotificationConfig、tasks/pushNotification/delete)管理任务的推送通知设置。未知方法返回错误 -32601。 |
params | JSONValue | 否 | 方法的参数。其结构取决于 method,由 A2A 协议定义。 可为 null。 |
响应
200 · application/json · Schema: RuntimeMethodResponse
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
jsonrpc | string | 是 | JSON-RPC 协议版本:始终为 2.0。 可选值: "2.0" — JSON-RPC 2.0 版本. |
id | string | integer | 是 | 该响应所回答的请求的 ID。请求无法读取时为 null。 可为 null。 |
result | JSONValue | 否 | 方法的结果。仅在成功时出现;其结构取决于方法。 可为 null。 |
error | object | 否 | 调用的错误。仅在失败时出现。 |
error.code | integer | 是 | 错误码。-32700 解析错误,-32600 无效请求,-32601 方法不存在,-32602 无效参数,-32603 内部错误,-32001 任务不存在,-32002 任务不可取消,-32003 不支持推送通知,-32004 不支持的操作,-32005 不支持的内容类型,-32006 智能体响应无效,-32007 未配置 agent card,-32008 智能体繁忙,-32009 A2A-Version 不兼容,-32010 任务派发之后连接断开(请读取该任务,不要再次发送),-32011 任务超时,-32012 派发之前连接断开(没有任何运行;可以安全重试)。 |
error.message | string | 是 | 错误的可读描述。 |
error.data | JSONValue | 否 | 错误的机器可读详情:包含一个 type.googleapis.com/google.rpc.ErrorInfo 类型对象的列表。其 reason 为错误名称,例如 TASK_NOT_FOUND,其 metadata 重复 code 和 message。 可为 null。 |
错误
| 状态码 | Schema | 说明 |
|---|---|---|
| 其他(default) | ErrorResponse | Cloud Server 错误 |
错误 schema 见错误。
示例
import { BeeOSClient } from "@beeos-ai/cloud-sdk";
const cloud = new BeeOSClient({
baseURL: "https://api.cloud.beeos.ai/v1",
apiKey: "YOUR_API_KEY", // bsk_ key: backend only
});
const result = await cloud.a2a.invoke("agent_123", { jsonrpc: "2.0", method: "example_method" });
console.log(result);a2a.getAgentCard
GET /v1/a2a/{agentId}/.well-known/agent-card.json · Operation ID getA2AAgentCard
获取 A2A agent card
SDK 方法
| 语言 | 方法 | 签名 |
|---|---|---|
| TypeScript | cloud.a2a.getAgentCard | getAgentCard(agentId: string): Promise<Models.GetA2AAgentCardResponse> |
| Python | cloud.a2a.get_agent_card | def get_agent_card(self, agent_id: str) -> A2AAgentCard |
| Go | cloud.A2a.GetAgentCard | func (r *A2aResource) GetAgentCard(ctx context.Context, agentId string) (A2AAgentCard, error) |
参数
| 参数 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
agentId | path | string | 是 | 智能体的 ID。它必须属于你的应用。对于 JSON-RPC 和 agent card 请求,该智能体还必须启用其 A2A 协议,否则请求返回 403 a2a_disabled;读取任务则不受此限制。 |
响应
200 · application/json · Schema: A2AAgentCard
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
name | string | 是 | 智能体的显示名称。 |
description | string | 是 | 智能体的描述。 |
url | string | 否 | 智能体 JSON-RPC 端点的 URL。仅当请求发送 A2A-Version: 0.3 时返回;1.0 版本在 supportedInterfaces 中列出该端点。 |
version | string | 是 | 智能体的版本:其资源版本,十进制数字。 |
protocolVersion | string | 否 | url 所使用的 A2A 协议版本。仅当请求发送 A2A-Version: 0.3 时返回。 |
defaultInputModes | array<string> | 是 | 智能体接受作为输入的媒体类型,例如 text/plain。 |
defaultOutputModes | array<string> | 是 | 智能体产出的输出媒体类型,例如 text/plain。 |
supportedInterfaces | array<object> | 否 | 可以访问该智能体的接口。除非请求发送 A2A-Version: 0.3,否则返回。 |
supportedInterfaces[].url | string | 是 | 接口的 URL。 |
supportedInterfaces[].protocolBinding | string | 是 | 该接口使用的传输方式:JSONRPC。 |
supportedInterfaces[].protocolVersion | string | 是 | 该接口使用的 A2A 协议版本。 |
错误
| 状态码 | Schema | 说明 |
|---|---|---|
| 其他(default) | ErrorResponse | Cloud Server 错误 |
错误 schema 见错误。
示例
import { BeeOSClient } from "@beeos-ai/cloud-sdk";
const cloud = new BeeOSClient({
baseURL: "https://api.cloud.beeos.ai/v1",
apiKey: "YOUR_API_KEY", // bsk_ key: backend only
});
const result = await cloud.a2a.getAgentCard("agent_123");
console.log(result);a2a.getAgentCardLegacy
GET /v1/a2a/{agentId}/.well-known/agent.json · Operation ID getA2AAgentCardLegacy
获取 A2A agent card(旧路径)
SDK 方法
| 语言 | 方法 | 签名 |
|---|---|---|
| TypeScript | cloud.a2a.getAgentCardLegacy | getAgentCardLegacy(agentId: string): Promise<Models.GetA2AAgentCardLegacyResponse> |
| Python | cloud.a2a.get_agent_card_legacy | def get_agent_card_legacy(self, agent_id: str) -> A2AAgentCard |
| Go | cloud.A2a.GetAgentCardLegacy | func (r *A2aResource) GetAgentCardLegacy(ctx context.Context, agentId string) (A2AAgentCard, error) |
参数
| 参数 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
agentId | path | string | 是 | 智能体的 ID。它必须属于你的应用。对于 JSON-RPC 和 agent card 请求,该智能体还必须启用其 A2A 协议,否则请求返回 403 a2a_disabled;读取任务则不受此限制。 |
响应
200 · application/json · Schema: A2AAgentCard
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
name | string | 是 | 智能体的显示名称。 |
description | string | 是 | 智能体的描述。 |
url | string | 否 | 智能体 JSON-RPC 端点的 URL。仅当请求发送 A2A-Version: 0.3 时返回;1.0 版本在 supportedInterfaces 中列出该端点。 |
version | string | 是 | 智能体的版本:其资源版本,十进制数字。 |
protocolVersion | string | 否 | url 所使用的 A2A 协议版本。仅当请求发送 A2A-Version: 0.3 时返回。 |
defaultInputModes | array<string> | 是 | 智能体接受作为输入的媒体类型,例如 text/plain。 |
defaultOutputModes | array<string> | 是 | 智能体产出的输出媒体类型,例如 text/plain。 |
supportedInterfaces | array<object> | 否 | 可以访问该智能体的接口。除非请求发送 A2A-Version: 0.3,否则返回。 |
supportedInterfaces[].url | string | 是 | 接口的 URL。 |
supportedInterfaces[].protocolBinding | string | 是 | 该接口使用的传输方式:JSONRPC。 |
supportedInterfaces[].protocolVersion | string | 是 | 该接口使用的 A2A 协议版本。 |
错误
| 状态码 | Schema | 说明 |
|---|---|---|
| 其他(default) | ErrorResponse | Cloud Server 错误 |
错误 schema 见错误。
示例
import { BeeOSClient } from "@beeos-ai/cloud-sdk";
const cloud = new BeeOSClient({
baseURL: "https://api.cloud.beeos.ai/v1",
apiKey: "YOUR_API_KEY", // bsk_ key: backend only
});
const result = await cloud.a2a.getAgentCardLegacy("agent_123");
console.log(result);a2a.listTasks
GET /v1/a2a/{agentId}/tasks · Operation ID listA2ATasks
列出 A2A 任务
SDK 方法
| 语言 | 方法 | 签名 |
|---|---|---|
| TypeScript | cloud.a2a.listTasks | listTasks(agentId: string, query?: Models.ListA2ATasksQuery): Promise<Models.ListA2ATasksResponse> |
| Python | cloud.a2a.list_tasks | def list_tasks(self, agent_id: str, options: ListA2ATasksOptions | None = None) -> ListA2ATasksResponse |
| Go | cloud.A2a.ListTasks | func (r *A2aResource) ListTasks(ctx context.Context, agentId string, options ListA2ATasksOptions) (ListA2ATasksResponse, error) |
参数
| 参数 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
agentId | path | string | 是 | 智能体的 ID。它必须属于你的应用。对于 JSON-RPC 和 agent card 请求,该智能体还必须启用其 A2A 协议,否则请求返回 403 a2a_disabled;读取任务则不受此限制。 |
direction | query | string | 否 | sent 列出该智能体提交的任务,received 列出提交给它的任务。省略时两者都列出。其他任何值都会被拒绝。 |
agent_id | query | string | 否 | 只返回与该另一个智能体交换的任务,最多 128 个字符。它按提交方还是接收方匹配,取决于 direction。 |
cursor | query | string | 否 | 下一页的不透明游标:上一次响应的 next_cursor,最多 4096 字节。 |
limit | query | integer | 否 | 每页的任务数量,1 到 100。默认为 20。 |
响应
200 · application/json
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
tasks | array<a2aTaskView> | 是 | — |
total | integer | 是 | — |
next_cursor | string | 是 | — |
has_more | boolean | 是 | — |
错误
| 状态码 | Schema | 说明 |
|---|---|---|
| 其他(default) | ErrorResponse | Cloud Server 错误 |
错误 schema 见错误。
示例
import { BeeOSClient } from "@beeos-ai/cloud-sdk";
const cloud = new BeeOSClient({
baseURL: "https://api.cloud.beeos.ai/v1",
apiKey: "YOUR_API_KEY", // bsk_ key: backend only
});
const result = await cloud.a2a.listTasks("agent_123");
console.log(result);a2a.getTask
GET /v1/a2a/{agentId}/tasks/{taskId} · Operation ID getA2ATask
获取一个 A2A 任务
SDK 方法
| 语言 | 方法 | 签名 |
|---|---|---|
| TypeScript | cloud.a2a.getTask | getTask(agentId: string, taskId: string, query?: Models.GetA2ATaskQuery): Promise<Models.GetA2ATaskResponse> |
| Python | cloud.a2a.get_task | def get_task(self, agent_id: str, task_id: str, options: GetA2ATaskOptions | None = None) -> a2aTaskView |
| Go | cloud.A2a.GetTask | func (r *A2aResource) GetTask(ctx context.Context, agentId string, taskId string, options GetA2ATaskOptions) (a2aTaskView, error) |
参数
| 参数 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
agentId | path | string | 是 | 智能体的 ID。它必须属于你的应用。对于 JSON-RPC 和 agent card 请求,该智能体还必须启用其 A2A 协议,否则请求返回 403 a2a_disabled;读取任务则不受此限制。 |
taskId | path | string | 是 | 任务的 ID,最多 256 个字符。 |
history_length | query | integer | 否 | 返回的历史消息的最大数量,0 到 200。默认为 50。 |
响应
200 · application/json · Schema: a2aTaskView
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
id | string | 是 | 任务的 ID。 |
contextId | string | 是 | 任务所属的上下文(会话)的 ID。 |
status | A2ATaskStatus | 是 | 任务的当前状态。 |
artifacts | array<A2AArtifact> | 否 | 智能体为该任务产出的输出。没有时省略。 |
history | array<A2AMessage> | 否 | 任务的消息。读取单个任务时最多返回其中 history_length 条。没有存储历史时,包含原始请求这一条消息。没有时省略。 |
metadata | map<string, JSONValue> | 否 | 任务的额外元数据。没有时省略。 |
caller_principal_id | string | 是 | 提交该任务的主体的 ID。 |
caller_agent_id | string | 是 | 提交该任务的智能体的 ID(如果有)。 |
caller_owner_id | string | 是 | 提交方所有者的 ID。Cloud 根据凭证的组织和应用派生该值。调用方不发送终端用户 ID。 |
target_principal_id | string | 是 | 任务所发送给的主体的 ID。 |
target_agent_id | string | 是 | 任务所发送给的智能体的 ID。 |
target_owner_id | string | 是 | 接收方所有者的 ID。 |
channel_id | string | 否 | 承载该任务流式回复的通道的 ID。任务不使用基于通道的投递时省略。 |
created_at | string | 否 | 任务的创建时间,UTC 时间戳,例如 2026-01-02T15:04:05.000Z。未知时省略。 |
updated_at | string | 否 | 任务最后一次更新的时间,格式与 created_at 相同。未知时省略。 |
completed_at | string | 否 | 任务结束的时间,格式与 created_at 相同。任务结束之前省略。 |
错误
| 状态码 | Schema | 说明 |
|---|---|---|
| 其他(default) | ErrorResponse | Cloud Server 错误 |
错误 schema 见错误。
示例
import { BeeOSClient } from "@beeos-ai/cloud-sdk";
const cloud = new BeeOSClient({
baseURL: "https://api.cloud.beeos.ai/v1",
apiKey: "YOUR_API_KEY", // bsk_ key: backend only
});
const result = await cloud.a2a.getTask("agent_123", "task_123");
console.log(result);a2a.cancelTask
POST /v1/a2a/{agentId}/tasks/{taskId}/cancel · Operation ID cancelA2ATask
取消一个 A2A 任务
SDK 方法
| 语言 | 方法 | 签名 |
|---|---|---|
| TypeScript | cloud.a2a.cancelTask | cancelTask(agentId: string, taskId: string): Promise<Models.CancelA2ATaskResponse> |
| Python | cloud.a2a.cancel_task | def cancel_task(self, agent_id: str, task_id: str) -> a2aTaskView |
| Go | cloud.A2a.CancelTask | func (r *A2aResource) CancelTask(ctx context.Context, agentId string, taskId string) (a2aTaskView, error) |
参数
| 参数 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
agentId | path | string | 是 | 智能体的 ID。它必须属于你的应用。对于 JSON-RPC 和 agent card 请求,该智能体还必须启用其 A2A 协议,否则请求返回 403 a2a_disabled;读取任务则不受此限制。 |
taskId | path | string | 是 | 任务的 ID,最多 256 个字符。 |
响应
200 · application/json · Schema: a2aTaskView
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
id | string | 是 | 任务的 ID。 |
contextId | string | 是 | 任务所属的上下文(会话)的 ID。 |
status | A2ATaskStatus | 是 | 任务的当前状态。 |
artifacts | array<A2AArtifact> | 否 | 智能体为该任务产出的输出。没有时省略。 |
history | array<A2AMessage> | 否 | 任务的消息。读取单个任务时最多返回其中 history_length 条。没有存储历史时,包含原始请求这一条消息。没有时省略。 |
metadata | map<string, JSONValue> | 否 | 任务的额外元数据。没有时省略。 |
caller_principal_id | string | 是 | 提交该任务的主体的 ID。 |
caller_agent_id | string | 是 | 提交该任务的智能体的 ID(如果有)。 |
caller_owner_id | string | 是 | 提交方所有者的 ID。Cloud 根据凭证的组织和应用派生该值。调用方不发送终端用户 ID。 |
target_principal_id | string | 是 | 任务所发送给的主体的 ID。 |
target_agent_id | string | 是 | 任务所发送给的智能体的 ID。 |
target_owner_id | string | 是 | 接收方所有者的 ID。 |
channel_id | string | 否 | 承载该任务流式回复的通道的 ID。任务不使用基于通道的投递时省略。 |
created_at | string | 否 | 任务的创建时间,UTC 时间戳,例如 2026-01-02T15:04:05.000Z。未知时省略。 |
updated_at | string | 否 | 任务最后一次更新的时间,格式与 created_at 相同。未知时省略。 |
completed_at | string | 否 | 任务结束的时间,格式与 created_at 相同。任务结束之前省略。 |
错误
| 状态码 | Schema | 说明 |
|---|---|---|
| 其他(default) | ErrorResponse | Cloud Server 错误 |
错误 schema 见错误。
示例
import { BeeOSClient } from "@beeos-ai/cloud-sdk";
const cloud = new BeeOSClient({
baseURL: "https://api.cloud.beeos.ai/v1",
apiKey: "YOUR_API_KEY", // bsk_ key: backend only
});
const result = await cloud.a2a.cancelTask("agent_123", "task_123");
console.log(result);