Principle:Microsoft Autogen Hierarchical Agent Composition
| Knowledge Sources | |
|---|---|
| Domains | Agent Composition, Hierarchical Systems, Tool Use, Multi-Agent Systems |
| Last Updated | 2026-02-11 00:00 GMT |
Overview
Hierarchical agent composition is the technique of wrapping an agent or a multi-agent team as a callable tool, enabling a parent agent to delegate subtasks to child agents through the standard tool-calling interface.
Description
In multi-agent systems, complex tasks often require orchestration across multiple specialized agents. Hierarchical agent composition addresses this by allowing agents and teams to be treated as tools that a parent agent can invoke. Instead of building custom orchestration logic, the parent agent's LLM decides when to delegate work by calling a tool that internally runs another agent or team.
This approach creates a tree-shaped hierarchy of agents:
- A parent agent has tools in its tool set that represent child agents or teams.
- When the parent's LLM decides to call one of these tools, the framework runs the child agent or team with the tool input as the task.
- The child agent or team processes the task independently, potentially using its own tools, model clients, and sub-agents.
- The child's result is returned to the parent as the tool's output, which the parent's LLM can then reason about.
This pattern enables several powerful capabilities:
- Specialization: Each child agent can be optimized for a specific domain (e.g., a code-writing agent, a research agent, a data analysis agent), and the parent agent selects the right specialist based on the task.
- Encapsulation: The child agent's internal complexity (its tools, prompts, and logic) is hidden behind a simple tool interface. The parent only sees a name, description, and a result.
- Recursive composition: Child agents can themselves have agent tools, creating arbitrary depth hierarchies. A team tool can contain agents that use agent tools, which in turn use team tools, and so on.
- Result mode control: The composition can be configured to return either the full task result (a concatenation of all messages) or just the last message from the child. This controls the verbosity of the information passed back to the parent.
Usage
Use hierarchical agent composition when:
- A single agent cannot handle all aspects of a complex task, and you want specialized agents for different subtasks.
- You want the parent LLM to dynamically decide when and which specialist to invoke, rather than hardcoding the routing logic.
- You need to compose multi-agent teams as reusable components that can be embedded in larger workflows.
- You want to scale complexity by nesting agents without changing the parent agent's fundamental tool-calling architecture.
- You are building supervisor-worker patterns where a coordinating agent delegates to and synthesizes results from worker agents.
Theoretical Basis
Hierarchical agent composition applies the Composite pattern from software design to the agent domain. Each agent or team implements a common task-running interface, and composite nodes (agent tools, team tools) delegate to their children:
PATTERN hierarchical_agent_composition:
AGENT_TOOL wraps a single AGENT:
- name = agent.name
- description = agent.description
- When called with input_text:
1. Create a task message from input_text
2. Run the agent on the task
3. Collect the result (TaskResult with messages)
4. If return_last_message_mode:
Return only the last message's content
5. Else:
Return concatenation of all message contents
TEAM_TOOL wraps a TEAM (group chat):
- name = explicit name (required, since teams may not have meaningful names)
- description = explicit description
- When called with input_text:
1. Create a task message from input_text
2. Run the team on the task (full multi-agent conversation)
3. Collect the TaskResult
4. If return_last_message_mode:
Return only the last message's content
5. Else:
Return concatenation of all message contents
PARENT_AGENT uses AGENT_TOOLs and TEAM_TOOLs like any other tool:
- LLM sees tool schemas for each child
- LLM decides when to delegate
- Framework executes the delegation transparently
The key theoretical insight is that the tool-calling interface is universal. Any computation that accepts a string input and produces a string output can be exposed as a tool. Since agents and teams naturally satisfy this contract (they accept a task and produce a result), they can be seamlessly integrated into the tool-calling ecosystem.
The return value mode (last message vs. full result) addresses the information bandwidth problem. Full results provide maximum context but may overwhelm the parent agent's context window. Last-message mode provides a concise summary at the cost of losing intermediate reasoning steps. The choice depends on the parent agent's needs and the context window constraints.