feat(a2a): implement A2A client tools and server (closes #514 phases 1 & 2)#4948
Closed
balaji-embedcentrum wants to merge 1 commit into
Closed
Conversation
…#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 Co-Authored-By: balaji-embedcentrum <balaji@embedcentrum.com>
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 correct response, SSE streaming verified end-to-end against live deployment athttp://15.204.116.57:8106Test 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