a2aproject / a2aproject/A2A

[Feat]: Support multi-agent composition by registering HostAgent via create_agent as an AgentTool

Open
#563 4 comments 0 reactions 1 assignee Claimed by @rajeshvelicheti View on GitHub
enhancement In Progress
Dominant language
Shell
Stars
25.7k
Forks
2.6k
Avg merge
3d 6h
Merged PRs (30d)
16

Description

### Is your feature request related to a problem? Please describe.

While multi-agent composition is possible using tools like google_adk, existing implementations do not yet demonstrate how the A2A protocol can be used in a multi-layered or recursive fashion—i.e., chaining agent-to-agent calls across multiple levels.

This feature request stems from our successful implementation of such an architecture: a remote agent is created via HostAgent(...).create_agent() and registered as an AgentTool in the main agent. The main agent can then delegate queries to the remote agent, effectively enabling a multi-stage A2A composition that had not been previously demonstrated.

This implementation also complements the ideas discussed in https://github.com/google/A2A/issues/87, https://github.com/google/A2A/issues/88, and https://github.com/google/A2A/issues/119, where various extensions of the A2A protocol are proposed. Our work provides a practical example of how these ideas can be realized in a multi-agent setting.

### Describe the solution you'd like

We would like to see official support and documentation for a pattern where a remote agent—instantiated via HostAgent(...).create_agent()—can be wrapped with AgentTool and included in the main agent’s tool list. This enables the root agent to delegate queries to the remote agent using the A2A protocol, allowing for dynamic, multi-layered agent compositions.

To make this work reliably in streaming scenarios (where tasks were not being generated as expected), we explicitly created an ADKHostManager instance and passed its task_callback to the HostAgent. This ensures proper handling of streamed outputs from the remote agent.

Here’s a simplified example:

A2A/samples/python/agents/google_adk/agent.py

```
adkHostManager = ADKHostManager()
self.client_agent = HostAgent(
["{remote_agent_url}"],
adkHostManager.task_callback,
).create_agent()

# Register as AgentTool
tools = [
agent_tool.AgentTool(agent=self.client_agent),
]
```
This approach demonstrates how recursive A2A-based delegation can be implemented. It complements and extends ideas proposed in https://github.com/google/A2A/issues/87, https://github.com/google/A2A/issues/88, and https://github.com/google/A2A/issues/119, offering a concrete path toward more robust, modular multi-agent systems.

### Describe alternatives you've considered

_No response_

### Additional context

_No response_

### Code of Conduct

- [x] I agree to follow this project's Code of Conduct

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.