feat: native multi-agent support via MultiAgentRegistry - #1031
feat: native multi-agent support via MultiAgentRegistry#1031malladinagarjuna2 wants to merge 1 commit into
Conversation
This adds native support for multiple agents in the reference-jsonrpc Quarkus extension.
If a CDI bean implements MultiAgentRegistry, the A2AServerRoutes will automatically
dynamically register endpoints for each agent, mapping '/{agentId}' to its JSONRPCHandler
and '/{agentId}/.well-known/agent-card.json'.
kabir
left a comment
There was a problem hiding this comment.
Thanks for the PR :-) The MultiAgentRegistry approach is interesting.
A few things to address before this can be merged:
- Support for all transports (REST, gRPC), not just JSON-RPC — as noted inline
- The tenant extraction / agent ID path conflict
- Compile issues in the tests
It would also be interesting to see if this could be enhanced with @mescaja's database-driven approach from #898 (comment) — either in this PR or as a follow-up.
| Instance<JSONRPCHandler> jsonRpcHandler; | ||
|
|
||
| @Inject | ||
| Instance<org.a2aproject.sdk.server.apps.quarkus.registry.MultiAgentRegistry> multiAgentRegistry; |
| String pathPrefix = "/" + agentId; | ||
| registerAgentRoutes(router, pathPrefix, entry.getValue()); | ||
| } | ||
| } else if (!jsonRpcHandler.isUnsatisfied()) { |
There was a problem hiding this comment.
Better to use isResolvable()
| /** | ||
| * @return a map of agent ID (path segment) to their JSONRPCHandler | ||
| */ | ||
| Map<String, JSONRPCHandler> getAgents(); |
There was a problem hiding this comment.
We should also include the other transports
| } | ||
|
|
||
| private void registerAgentRoutes(Router router, String pathPrefix, JSONRPCHandler handler) { | ||
| String rpcPath = pathPrefix.isEmpty() ? "/" : pathPrefix; |
There was a problem hiding this comment.
The tenant extraction will conflict with multi-agent routing. extractTenant() reads the normalized path, so a request to POST /myagent would return "myagent" as the tenant. The agent ID prefix needs to be stripped before tenant extraction — registerAgentRoutes should pass the pathPrefix length so extractTenant can skip it, or use a Vert.x path parameter (e.g. /:agentId/*) instead of a fixed path.
Overview
This PR introduces native support for deploying multiple Server Agents within a single Quarkus application instance for the
reference-jsonrpcextension, resolving the operational overhead of 1:1 Kubernetes pod mappings.Fixes #898
Changes
MultiAgentRegistryInterface: Introduced a registry interface that users can implement as a CDI bean to provide a map ofagentIdtoJSONRPCHandler.A2AServerRoutes: The server router now checks for the presence of aMultiAgentRegistry. If found, it iterates over all registered agents and dynamically creates Vert.x routes for/{agentId}and/{agentId}/.well-known/agent-card.json./and/.well-known/agent-card.json).This allows production deployments to scale infinitely to hundreds of agents in a single JVM with zero custom routing code.