Synapse A2A Communication
Synapse A2A 通信
Inter-agent communication framework via Google A2A Protocol.
基于Google A2A协议的Agent间通信框架。
| Task | Command |
|---|
| List agents (Rich TUI) | (event-driven refresh via file watcher with 10s fallback, ↑/↓ or 1-9 to select, Enter/j jump, k kill, / filter by TYPE/NAME/WORKING_DIR) |
| Send message | synapse send <target> "<message>" --from <sender>
|
| Broadcast to cwd agents | synapse broadcast "<message>" --from <sender>
|
| Wait for reply | synapse send <target> "<message>" --response --from <sender>
|
| Reply to last message | synapse reply "<response>"
|
| Reply to specific sender | synapse reply "<response>" --to <sender_id>
|
| List reply targets | synapse reply --list-targets
|
| Emergency stop | synapse send <target> "STOP" --priority 5 --from <sender>
|
| Stop agent | synapse stop <profile|id>
|
| Kill agent (graceful) | (sends shutdown request, 30s timeout, then SIGTERM) |
| Kill agent (force) | (immediate SIGKILL) |
| Jump to terminal | |
| Rename agent | synapse rename <target> --name <name> --role <role>
|
| Check file locks | synapse file-safety locks
|
| View history | |
| Initialize settings | |
| Edit settings (TUI) | (includes List Display for column config) |
| View settings | synapse config show [--scope user|project]
|
| Reset settings | synapse reset [--scope user|project|both]
|
| Show instructions | synapse instructions show <agent>
|
| Send instructions | synapse instructions send <agent> [--preview]
|
| View logs | synapse logs <profile> [-f] [-n <lines>]
|
| Add external agent | synapse external add <url> [--alias <name>]
|
| List external agents | |
| External agent info | synapse external info <alias>
|
| Send to external | synapse external send <alias> "<message>" [--wait]
|
| Remove external agent | synapse external remove <alias>
|
| Skill Manager (TUI) | |
| List skills | synapse skills list [--scope synapse|user|project|plugin]
|
| Show skill detail | synapse skills show <name>
|
| Deploy skill | synapse skills deploy <name> --agent claude,codex --scope user
|
| Import skill | synapse skills import <name>
|
| Install from repo | synapse skills add <repo>
|
| Create skill | |
| List skill sets | |
| Auth setup | (generate keys + instructions) |
| Generate API key | synapse auth generate-key [-n <count>] [-e]
|
| List task board | synapse tasks list [--status pending] [--agent claude]
|
| Create task | synapse tasks create "subject" -d "description" [--blocked-by ID]
|
| Assign task | synapse tasks assign <task_id> <agent>
|
| Complete task | synapse tasks complete <task_id>
|
| Approve plan | synapse approve <task_id>
|
| Reject plan | synapse reject <task_id> --reason "reason"
|
| Start team (CLI) | synapse team start <agents...> [--layout split|horizontal|vertical]
|
| Start team (API) | with {"agents": [...], "layout": "split"}
|
| Delegate mode | synapse claude --delegate-mode [--name coordinator]
|
| Version info | |
Tip: Run
before sending to verify the target agent is READY.
| 任务 | 命令 |
|---|
| 列出Agent(富文本终端界面) | (通过文件监视器实现事件驱动刷新,10秒超时降级;使用↑/↓或1-9选择,Enter/j跳转,k终止,/按类型/名称/工作目录过滤) |
| 发送消息 | synapse send <target> "<message>" --from <sender>
|
| 向当前工作目录下的Agent广播消息 | synapse broadcast "<message>" --from <sender>
|
| 等待回复 | synapse send <target> "<message>" --response --from <sender>
|
| 回复最后一条消息 | synapse reply "<response>"
|
| 回复特定发送方 | synapse reply "<response>" --to <sender_id>
|
| 列出回复目标 | synapse reply --list-targets
|
| 紧急停止 | synapse send <target> "STOP" --priority 5 --from <sender>
|
| 停止Agent | synapse stop <profile|id>
|
| 优雅终止Agent | (发送关闭请求,30秒超时后发送SIGTERM信号) |
| 强制终止Agent | (立即发送SIGKILL信号) |
| 跳转到Agent终端 | |
| 重命名Agent | synapse rename <target> --name <name> --role <role>
|
| 检查文件锁 | synapse file-safety locks
|
| 查看历史记录 | |
| 初始化设置 | |
| 编辑设置(终端界面) | (包含列配置的列表显示功能) |
| 查看设置 | synapse config show [--scope user|project]
|
| 重置设置 | synapse reset [--scope user|project|both]
|
| 显示指令 | synapse instructions show <agent>
|
| 发送指令 | synapse instructions send <agent> [--preview]
|
| 查看日志 | synapse logs <profile> [-f] [-n <lines>]
|
| 添加外部Agent | synapse external add <url> [--alias <name>]
|
| 列出外部Agent | |
| 查看外部Agent信息 | synapse external info <alias>
|
| 向外部Agent发送消息 | synapse external send <alias> "<message>" [--wait]
|
| 删除外部Agent | synapse external remove <alias>
|
| Skill管理器(终端界面) | |
| 列出Skill | synapse skills list [--scope synapse|user|project|plugin]
|
| 查看Skill详情 | synapse skills show <name>
|
| 部署Skill | synapse skills deploy <name> --agent claude,codex --scope user
|
| 导入Skill | synapse skills import <name>
|
| 从仓库安装Skill | synapse skills add <repo>
|
| 创建Skill | |
| 列出Skill集合 | |
| 认证设置 | (生成密钥及操作说明) |
| 生成API密钥 | synapse auth generate-key [-n <count>] [-e]
|
| 列出任务看板 | synapse tasks list [--status pending] [--agent claude]
|
| 创建任务 | synapse tasks create "subject" -d "description" [--blocked-by ID]
|
| 分配任务 | synapse tasks assign <task_id> <agent>
|
| 完成任务 | synapse tasks complete <task_id>
|
| 批准计划 | synapse approve <task_id>
|
| 拒绝计划 | synapse reject <task_id> --reason "reason"
|
| 启动Agent团队(命令行) | synapse team start <agents...> [--layout split|horizontal|vertical]
|
| 启动Agent团队(API) | ,请求体为{"agents": [...], "layout": "split"}
|
| 委托模式 | synapse claude --delegate-mode [--name coordinator]
|
| 版本信息 | |
提示: 发送消息前先运行
,确认目标Agent处于READY状态。
Sending Messages (Recommended)
发送消息(推荐方式)
Use command for inter-agent communication. This works reliably from any environment including sandboxed agents.
bash
synapse send gemini "Please review this code" --response --from synapse-claude-8100
synapse send claude "What is the status?" --response --from synapse-codex-8121
synapse send codex-8120 "Fix this bug" --response --priority 3 --from synapse-gemini-8110
Important:
- Always use with your agent ID (format: ). Do NOT use custom names or agent types for .
- By default, use to wait for a reply. Only use for notifications or fire-and-forget tasks.
Target Resolution (Matching Priority):
- Custom name: (highest priority, exact match, case-sensitive)
- Exact ID: (direct match)
- Type-port: , , , (shorthand)
- Type only: , , , , (only if single instance)
Note: When multiple agents of the same type are running, type-only targets (e.g.,
) will fail with an ambiguity error. Use custom name (e.g.,
) or type-port shorthand (e.g.,
) instead.
使用命令进行Agent间通信。 该命令在包括沙箱Agent在内的任何环境中都能可靠工作。
bash
synapse send gemini "请审核这段代码" --response --from synapse-claude-8100
synapse send claude "当前状态如何?" --response --from synapse-codex-8121
synapse send codex-8120 "修复这个bug" --response --priority 3 --from synapse-gemini-8110
重要提示:
- 务必使用参数指定你的Agent ID(格式:)。不要使用自定义名称或Agent类型作为的值。
- 默认使用参数等待回复。仅在发送通知或无需回复的任务时使用。
目标解析优先级:
- 自定义名称:(最高优先级,精确匹配,区分大小写)
- 精确ID:(直接匹配)
- 类型-端口简写:、、、(简写形式)
- 仅类型:、、、、(仅当该类型只有一个实例时可用)
注意: 当同一类型存在多个Agent时,仅使用类型作为目标(例如
)会因歧义而失败。请改用自定义名称(例如
)或类型-端口简写(例如
)。
Choosing --response vs --no-response
选择--response还是--no-response
Analyze the message content and determine if a reply is expected:
- If the message expects or benefits from a reply → use
- If the message is purely informational with no reply needed → use
- If unsure, use (safer default)
分析消息内容,判断是否需要回复:
- 如果消息需要或期望回复 → 使用
- 如果消息仅为通知类,无需回复 → 使用
- 若不确定,默认使用(更安全的选择)
Message that expects a reply
需要回复的消息
synapse send gemini "What is the best approach?" --response --from synapse-claude-8100
synapse send gemini "最佳方案是什么?" --response --from synapse-claude-8100
Purely informational, no reply needed
纯通知类消息,无需回复
synapse send codex "FYI: Build completed" --no-response --from synapse-claude-8100
synapse send codex "通知:构建已完成" --no-response --from synapse-claude-8100
Roundtrip Communication (--response)
往返通信(--response)
For request-response patterns:
Sender: Wait for response (blocks until reply received)
发送方:等待回复(阻塞直到收到回复)
synapse send gemini "Analyze this data" --response --from synapse-claude-8100
synapse send gemini "分析这些数据" --response --from synapse-claude-8100
Receiver: Reply to sender (auto-routes via reply tracking)
接收方:回复发送方(通过回复跟踪自动路由)
synapse reply "Analysis result: ..."
The `--response` flag makes the sender wait. The receiver should reply using the `synapse reply` command.
**Reply Tracking:** Synapse automatically tracks senders who expect a reply (`[REPLY EXPECTED]` messages). Use `synapse reply` for responses - it automatically knows who to reply to.
synapse reply "分析结果:..."
`--response`参数会让发送方处于等待状态。接收方应使用`synapse reply`命令进行回复。
**回复跟踪:** Synapse会自动跟踪期望回复的发送方(标记为`[REPLY EXPECTED]`的消息)。使用`synapse reply`进行回复时,系统会自动知道回复目标。
Broadcasting to All Agents
向所有Agent广播消息
Send a message to all agents sharing the same working directory:
向与发送方处于同一工作目录的所有Agent发送消息:
Broadcast status check to all cwd agents
向当前工作目录下的所有Agent发送状态检查广播
synapse broadcast "Status check" --from synapse-claude-8100
synapse broadcast "状态检查" --from synapse-claude-8100
synapse broadcast "Urgent: stop all work" --priority 4 --from synapse-claude-8100
synapse broadcast "紧急:停止所有工作" --priority 4 --from synapse-claude-8100
Fire-and-forget broadcast
无需回复的广播
synapse broadcast "FYI: Build completed" --no-response --from synapse-claude-8100
**Note:** Broadcast only targets agents in the **same working directory** as the sender. This prevents unintended messages to agents working on different projects.
synapse broadcast "通知:构建已完成" --no-response --from synapse-claude-8100
**注意:** 广播仅针对与发送方处于**同一工作目录**的Agent。这可避免向处理不同项目的Agent发送意外消息。
Receiving and Replying to Messages
接收并回复消息
When you receive an A2A message, it appears with the
prefix:
Message Formats:
A2A: [REPLY EXPECTED] <message> <- Reply is REQUIRED
A2A: <message> <- Reply is optional (one-way notification)
If
marker is present, you
MUST reply using
.
Reply Tracking: Synapse stores sender info only for messages with
marker. Multiple senders can be tracked simultaneously (each sender has one entry).
Replying to messages:
消息格式:
A2A: [REPLY EXPECTED] <消息内容> <- 必须回复
A2A: <消息内容> <- 回复可选(单向通知)
回复跟踪: Synapse仅为带有
标记的消息存储发送方信息。可同时跟踪多个发送方(每个发送方对应一条记录)。
回复消息的方式:
Use the reply command (auto-routes to last sender)
使用回复命令(自动路由到最后一个发送方)
synapse reply "Here is my analysis..."
synapse reply "这是我的分析结果..."
When multiple senders are pending, inspect and choose target
当有多个待回复发送方时,先查看并选择目标
synapse reply --list-targets
synapse reply "Here is my analysis..." --to <sender_id>
synapse reply --list-targets
synapse reply "这是我的分析结果..." --to <sender_id>
In sandboxed environments (like Codex), specify your agent ID
在沙箱环境中(如Codex),需指定你的Agent ID
synapse reply "Here is my analysis..." --from <your_agent_id>
**Example - Question received (MUST reply):**
Received: A2A: [REPLY EXPECTED] What is the project structure?
Reply: synapse reply "The project has src/, tests/..."
**Example - Delegation received (no reply needed):**
Received: A2A: Run the tests and fix failures
Action: Just do the task. No reply needed unless you have questions.
synapse reply "这是我的分析结果..." --from <your_agent_id>
收到:A2A: [REPLY EXPECTED] 项目结构是什么?
回复: synapse reply "项目包含src/、tests/..."
收到:A2A: 运行测试并修复失败项
操作: 直接执行任务即可。除非有疑问,否则无需回复。
| Priority | Description | Use Case |
|---|
| 1-2 | Low | Background tasks |
| 3 | Normal | Standard tasks |
| 4 | Urgent | Follow-ups, status checks |
| 5 | Interrupt | Emergency (sends SIGINT first) |
Default priority:
= 3 (normal),
= 1 (low).
| 优先级 | 描述 | 使用场景 |
|---|
| 1-2 | 低 | 后台任务 |
| 3 | 正常 | 标准任务 |
| 4 | 紧急 | 跟进任务、状态检查 |
| 5 | 中断 | 紧急情况(先发送SIGINT信号) |
Normal priority (default: 3) - with response
正常优先级(默认:3)- 等待回复
synapse send gemini "Analyze this" --response --from synapse-claude-8100
synapse send gemini "分析这个内容" --response --from synapse-claude-8100
Higher priority - urgent request
高优先级 - 紧急请求
synapse send claude "Urgent review needed" --response --priority 4 --from synapse-codex-8121
synapse send claude "急需审核" --response --priority 4 --from synapse-codex-8121
synapse send codex "STOP" --priority 5 --from synapse-claude-8100
synapse send codex "STOP" --priority 5 --from synapse-claude-8100
| Status | Meaning | Color |
|---|
| READY | Idle, waiting for input | Green |
| WAITING | Awaiting user input (selection, confirmation) | Cyan |
| PROCESSING | Busy handling a task | Yellow |
| DONE | Task completed (auto-clears after 10s) | Blue |
| SHUTTING_DOWN | Graceful shutdown in progress | Red |
Verify before sending: Run
and confirm the target agent's Status column shows
:
| 状态 | 含义 | 颜色 |
|---|
| READY | 空闲,等待输入 | 绿色 |
| WAITING | 等待用户输入(选择、确认) | 青色 |
| PROCESSING | 正忙于处理任务 | 黄色 |
| DONE | 任务已完成(10秒后自动清除) | 蓝色 |
| SHUTTING_DOWN | 正在进行优雅关闭 | 红色 |
发送前验证: 运行
,确认目标Agent的状态列显示为
:
Output (NAME column shows custom name if set, otherwise agent ID):
输出(NAME列显示自定义名称,若无则显示Agent ID):
NAME TYPE STATUS PORT WORKING_DIR
NAME TYPE STATUS PORT WORKING_DIR
my-claude claude READY 8100 my-project # <- has custom name
my-claude claude READY 8100 my-project # <- 已设置自定义名称
gemini gemini WAITING 8110 my-project # <- no custom name, shows type
gemini gemini WAITING 8110 my-project # <- 无自定义名称,显示类型
codex codex PROCESSING 8120 my-project # <- busy
codex codex PROCESSING 8120 my-project # <- 忙碌中
**Status meanings:**
- `READY`: Safe to send messages
- `WAITING`: Agent needs user input - use terminal jump (see below) to respond
- `PROCESSING`: Busy, wait or use `--priority 5` for emergency interrupt
- `DONE`: Recently completed, will return to READY shortly
**状态含义:**
- `READY`:可安全发送消息
- `WAITING`:Agent需要用户输入 - 使用终端跳转(见下文)进行响应
- `PROCESSING`:忙碌中,可等待或使用`--priority 5`进行紧急中断
- `DONE`:最近完成任务,很快会返回READY状态
In
, you can interact with agents:
| Key | Action |
|---|
| Select agent row (direct) |
| Navigate agent rows |
| or | Jump to selected agent's terminal |
| Kill selected agent (with confirmation) |
| Filter by TYPE, NAME, or WORKING_DIR |
| Clear filter first, then selection |
| Quit |
Supported Terminals:
- iTerm2 (macOS) - Switches to correct tab/pane
- Terminal.app (macOS) - Switches to correct tab
- Ghostty (macOS) - Activates application
- VS Code integrated terminal - Opens to working directory
- tmux - Switches to agent's session
- Zellij - Focuses agent's terminal pane
Use case: When an agent shows
status, use terminal jump to quickly respond to its selection prompt.
| 按键 | 操作 |
|---|
| 直接选择Agent行 |
| 导航Agent行 |
| 或 | 跳转到选中Agent的终端 |
| 终止选中Agent(需确认) |
| 按类型、名称或工作目录过滤 |
| 先清除过滤器,再清除选择 |
| 退出 |
支持的终端:
- iTerm2(macOS)- 切换到正确的标签/面板
- Terminal.app(macOS)- 切换到正确的标签
- Ghostty(macOS)- 激活应用程序
- VS Code集成终端 - 打开到工作目录
- tmux - 切换到Agent的会话
- Zellij - 聚焦Agent的终端面板
使用场景: 当Agent显示
状态时,使用终端跳转快速响应其选择提示。
Assign custom names and roles to agents for easier identification:
Start with name and role
启动时指定名称和角色
synapse claude --name my-claude --role "code reviewer"
synapse claude --name my-claude --role "代码审核员"
Skip interactive name/role setup
跳过交互式名称/角色设置
synapse claude --no-setup
synapse claude --no-setup
Update name/role after agent is running
Agent运行后更新名称/角色
synapse rename synapse-claude-8100 --name my-claude --role "test writer"
synapse rename my-claude --role "documentation" # Change role only
synapse rename my-claude --clear # Clear name and role
Once named, use the custom name for all operations:
```bash
synapse send my-claude "Review this code" --from synapse-codex-8121
synapse jump my-claude
synapse kill my-claude
Name vs ID:
- Display/Prompts: Shows name if set, otherwise ID (e.g.,
Kill my-claude (PID: 1234)?
)
- Internal processing: Always uses agent ID ()
- Target resolution: Name has highest priority when matching targets
synapse rename synapse-claude-8100 --name my-claude --role "测试编写者"
synapse rename my-claude --role "文档编写" # 仅修改角色
synapse rename my-claude --clear # 清除名称和角色
设置名称后,所有操作均可使用自定义名称:
```bash
synapse send my-claude "审核这段代码" --from synapse-codex-8121
synapse jump my-claude
synapse kill my-claude
名称与ID的区别:
- 显示/提示: 若设置了名称则显示名称,否则显示ID(例如:
Kill my-claude (PID: 1234)?
)
- 内部处理: 始终使用Agent ID()
- 目标解析: 名称在匹配目标时优先级最高
External Agent Management
外部Agent管理
Connect to external A2A-compatible agents over HTTP/HTTPS:
通过HTTP/HTTPS连接到兼容A2A协议的外部Agent:
Discover and add an external agent
发现并添加外部Agent
List registered external agents
列出已注册的外部Agent
Show agent details (capabilities, skills)
查看Agent详情(功能、Skill)
synapse external info myagent
synapse external info myagent
Send message to external agent
向外部Agent发送消息
synapse external send myagent "Analyze this data"
synapse external send myagent "Process file" --wait # Wait for completion
synapse external send myagent "分析这些数据"
synapse external send myagent "处理文件" --wait # 等待完成
synapse external remove myagent
External agents are stored persistently in `~/.a2a/external/`.
synapse external remove myagent
外部Agent的信息会持久存储在`~/.a2a/external/`目录中。
Secure A2A communication with API key authentication:
Interactive setup (generates keys + shows instructions)
交互式设置(生成密钥并显示操作说明)
Generate API key(s)
生成API密钥
synapse auth generate-key
synapse auth generate-key -n 3 -e # 3 keys in export format
synapse auth generate-key
synapse auth generate-key -n 3 -e # 生成3个可导出格式的密钥
Enable authentication
启用认证
export SYNAPSE_AUTH_ENABLED=true
export SYNAPSE_API_KEYS=<key>
export SYNAPSE_ADMIN_KEY=<admin_key>
synapse claude
export SYNAPSE_AUTH_ENABLED=true
export SYNAPSE_API_KEYS=<key>
export SYNAPSE_ADMIN_KEY=<admin_key>
synapse claude
Start agents without sending initial instructions (for session recovery):
bash
synapse claude -- --resume
synapse gemini -- --resume
synapse codex -- resume # Codex: resume is a subcommand
synapse opencode -- --continue
synapse copilot -- --continue
To inject instructions later:
synapse instructions send <agent>
.
启动Agent时不发送初始指令(用于会话恢复):
bash
synapse claude -- --resume
synapse gemini -- --resume
synapse codex -- resume # Codex:resume是子命令
synapse opencode -- --continue
synapse copilot -- --continue
后续可通过以下命令注入指令:
synapse instructions send <agent>
。
- Agent Naming: Custom names and roles for easy identification
- Agent Communication: command, for cwd-scoped messaging, priority control, response handling
- Task History: Search, export, statistics ()
- File Safety: Lock files to prevent conflicts (); active locks shown in EDITING_FILE column
- External Agents: Connect to external A2A agents ()
- Authentication: API key-based security ()
- Skill Management: Central skill store, deploy, import, create, skill sets ()
- Settings: Configure via ()
- Approval Mode: Control initial instruction approval ( in settings)
- Shared Task Board: Create, claim, and complete tasks with dependency tracking ()
- Quality Gates: Configurable hooks (, ) that gate status transitions
- Plan Approval: Plan-mode workflow with for review
- Graceful Shutdown: sends shutdown request before SIGTERM (30s timeout)
- Delegate Mode: creates a coordinator that delegates instead of editing files
- Auto-Spawn Panes: launches multiple agents in split panes
- Agent命名: 自定义名称和角色,便于识别
- Agent通信: 命令、用于当前工作域消息发送、优先级控制、回复处理
- 任务历史: 搜索、导出、统计()
- 文件安全: 锁定文件以避免冲突();的EDITING_FILE列会显示活跃的文件锁
- 外部Agent: 连接到外部A2A Agent()
- 认证: 基于API密钥的安全机制()
- Skill管理: 集中式Skill仓库、部署、导入、创建、Skill集合()
- 设置: 通过配置()
- 审批模式: 控制初始指令的审批(设置中的)
- 共享任务看板: 创建、认领、完成任务,支持依赖跟踪()
- 质量门: 可配置的钩子(、),用于控制状态转换
- 计划审批: 计划模式工作流,使用进行审核
- 优雅关闭: 先发送关闭请求,30秒超时后发送SIGTERM信号
- 委托模式: 创建一个协调器,负责委托任务而非直接编辑文件
- 自动生成面板: 在拆分面板中启动多个Agent
When running multiple environments or tests, override storage paths via env vars:
- (default: )
SYNAPSE_EXTERNAL_REGISTRY_DIR
(default: )
- (default:
~/.synapse/history/history.db
)
- (default: )
运行多环境或测试时,可通过环境变量覆盖存储路径:
- (默认:)
SYNAPSE_EXTERNAL_REGISTRY_DIR
(默认:)
- (默认:
~/.synapse/history/history.db
)
- (默认:)
For detailed documentation, read:
- - Full CLI command reference
references/file-safety.md
- File Safety detailed guide
- - A2A endpoints and message format
- - Multi-agent workflow examples
如需详细文档,请阅读:
- - 完整CLI命令参考
references/file-safety.md
- 文件安全详细指南
- - A2A端点及消息格式
- - 多Agent工作流示例