[Feat]: Support multi-agent composition by registering HostAgent via create_agent as an AgentTool
- Lingua principale
- Shell
- Stelle
- 25.7k
- Fork
- 2.6k
- Merge medio
- 3g 6h
- PR unite (30g)
- 16
Descrizione
### 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
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
The issue references A2A/samples/python/agents/google_adk/agent.py as a starting point. Examine the HostAgent and ADKHostManager classes to understand how to create a remote agent and pass a task_callback. The goal is to wrap the remote agent in an AgentTool and integrate it into a main agent's tool list, enabling multi-layered delegation. Review linked issues #87, #88, and #119 for context on A2A protocol extensions.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- ai-infra-agents
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100