用 CLI 调用 peer Agent
使用 mf 发现可调用 peer、发送 A2A 工作并恢复 long-running task。
mf a2a 支持两个方向:
- Outbound:调用已授权的 peer Agent 或 raw A2A server。
- Inbound:暴露当前 Agent,并管理 authorized caller。
A2A API 指南覆盖 inbound exposure 和 External client token。 本页重点说明 outbound call 和 task recovery。
发现可调用 peer
mf a2a status
结果列出当前 Agent 可以调用的 peer name/ID,以及 in-flight outbound call。发送时 使用列表中的 name 或 ID。
发送工作
mf a2a send peer-name "Summarize today's open pull requests."
mf a2a send peer-name "Continue the review." --context-id aac_xxx
mf a2a send peer-name "Inspect this file." --input-file ./report.txt
默认会等待结果。如果 remote Agent Card 暴露特定 skill,可使用 --skill <id>。
调用 raw URL 时,通过 stdin 或 MF_A2A_BEARER 提供 bearer:
printf '%s' "$A2A_TOKEN" |
mf a2a send https://example.com/a2a "Run the check." --bearer -
默认拒绝 HTTP、localhost 和 private target。--allow-http-localhost 只用于本地开发。
Long task
Stream event:
mf a2a send peer-name "Run the full audit." --stream
状态更新会实时显示。普通文本模式会合并 Agent 对内容的修正,只输出一次最终结果。
添加 --json 可实时接收每条状态和 artifact 事件。
或提交后立即返回:
mf a2a send peer-name "Run the full audit." --async --json
mf a2a tasks list --state working
mf a2a tasks get peer-name aat_xxx --wait
默认 client deadline 是 900 秒。--timeout 0 只会关闭 client deadline,不会移除
server-side task limit。
阻塞的 send(带不带 --stream 都一样)最多被服务端挂到它的阻塞上限(托管服务是
10 分钟)。到那时还在跑的一轮会继续跑:服务端把 task 以 working 状态交还,send
在同一个 client deadline 内用 tasks get 跟到它结束。如果 deadline 先到,send
以退出码 1 结束,并给出 task ID 和继续跟进用的 mf a2a tasks get … --wait 命令。
以 failed、canceled 或 rejected 结束的 task 会打印原因,退出码为 1。
恢复或取消
mf a2a tasks subscribe peer-name aat_xxx
mf a2a tasks get peer-name aat_xxx
mf a2a tasks cancel peer-name aat_xxx
subscribe 会重新连接 task SSE stream,持续接收更新直到任务结束。
断线后先用 get 判断状态再决定是否重试。CLI 每次发送都会生成新的 message ID,
因此即使复用 context 或 task ID,重新发送 prompt 仍会启动新一轮工作。
管理 inbound access
mf --agent-id agt_xxx a2a exposure get
mf --agent-id agt_xxx a2a exposure enable
mf --agent-id agt_xxx a2a callers list
Exposure 和 caller grant 是两个独立控制。创建 caller 不会自动打开 public exposure。
升级旧脚本
已废弃的 call、stream 和 peers 命令不再提供。升级 CLI 前,先更新保存的脚本和 Agent 指引:
| 原命令 | 现行命令 |
|---|---|
mf a2a call <target> <prompt> | mf a2a send <target> <prompt> |
mf a2a stream <url> <prompt> | mf a2a send <url> <prompt> --stream |
mf a2a peers | mf a2a status |
status --json 返回包含 peers 和 inflight 数组的对象。原来直接读取 peers --json 数组的脚本,需要改读 peers 字段。