125 lines
7.0 KiB
Markdown
125 lines
7.0 KiB
Markdown
---
|
|
name: hermes-a2a
|
|
description: "Connect Hermes agents over A2A: setup, peers, verify."
|
|
version: 1
|
|
author: "Hermes Agent"
|
|
license: MIT
|
|
metadata:
|
|
hermes:
|
|
tags: [a2a, agents, multi-agent, hermes, tailnet, delegation]
|
|
related_skills: [hermes-agent, termux-go-builds]
|
|
---
|
|
|
|
# Hermes A2A (Agent-to-Agent) — connecting agents to each other
|
|
|
|
A2A is the open Agent2Agent protocol (v1.0) for inter-agent communication.
|
|
The Hermes A2A plugin is bidirectional:
|
|
- **Inbound**: your Hermes serves an Agent Card + JSON-RPC 2.0 endpoint (port 9900)
|
|
→ other agents can send you tasks.
|
|
- **Outbound**: the `a2a` toolset gives YOUR agent tools to call other agents
|
|
(`a2a_discover`, `a2a_call`, `a2a_list`, `a2a_history`, `a2a_orchestrate`).
|
|
|
|
Use A2A when crossing process/machine/framework boundaries. For multiple agents
|
|
on the SAME machine, prefer `delegate_task` (in-process) or the kanban board.
|
|
|
|
Docs: https://hermes-agent.nousresearch.com/docs/user-guide/messaging/a2a
|
|
|
|
## When to Use
|
|
- The user wants two Hermes agents (or a Hermes agent and any other agent) to talk to each other, send tasks, or chain multi-agent work across machines.
|
|
- Setting up or debugging an A2A inbound/outbound connection (port 9900, bearer token, peer registration).
|
|
- Deciding between in-process `delegate_task`/kanban (same machine) vs A2A (crosses process/machine/framework boundaries).
|
|
- Verifying that an A2A peer is actually reachable and answering, not just showing up in `tailscale status`.
|
|
|
|
## Quick setup (verified 2026-10-23)
|
|
|
|
1. **Enable the platform + toolsets:**
|
|
```bash
|
|
hermes config set gateway.platforms.a2a.enabled true
|
|
hermes tools enable a2a --platform cli
|
|
hermes tools enable a2a --platform a2a # lets inbound tasks call peers (agent chaining)
|
|
```
|
|
2. **Tokens & bind (in `~/.hermes/.env` — credentials go in .env, never config.yaml).**
|
|
Generate a token: `python3 -c "import secrets;print(secrets.token_hex(24))"`.
|
|
```
|
|
A2A_BEARER_TOKEN=<64-hex>
|
|
A2A_HOST=0.0.0.0 # widens bind ONLY when a token is set (security invariant)
|
|
A2A_PORT=9900
|
|
A2A_PUBLIC_URL=http://<node>.<tailnet-domain>:9900 # routable URL the Agent Card advertises
|
|
A2A_AGENT_NAME=<name>
|
|
```
|
|
Security model: **no token ⇒ binds 127.0.0.1 only.** Remote exposure requires a
|
|
bearer token AND `A2A_HOST`. Per-peer alt: `A2A_PEER_TOKENS="alice:tok1,bob:tok2"`.
|
|
3. **Register peers** (each peer must point at the OTHER's public URL + same token):
|
|
```bash
|
|
hermes config set a2a_agents.<peer>.url "http://<peer>.<domain>:9900" --force
|
|
hermes config set a2a_agents.<peer>.auth.type bearer --force
|
|
hermes config set a2a_agents.<peer>.auth.token "<same A2A_BEARER_TOKEN>" --force
|
|
```
|
|
4. **Start the gateway** in its own tmux session (survives session churn):
|
|
```bash
|
|
tmux new-session -d -s gateway 'env TERM=xterm hermes gateway run 2>&1 | tee -a ~/.hermes/logs/gateway-run.log'
|
|
```
|
|
|
|
## Verification (do this — don't trust the config)
|
|
- Agent Card: `curl -sS http://127.0.0.1:9900/.well-known/agent-card.json` → JSON with `name` and `url`.
|
|
- Inbound task:
|
|
```bash
|
|
curl -sS -X POST http://127.0.0.1:9900/ -H 'Authorization: Bearer <tok>' \
|
|
-d '{"jsonrpc":"2.0","id":1,"method":"SendMessage","params":{"message":{"messageId":"m1","role":"ROLE_USER","parts":[{"text":"hi"}]}}}'
|
|
```
|
|
- **The audit log is the source of truth**: `~/.hermes/a2a_audit.jsonl` records
|
|
inbound/outbound task + reply even when the HTTP response is lost. If you see
|
|
an `inbound` and a matching `outbound` line, the round-trip worked.
|
|
|
|
## Pitfalls (hit in-session)
|
|
- **curl timeout ≠ failure.** A self-test that times out (e.g. `-m 40`) can still
|
|
have a COMPLETE audit-log entry (inbound task + outbound reply). Check
|
|
`a2a_audit.jsonl` before concluding A2A is broken. A long LLM reply easily
|
|
exceeds a short curl timeout; the server logs `BrokenPipeError` after the client
|
|
gave up — that is a client-side timeout, not a server failure.
|
|
- **Same rule for a client-timed-out `a2a_call` — with one twist.** A client
|
|
timeout does not mean the task wasn't delivered: `a2a_list` (outbound count
|
|
rose) and the conversation's `a2a_history` prove delivery if your message is
|
|
listed there. But unlike the audit-log curl case, the lost reply is usually
|
|
LOST — the peer may still finish processing with no one listening for the
|
|
answer. If the result matters, follow up with a new call that references the
|
|
original task; don't blindly re-send the same text.
|
|
- **Peer agents have their own security heuristics.** A peer LLM can refuse a
|
|
relayed instruction containing a URL or auth token as "untrusted external
|
|
input" (because it arrived from another agent, not the user). Recover by
|
|
stating provenance explicitly (direct request from the user, the user's own
|
|
service/device) AND re-instructing with a concrete action verb ("call this
|
|
endpoint and report the response body") instead of "follow this URL".
|
|
- **Set the token BEFORE widening the bind.** `A2A_HOST=0.0.0.0` only widens the
|
|
bind when `A2A_BEARER_TOKEN` is set; without the token the server stays on
|
|
127.0.0.1 and remote peers get connection-refused.
|
|
- **Peers must be running too.** A node showing in `tailscale status --peers` is
|
|
NOT the same as its A2A server being up. Verify each peer's card first:
|
|
`curl -m 5 http://<peer>.<domain>:9900/.well-known/agent-card.json`.
|
|
- **Token must match on BOTH sides.** A mismatch does NOT always return HTTP 401 —
|
|
verified in-session: the peer answered `HTTP 200` with a JSON-RPC error body
|
|
`{"code": -32050, "message": "unauthorized"}`. Treat `-32050 unauthorized` as the
|
|
token-mismatch signature (card fetch needs no auth, so a 200 card + -32050 task call =
|
|
network fine, auth wrong).
|
|
- **`a2a_agents` is a custom top-level key** — `hermes config set` warns "not a
|
|
recognized config key"; use `--force`. It works and is read by the plugin.
|
|
- **Magic DNS may not exist for the tailnet.** `<node>.<zone>` URLs (in
|
|
`A2A_PUBLIC_URL`, peer `url`s, and the advertised Agent Card `url`) only resolve
|
|
if the control server has Magic DNS enabled for that zone. Symptom that bites:
|
|
even your OWN node's advertised URL fails with `curl: (6) Could not resolve
|
|
host` — the card is fine, the name just doesn't exist. Fix: enable Magic DNS on
|
|
the control server, or switch all references to the CGNAT address
|
|
(`tailscale ip -4` → `http://100.x.y.z:9900`) and regenerate `A2A_PUBLIC_URL`.
|
|
Diagnosis order when a peer is "unreachable": `curl (6)` = DNS, fix the name;
|
|
`curl (7) Failed to connect` = port closed, the peer's A2A server genuinely
|
|
isn't running (most common). A node in `tailscale status` does not imply either.
|
|
|
|
## Templates
|
|
- `templates/a2a-peer-setup.sh` — idempotent per-peer inbound setup (enables the
|
|
platform/toolsets, derives the tailnet IP via `tailscale ip -4` so it works
|
|
without Magic DNS, sets A2A_* env vars incl. token, self-tests the card).
|
|
Run it on EVERY box that must receive A2A tasks.
|
|
|
|
## See also
|
|
- Tailscale networking that A2A often rides over: see the `termux-go-builds` skill (references/tailscale-android.md there) for Termux/Android bring-up.
|