> ## Documentation Index
> Fetch the complete documentation index at: https://docs.definable.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Delegation

> How the leader agent delegates work to team members.

In every execution mode, the leader agent receives auto-injected tools that let it delegate work to members. You do not need to create these tools manually.

## Auto-Injected Tools

| Mode            | Leader tools                                                                                |
| --------------- | ------------------------------------------------------------------------------------------- |
| **coordinate**  | `delegate_to_member(member_name, task)`                                                     |
| **route**       | `route_to_member(member_name)`                                                              |
| **collaborate** | None (all members execute automatically)                                                    |
| **tasks**       | `create_task(title, description, assignee)`, `update_task(task_id, status)`, `list_tasks()` |

## Coordinate Mode

The leader receives member descriptions and decides which ones to involve:

```python theme={null}
team = Team(
    model="gpt-4o",
    members=[researcher, writer, editor],
    mode=TeamMode.coordinate,
)
```

1. Leader sees each member's name and instructions.
2. Leader calls `delegate_to_member` for each selected member.
3. Each member runs with the delegated task.
4. Leader synthesizes all responses into a final output.

## Route Mode

The leader classifies the request and routes to exactly one member:

```python theme={null}
team = Team(
    model="gpt-4o",
    members=[tech_support, billing_support, general_support],
    mode=TeamMode.route,
)
```

1. Leader sees member descriptions.
2. Leader calls `route_to_member` with the best match.
3. The selected member's response is returned directly (no synthesis).

## Tasks Mode

The leader decomposes work into a task list and delegates autonomously:

```python theme={null}
team = Team(
    model="gpt-4o",
    members=[researcher, designer, developer],
    mode=TeamMode.tasks,
    max_iterations=10,
)
```

1. Leader calls `create_task` for each subtask.
2. Leader assigns tasks to members via delegation.
3. Tasks complete and the leader creates follow-up tasks as needed.
4. Loop continues until all tasks are done or `max_iterations` is reached.

## Sharing Context

Enable `share_member_interactions` to pass member responses to subsequent delegations:

```python theme={null}
team = Team(
    model="gpt-4o",
    members=[researcher, writer],
    mode=TeamMode.coordinate,
    share_member_interactions=True,  # writer sees researcher's output
)
```

Without this, each member only sees the leader's delegation message.
