feat(tools): implement A2A client tools and server (closes #514 phases 1 & 2)#4952
Closed
balaji-embedcentrum wants to merge 20 commits into
Closed
Conversation
…ch#514 phases 1 & 2) Phase 1 — A2A Client (tools/a2a_tool.py): - Add a2a_discover: fetch and cache Agent Cards from remote A2A endpoints - Add a2a_call: send tasks via tasks/send (non-streaming) or tasks/sendSubscribe (SSE streaming), auto-detected from Agent Card - Add a2a_local_scan: scan localhost port range to discover running A2A agents without pre-configuration - Agent card caching (5 min TTL) shared across discover and call - Named agent resolution from ~/.hermes/config.yaml a2a_agents section Phase 2 — A2A Server (a2a_adapter/): - HermesAgentExecutor wrapping AIAgent.run_conversation() - Streaming via SSE (tasks/sendSubscribe) with delta queue bridge - Bearer token auth via A2A_KEY env var - Agent Card built from env vars (AGENT_NAME, AGENT_SKILLS, etc.) - Separate uvicorn process on configurable port (default 9000) - CLI entry point: hermes-a2a / python -m a2a_adapter Supporting changes: - pyproject.toml: [a2a] extra, hermes-a2a entry point, a2a_adapter package - toolsets.py: a2a toolset definition + all 3 tools in _HERMES_CORE_TOOLS Docs & tests: - docs/a2a-user-guide.md: end-user guide for server and client usage - docs/a2a-architecture.md: internal design, data flow, extension points - tests/tools/test_a2a_tool.py: unit tests for all 3 tools using mocks
bf88439 to
f858348
Compare
- Slim Dockerfile: drops playwright/nodejs/ffmpeg, adds filebrowser binary and supervisor; installs only a2a+mcp extras (~60% smaller image) - supervisord manages 3 processes per container: hermes gateway (8642), A2A server (9000), filebrowser UI (8080) - entrypoint: persona selection via AGENT_PERSONA env var, filebrowser first-run init with FB_PASSWORD, A2A_KEY warning if unset - docker/config.yaml: api_server platform + a2a toolset + all 30 agents pre-wired with bearer tokens for cross-agent A2A calls - docker-compose.yml: 30 services (HP/Marvel/Office), individual port triplets (80xx/90xx/70xx), 768MB/0.25CPU limits per container - 30 persona SOUL.md files: Harry Potter x10, Marvel x10, Office x10 (Maxwell/Toby/Claire/Alex/Frank/Maya/Linda/Raj/Derek/Eleanor) - .env.fleet.example: template for 60 secrets (30 A2A keys + 30 FB passwords) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- hermes gateway needs --platform api_server flag to serve the OpenAI-compatible HTTP API on :8642; without it only runs messaging gateway (Telegram/Discord) with nothing on the port - GATEWAY_ALLOW_ALL_USERS=true required so API server accepts requests without an allowlist configured Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- hermes gateway does not accept --platform flag; API server is enabled via API_SERVER_ENABLED=true env var instead - correct subcommand is 'hermes gateway run' not 'hermes gateway' Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The agent card was hardcoding 'http://localhost:{port}' which breaks
orchestrators that discover the agent and call back using the URL in
the card. A2A_PUBLIC_URL env var now sets the correct external URL.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
A2A SDK 0.3.x renamed the event id field to taskId and added a required contextId field on TaskStatusUpdateEvent and TaskArtifactUpdateEvent. Updated all event emissions to match. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
A2A SDK 0.3.x requires artifactId inside the artifact dict on TaskArtifactUpdateEvent. Added to both streaming and non-streaming artifact emissions. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Wire tool_gen_callback to push tool call names into the delta queue as dict events. These are forwarded to the A2A event queue as data artifact parts so the Akela orchestrator can display tool steps in real time.
Add _extract_message_content() that returns a list of Anthropic-format content blocks when image file parts are present. Text-only messages still return a plain string. Images from Akela attachment parts are forwarded to run_conversation as multimodal content so the agent can see them directly.
Tenants need to browse all agent data (sessions, logs, config, memories) not just the empty files/ upload directory.
- Walks workspace directory for all 21 Sylang file extensions
- Returns all file contents in one JSON response (batch delivery for hermes web app)
- 5-min per-repo cache, auto-invalidated on file writes
- POST /ws/{repo}/symbols/invalidate for manual cache bust
…n commit messages)
Needed so hermes can run git commands inside the container (used by the new /ws/* workspace API routes and git/log, git/files endpoints). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…r-implementation # Conflicts: # Dockerfile # docker/entrypoint.sh # pyproject.toml
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #514 — implements Phases 1 and 2 of the A2A (Agent-to-Agent) protocol support.
Phase 1 — A2A Client (
tools/a2a_tool.py)Three new tools in the
a2atoolset:a2a_discover— fetch an Agent Card from any A2A endpoint; results cached for 5 min to avoid redundant fetchesa2a_call— send a task to a remote A2A agent; auto-detects streaming capability from the cached Agent Card and usestasks/sendSubscribe(SSE) when supported, falling back totasks/senda2a_local_scan— scan a localhost port range (default 9000–9010) to discover running A2A agents without any pre-configuration; closes the discovery gap identified in the issueNamed agents can be pre-configured in
~/.hermes/config.yaml:Phase 2 — A2A Server (
a2a_adapter/)Exposes Hermes as a standards-compliant A2A agent over HTTP:
HermesAgentExecutorwrapsAIAgent.run_conversation()with full SSE streaming supportA2A_KEYenv varAGENT_NAME,AGENT_SKILLS,AGENT_DESCRIPTION, etc.)9000)Supporting changes
pyproject.toml—[a2a]optional extra,hermes-a2aCLI entry point,a2a_adapterin packagestoolsets.py—a2atoolset definition + all 3 tools registered in_HERMES_CORE_TOOLSDocs & Tests
docs/a2a-user-guide.md— end-user guide covering server setup, client tools, multi-agent workflows, auth, and troubleshootingdocs/a2a-architecture.md— internal design, data flow diagrams, extension pointstests/tools/test_a2a_tool.py— unit tests for all 3 tools using mocks (no real servers needed); covers caching, SSE streaming, named agent resolution, error handlingWhat's not in this PR (Phase 3)
Multi-agent orchestration patterns (agent registry, automatic agent selection, fan-out workflows) remain open per the original issue roadmap.
How to test manually
1. Start the A2A server:
2. Verify the Agent Card:
curl http://localhost:9000/.well-known/agent.json | jq3. Send a test task:
4. Test client tools in chat:
5. Run unit tests:
Platforms tested
tasks/sendreturned completed response, SSE streaming verified end-to-end against live deploymentTest plan
pip install 'hermes-agent[a2a]'installs without errorshermes-a2astarts and serves Agent Card at/.well-known/agent.jsontasks/sendreturns a completed responsetasks/sendSubscribestreams SSE events correctlya2a_discover,a2a_call,a2a_local_scanavailable in chat witha2atoolset enabledpytest tests/tools/test_a2a_tool.pypasses in full dev environmentRelated issues
Closes #514 — related: #344, #342, #413