# Agent Tools

> Delegate complex tasks to other agents.

**URL:** https://inference.sh/docs/api/agent/agent-tools
**Last updated:** 2026-09-18

---

Delegate complex tasks to other agents.

---

## Basic Usage

<div data-type="codegroup">

```python Python
from inferencesh import agent_tool

researcher = (
    agent_tool("research", "my-team/researcher@latest")
    .describe("Research a topic in depth and return findings")
    .build()
)
```

```typescript JavaScript
import { agentTool } from '@inferencesh/sdk';

const researcher = agentTool('research', 'my-team/researcher@latest')
  .describe('Research a topic in depth and return findings')
  .build();
```

</div>

---

## How It Works

When the agent calls an agent tool:
1. A new chat is created with the sub-agent
2. The tool arguments become the message to the sub-agent
3. Sub-agent executes and responds (possibly using its own tools)
4. 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

```
# Latest version
namespace/agent-name@latest

# Specific version
namespace/agent-name@abc123
```

---

## Example: Multi-Agent Workflow

<div data-type="codegroup">

```python Python
from inferencesh import inference, agent_tool

# Sub-agents for specialized tasks
researcher = (
    agent_tool("research", "my-team/researcher@latest")
    .describe("Research a topic thoroughly")
    .build()
)

writer = (
    agent_tool("write", "my-team/writer@latest")
    .describe("Write content based on research")
    .build()
)

reviewer = (
    agent_tool("review", "my-team/reviewer@latest")
    .describe("Review and improve content")
    .build()
)

# Coordinator agent
client = inference(api_key="inf_...")
coordinator = client.agent({
    "core_app": { "ref": "infsh/claude-sonnet-4@latest" },
    "system_prompt": "You coordinate content creation. Use research, write, and review tools.",
    "tools": [researcher, writer, reviewer]
})

response = coordinator.send_message("Create a blog post about AI trends")
```

```typescript JavaScript
import { inference, agentTool } from '@inferencesh/sdk';

// Sub-agents for specialized tasks
const researcher = agentTool('research', 'my-team/researcher@latest')
  .describe('Research a topic thoroughly')
  .build();

const writer = agentTool('write', 'my-team/writer@latest')
  .describe('Write content based on research')
  .build();

const reviewer = agentTool('review', 'my-team/reviewer@latest')
  .describe('Review and improve content')
  .build();

// Coordinator agent
const client = inference({ apiKey: 'inf_...' });
const coordinator = client.agent({
  core_app: { ref: 'infsh/claude-sonnet-4@latest' },
  system_prompt: 'You coordinate content creation. Use research, write, and review tools.',
  tools: [researcher, writer, reviewer]
});

const response = await coordinator.sendMessage('Create a blog post about AI trends');
```

</div>

---

## With Approval

<div data-type="codegroup">

```python Python
expensive_agent = (
    agent_tool("expert", "my-team/expert@latest")
    .describe("Consult domain expert (high cost)")
    .require_approval()  # User approves before delegating
    .build()
)
```

```typescript JavaScript
const expensiveAgent = agentTool('expert', 'my-team/expert@latest')
  .describe('Consult domain expert (high cost)')
  .requireApproval()
  .build();
```

</div>

---

## 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](/docs/api/agent/internal-tools#finish-tool) for details.
