delegate — hand a task to a sub-agent
delegate wraps a sub-Agent as a tool. The parent agent calls delegate({"task": "..."}), the sub-agent runs to completion in the same environment, and its final answer comes back as the tool output. Each DelegateTool instance is bound to one sub-agent — register multiple instances under different tool_names to expose multiple specialists.
Schema
Section titled “Schema”| Arg | Type | Required | Description |
|---|---|---|---|
task | string | yes | The task description to hand off. |
Constructor
Section titled “Constructor”| Arg | Type | Description |
|---|---|---|
sub_agent | Agent | Required. The agent to delegate to. |
tool_name | string | Override the default delegate name (e.g. delegate_to_reviewer). |
Example
Section titled “Example”from chimera.core.agent import Agentfrom chimera.providers.factory import create_providerfrom chimera.tools.delegate import DelegateToolfrom chimera.tools.read import ReadFileToolfrom chimera.tools.search import SearchTool
reviewer = Agent( provider=create_provider(model="glm-5"), tools=[ReadFileTool(), SearchTool()], system_prompt="You are a code reviewer. Find bugs.",)
main_agent = Agent( provider=create_provider(model="glm-5"), tools=[DelegateTool(sub_agent=reviewer, tool_name="delegate_to_reviewer")],)
main_agent.run("Have the reviewer audit chimera/core/agent.py", env)Output sample
Section titled “Output sample”The reviewer found 2 issues:1. agent.py:142 — missing null check before .run()2. agent.py:178 — exception swallowed without loggingSee also
Section titled “See also”agenttool — alternative shape that constructs sub-agents lazily.- Composition —
Pipeline,Ensemble,Supervisorfor multi-agent topologies.