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

# Comms Channels

> Give agents and swarms a shared conversation that lives in a file, a queue, a database, a server or an email thread

A comms channel is a conversation that lives outside the agent. Every agent or swarm given the same channel reads what was said there before it runs and posts what it says after. Swap the channel and the same code keeps its conversation in a different place.

```python theme={null}
from swarms import Agent, FileChannel

channel = FileChannel("runs/ev_report.md")

researcher = Agent(agent_name="Researcher", model_name="gpt-5.4", max_loops=1, channel=channel)
writer = Agent(agent_name="Writer", model_name="gpt-5.4", max_loops=1, channel=channel)

task = "Report on the EV battery market."
researcher.run(task)
writer.run(task)  # Reads the Researcher's answer from the file first
```

## Pick a channel

> [card] [FileChannel](https://docs.swarms.world/examples/channels/file-channel.md)
>
> A markdown file you can read, edit and resume from.

> [card] [QueueChannel](https://docs.swarms.world/examples/channels/queue-channel.md)
>
> Watch every message the moment it is posted, without polling.

> [card] [SqliteChannel](https://docs.swarms.world/examples/channels/sqlite-channel.md)
>
> Many conversations in one database, safe for concurrent writers.

> [card] [HttpChannel](https://docs.swarms.world/examples/channels/http-channel.md)
>
> One conversation shared by agents on different machines.

> [card] [SmtpChannel](https://docs.swarms.world/examples/channels/smtp-channel.md)
>
> An email thread in your own mailbox that people can reply to.

> [card] [AgentMailChannel](https://docs.swarms.world/examples/channels/agentmail-channel.md)
>
> An email thread in an AgentMail inbox, through its API.

## Channels with multi-agent structures

Nine structures and `SwarmRouter` take a `channel` argument. The structure posts the task and each member's contribution under that member's name. See [Channels with every structure](https://docs.swarms.world/examples/channels/multi-agent-structures.md) for one example of each.

```python theme={null}
from swarms import Agent, SequentialWorkflow, SqliteChannel

workflow = SequentialWorkflow(
    agents=[
        Agent(agent_name="Researcher", model_name="gpt-5.4", max_loops=1),
        Agent(agent_name="Writer", model_name="gpt-5.4", max_loops=1),
    ],
    max_loops=1,
    channel=SqliteChannel("channels.db", name="ev-batteries"),
)
workflow.run("Report on the EV battery market.")
```

> [!WARNING]
>
> Give the channel to the structure, not to its agents. A structure with a channel detaches any channel its member agents carry, with a warning, so that nothing is posted twice.

## What every channel does on a run

1. The agent reads every earlier message and sends it to the model as prior turns.
2. It posts the task under its `user_name` (default `Human`), unless the same task is already there.
3. It runs.
4. It posts its final answer under its `agent_name`. A failed run posts nothing.

The full behaviour, the message format and how to write your own channel are in the [CommsChannel reference](https://docs.swarms.world/api/channels/overview.md).

## Prerequisites

```bash theme={null}
pip install -U swarms
export OPENAI_API_KEY="sk-..."
```

The examples use `gpt-5.4`. Any model name LiteLLM accepts works.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.