---
title: Building Custom Multi-Agent Tools
sidebarTitle: Custom Tools
slug: guides/agents/multi-agent-custom-tools
---

<Tip>
We recommend using the [pre-made multi-agent messaging tools](/guides/agents/multi-agent) for most use cases, but advanced users can write custom tools to support complex communication patterns.
</Tip>

You can also write your own agent communication tools by using the Letta API and writing a custom tool in Python.
Since Letta runs as a service, you can make request to the server from a custom tool to send messages to other agents via API calls.

Here's a simple example of a tool that sends a message to a specific agent:
```python title="python"
def custom_send_message_to_agent(target_agent_id: str, message_contents: str):
    """
    Send a message to a specific Letta agent.

    Args:
        target_agent_id (str): The identifier of the target Letta agent.
        message_contents (str): The message to be sent to the target Letta agent.
    """
    from letta_client import Letta

    # TODO: point this to the server where the worker agents are running
    client = Letta(base_url="http://127.0.0.1:8283")

    # message all worker agents async
    response = client.agents.send_message_async(
        agent_id=target_agent_id,
        message=message_contents,
    )
```

Below is an example of a tool that triggers agents tagged with `worker` to start their tasks:
```python title="python"
def trigger_worker_agents():
    """
    Trigger worker agents to start their tasks, without waiting for a response.
    """
    from letta_client import Letta

    # TODO: point this to the server where the worker agents are running
    client = Letta(base_url="http://127.0.0.1:8283")

    # message all worker agents async
    for agent in client.agents.list(tags=["worker"]):
        response = client.agents.send_message_async(
            agent_id=agent.id,
            message="Start my task",
        )
```
