Repository navigation
Description
Summary
Enable Trinity agents to delegate tasks to agents on a different Trinity instance using the A2A protocol. Agent A on Instance 1 calls `call_a2a_agent` (see #736) with the remote agent's Agent Card URL (see #737). Auth is handled by a stored token in `.env`. No custom inter-Trinity protocol needed — standard A2A over HTTPS.
Context
Multi-instance Trinity deployments (e.g. production + staging, or multiple operator-controlled instances) currently have no native way to delegate across instances. Once #736 (A2A client tool) and #737 (Agent Card serving) land, Trinity-to-Trinity federation is a zero-code-change consequence: each instance already speaks A2A client and serves A2A cards. This issue tracks the validation, documentation, and any glue needed to make cross-instance calls work reliably. Depends on #736 and #737.
Acceptance Criteria
- End-to-end test: Agent on Instance A calls agent on Instance B via `call_a2a_agent` using the remote Agent Card URL
- Remote instance auth: calling agent stores `A2A_{REMOTE_DOMAIN}_TOKEN` in `.env` (a Trinity MCP API key from the remote instance)
- `agent_permissions` on the remote instance controls whether the inbound call is accepted (remote agent must permit inbound A2A calls from the caller's Trinity identity)
- Cross-instance audit: both instances log the call — Instance A logs outbound (actor: local agent), Instance B logs inbound (source: A2A, actor_ip: Instance A)
- Docs: update `docs/MULTI_AGENT_SYSTEM_GUIDE.md` with a cross-instance delegation pattern example
- Error handling: Instance B unreachable → graceful failure with retry guidance in the calling agent's response
- No new infrastructure required — works over existing HTTPS/Cloudflare Tunnel endpoints
Technical Notes
- This issue is intentionally minimal: the protocol work is in feat: add call_a2a_agent MCP tool for outbound A2A protocol calls #736 and feat: serve A2A Agent Cards from template.yaml for external discoverability #737. This issue covers the auth wiring, permission model for inbound A2A calls, and cross-instance observability.
- Inbound A2A requests arrive at the A2A JSON-RPC endpoint added alongside feat: serve A2A Agent Cards from template.yaml for external discoverability #737. The backend validates the Bearer token as a Trinity MCP API key (existing `/api/mcp/validate` path).
- The `agent_permissions` table currently governs intra-instance calls. Inbound A2A calls from another instance authenticate as a platform-level user (the MCP key owner), so existing sharing/permission checks apply without schema changes.
- Depends on: feat: add call_a2a_agent MCP tool for outbound A2A protocol calls #736 (call_a2a_agent tool), feat: serve A2A Agent Cards from template.yaml for external discoverability #737 (Agent Card serving + inbound A2A endpoint)
Activity
feat(a2a): call_a2a_agent — outbound A2A calls to external agents (#736…
fix(a2a): one port normalisation for validation, pinning and origin c…
fix(a2a): compare IP-literal origins as addresses, not as text (ent#3…
fix(a2a): set each refusal reason at its raise site, not by matching …
fix(tests): loopback A2A overrides the route's actual auth dependency…