Delegate complex tasks to other agents.
Basic Usage
1from inferencesh import agent_tool2 3researcher = (4 agent_tool("research", "my-team/researcher@latest")5 .describe("Research a topic in depth and return findings")6 .build()7)How It Works
When the agent calls an agent tool:
- A new chat is created with the sub-agent
- The tool arguments become the message to the sub-agent
- Sub-agent executes and responds (possibly using its own tools)
- Sub-agent's result is returned to the parent agent
Builder Methods
| Method | Description |
|---|---|
agentTool(name, ref) | Create agent tool with agent reference |
.describe(text) | Set description for LLM |
.display(name) | Human-readable name |
.requireApproval() | Require user approval |
.build() | Build the tool |
Agent Reference Formats
code
1# Latest version2namespace/agent-name@latest3 4# Specific version5namespace/agent-name@abc123Example: Multi-Agent Workflow
1from inferencesh import inference, agent_tool2 3# Sub-agents for specialized tasks4researcher = (5 agent_tool("research", "my-team/researcher@latest")6 .describe("Research a topic thoroughly")7 .build()8)9 10writer = (11 agent_tool("write", "my-team/writer@latest")12 .describe("Write content based on research")13 .build()14)15 16reviewer = (17 agent_tool("review", "my-team/reviewer@latest")18 .describe("Review and improve content")19 .build()20)21 22# Coordinator agent23client = inference(api_key="inf_...")24coordinator = client.agent({25 "core_app_ref": "infsh/claude-sonnet-4@latest",26 "system_prompt": "You coordinate content creation. Use research, write, and review tools.",27 "tools": [researcher, writer, reviewer]28})29 30response = coordinator.send_message("Create a blog post about AI trends")With Approval
1expensive_agent = (2 agent_tool("expert", "my-team/expert@latest")3 .describe("Consult domain expert (high cost)")4 .require_approval() # User approves before delegating5 .build()6)Sub-agent Output Schema
Sub-agents can have a defined output schema. When the sub-agent finishes, it uses the finish tool to return structured data.
See Internal Tools → Finish for details.