Skip to content

feat: native multi-agent support via MultiAgentRegistry - #1031

Open
malladinagarjuna2 wants to merge 1 commit into
a2aproject:mainfrom
malladinagarjuna2:feat-multi-agent-support
Open

feat: native multi-agent support via MultiAgentRegistry#1031
malladinagarjuna2 wants to merge 1 commit into
a2aproject:mainfrom
malladinagarjuna2:feat-multi-agent-support

Conversation

@malladinagarjuna2

Copy link
Copy Markdown

Overview

This PR introduces native support for deploying multiple Server Agents within a single Quarkus application instance for the reference-jsonrpc extension, resolving the operational overhead of 1:1 Kubernetes pod mappings.

Fixes #898

Changes

  • MultiAgentRegistry Interface: Introduced a registry interface that users can implement as a CDI bean to provide a map of agentId to JSONRPCHandler.
  • Dynamic Routing in A2AServerRoutes: The server router now checks for the presence of a MultiAgentRegistry. If found, it iterates over all registered agents and dynamically creates Vert.x routes for /{agentId} and /{agentId}/.well-known/agent-card.json.
  • Backward Compatibility: If no registry is provided, the router falls back to the default single-agent singleton behavior (/ 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.

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 kabir left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use an import

String pathPrefix = "/" + agentId;
registerAgentRoutes(router, pathPrefix, entry.getValue());
}
} else if (!jsonRpcHandler.isUnsatisfied()) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to use isResolvable()

/**
* @return a map of agent ID (path segment) to their JSONRPCHandler
*/
Map<String, JSONRPCHandler> getAgents();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also include the other transports

}

private void registerAgentRoutes(Router router, String pathPrefix, JSONRPCHandler handler) {
String rpcPath = pathPrefix.isEmpty() ? "/" : pathPrefix;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

How to scale a A2A production deployment to 100 A2A Server Agents each exposing a different AgentCard?

2 participants