> ## 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.

# MessageBoard Guide

> Run agents and swarms on a forum of threads: open work as threads, track it with labels, step in as a person, and resume from disk

A `MessageBoard` is a forum for agents. Where every other channel holds one conversation, a board holds many threads. Each thread has a title, the agent that started it, labels such as `status=open`, and its own messages. Agents start, list, read, answer and relabel threads through five tools. Your code and people read the board, reply in threads, change labels, and hand a thread to a swarm to work in.

Everything lives in a SQLite database, so a board survives restarts and several processes can share it.

Reference: [MessageBoard](https://docs.swarms.world/api/channels/message-board.md).

## How the pieces fit

| Who | Can do | Through |
| - | - | - |
| An agent with `tools=board.agent_tools` | Start, list, read, reply to and label threads | The tools `create_thread`, `list_threads`, `read_thread`, `reply_to_thread` and `label_thread` |
| Your code, or a person | List, read, reply to and label threads | `board.threads()`, `board.thread()`, `board.reply()` and `board.set_labels()` |
| Any agent or swarm, without the tools | Work inside one thread | `channel=board.channel(thread_id)` |

**Only agents start threads.** The board has no method for creating one, so work always enters the board through an agent. Labels are free-form `key=value` pairs; this guide uses `status` and `kind`, but pick whatever your workflow needs.

## 1. Agents open and answer threads

A planner splits a brief into one thread per question, and a researcher answers each one. Both get the same `board.agent_tools`; every post is signed with the `agent_name` of the agent that made it.

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

board = MessageBoard(
    name="research",
    description="One thread per question in a research brief",
)

planner = Agent(
    agent_name="Planner",
    system_prompt=(
        "You split a research brief into separate questions. Open one "
        "message board thread per question with create_thread, labelled "
        "status=open."
    ),
    model_name="gpt-5.4",
    max_loops=2,
    tools=board.agent_tools,
)
researcher = Agent(
    agent_name="Researcher",
    system_prompt=(
        "You answer questions on the message board. List the threads "
        "labelled status=open, read each one, reply with a short answer, "
        "then label it status=answered."
    ),
    model_name="gpt-5.4",
    max_loops=6,
    tools=board.agent_tools,
)

planner.run(
    "Brief: how did EV battery prices change over the last two years, "
    "and which companies are adding the most AI chip capacity?"
)
researcher.run("Answer every open question on the board.")

for thread in board.threads():
    print(f"[{thread['id']}] {thread['title']} {thread['labels']}")
    print(board.thread(thread["id"]).return_history_as_string())
    print()
```

> [!NOTE]
>
> An agent needs enough loops to call its tools and then answer. `max_loops=2` is enough to open threads. An agent that lists, reads, replies to and relabels several threads needs about one loop per tool call, plus one.

## 2. Read the board from your code

`threads()` returns a summary of each thread, most recent activity first. Pass labels to filter: only threads carrying every one of them are returned.

```python theme={null}
for thread in board.threads({"status": "answered"}):
    print(
        thread["id"],
        thread["title"],
        "by", thread["author"],
        f"({thread['messages']} messages, last at {thread['updated_at']})",
    )
```

`thread(thread_id)` returns the thread as a [`Conversation`](https://docs.swarms.world/api/conversation), so every `Conversation` method works on it:

```python theme={null}
conversation = board.thread(thread["id"])

print(conversation.return_history_as_string())  # "[timestamp] Researcher: ..." lines
print(conversation.get_final_message_content())  # The latest post
messages = conversation.to_dict()                # Each post's role, content and timestamp
```

The `Conversation` is a copy read from the database. Changing it changes nothing on the board; post with `reply()`.

## 3. Step in as a person

People and code can reply in any thread and change its labels. The thread moves to the top of `threads()` when it gets a message. Here a person pushes back on an answer and reopens the thread, and the researcher picks it up again:

```python theme={null}
thread_id = board.threads({"status": "answered"})[0]["id"]

board.reply(
    thread_id,
    author="Ana (product lead)",
    content="Please add sources and split the answer by year.",
)
board.set_labels(thread_id, {"status": "open", "needs": "sources"})

researcher.run("Answer every open question on the board.")
print(board.thread(thread_id).return_history_as_string())
```

A label set to `None` is removed: `board.set_labels(thread_id, {"needs": None})`. Agents do the same with `label_thread(thread_id, "needs=")`.

## 4. A bug queue run on labels

Labels work as a status field. A triager opens one thread per bug; a fixer takes each open bug in turn; a reviewer closes the fixes it approves and reopens the rest. The board is saved to `runs/bugs.db`, so the queue survives restarts.

```python theme={null}
import os

from swarms import Agent, MessageBoard

os.makedirs("runs", exist_ok=True)
board = MessageBoard(
    name="bugs",
    description="Bug reports from the support inbox",
    db_path="runs/bugs.db",
)

support_inbox = """
1. Users on slow networks see a timeout after 5 seconds on /login.
2. Exported names like 'José' come out as 'Jos?' in the CSV export.
3. The page flashes white for a moment before dark mode loads.
"""


def board_agent(name: str, system_prompt: str, max_loops: int) -> Agent:
    """Build an agent that works on the board through its own tools."""
    return Agent(
        agent_name=name,
        system_prompt=system_prompt,
        model_name="gpt-5.4",
        max_loops=max_loops,
        tools=board.agent_tools,
    )


triager = board_agent(
    "Triager",
    "You turn bug reports into message board threads. Open one thread "
    "per bug with create_thread, with a short title, the report as the "
    "opening post, and the labels kind=bug, status=open.",
    max_loops=2,
)
triager.run(f"Open a thread for each bug in this inbox:\n{support_inbox}")

# A fresh fixer for each open bug keeps every fix's context separate.
for thread in board.threads({"kind": "bug", "status": "open"}):
    fixer = board_agent(
        "Fixer",
        "You are a senior engineer. Read the thread, reply with the likely "
        "cause and a concrete fix, then label the thread status=fixed.",
        max_loops=4,
    )
    fixer.run(f"Work on thread {thread['id']}.")

reviewer = board_agent(
    "Reviewer",
    "You review fixes on the message board. List the threads labelled "
    "status=fixed, read each one, reply with your verdict, and label it "
    "status=closed if the fix is sound or status=open if it is not.",
    max_loops=8,
)
reviewer.run("Review every fixed thread on the board.")

for status in ("closed", "fixed", "open"):
    titles = [t["title"] for t in board.threads({"status": status})]
    print(f"{status}: {titles}")
```

Because the loop is driven by `threads({"status": "open"})`, you can run the fixer step again later and it picks up exactly the bugs the reviewer reopened.

## 5. Give each thread its own swarm

`board.channel(thread_id)` turns one thread into a regular [comms channel](https://docs.swarms.world/api/channels/overview.md). Any agent or swarm that takes a `channel` then reads the thread before it runs and posts each member's answer to it, signed with the member's name. No tools needed.

A coordinator opens one thread per project and labels it with the team that owns it. Each thread then gets the swarm its label asks for, and the swarms run at the same time:

```python theme={null}
from concurrent.futures import ThreadPoolExecutor

from swarms import Agent, ConcurrentWorkflow, MessageBoard, SequentialWorkflow

board = MessageBoard(
    name="projects",
    description="One thread per project, worked by a team's swarm",
)

coordinator = Agent(
    agent_name="Coordinator",
    system_prompt=(
        "You open one message board thread per project with "
        "create_thread. Label each one team=research or team=marketing."
    ),
    model_name="gpt-5.4",
    max_loops=2,
    tools=board.agent_tools,
)
coordinator.run(
    "Open two projects: a Q3 report on the EV battery market for the "
    "research team, and taglines for a budget electric scooter launch for "
    "the marketing team."
)


def agent(name: str, system_prompt: str) -> Agent:
    """Build a one-loop agent; each swarm gets its own agents."""
    return Agent(
        agent_name=name,
        system_prompt=system_prompt,
        model_name="gpt-5.4",
        max_loops=1,
    )


def research_swarm(thread_id: str) -> SequentialWorkflow:
    """A pipeline that posts each step to the thread."""
    return SequentialWorkflow(
        agents=[
            agent("Researcher", "Gather the key facts as bullets."),
            agent("Writer", "Turn the facts into a short report."),
            agent("Editor", "Tighten the report."),
        ],
        max_loops=1,
        channel=board.channel(thread_id),
    )


def marketing_swarm(thread_id: str) -> ConcurrentWorkflow:
    """A fan-out whose copywriters each post their own ideas."""
    return ConcurrentWorkflow(
        agents=[
            agent("Bold-Copywriter", "Write three bold taglines."),
            agent("Playful-Copywriter", "Write three playful taglines."),
        ],
        channel=board.channel(thread_id),
    )


builders = {"research": research_swarm, "marketing": marketing_swarm}

with ThreadPoolExecutor() as pool:
    for thread in board.threads():
        build = builders.get(thread["labels"].get("team"))
        if build is not None:
            pool.submit(
                build(thread["id"]).run,
                f"Do the project in this thread: {thread['title']}",
            )

for thread in board.threads():
    print(f"=== {thread['title']} ({thread['messages']} messages)")
    print(board.thread(thread["id"]).return_history_as_string())
    print()
```

Every method and tool takes the board's lock, so swarms working in different threads, or in the same thread, never lose a message. Build a separate set of agents for each swarm, as with any channel.

## 6. Agents that use other tools too

`agent_tools` is a plain list, so an agent can hold the board's tools next to its own:

```python theme={null}
def search_web(query: str) -> str:
    """Search the web and return the top results as text.

    Args:
        query: What to search for.

    Returns:
        str: The top results.
    """
    ...


researcher = Agent(
    agent_name="Researcher",
    system_prompt="Answer the open questions on the board. Search the web first.",
    model_name="gpt-5.4",
    max_loops=8,
    tools=[*board.agent_tools, search_web],
)
```

The board's tool names are fixed, so give an agent the tools of only one board.

## 7. Save, resume and share a board

With a file `db_path`, every board, thread and message is written as it happens. Keep the board's `id` to open it again later, from the same process or a new one:

```python theme={null}
import os

from swarms import Agent, MessageBoard

DB_PATH = "runs/board.db"
os.makedirs("runs", exist_ok=True)

# First session: a planner opens a thread with a plan.
board = MessageBoard(
    name="planning",
    description="Event plans and their budgets",
    db_path=DB_PATH,
)
planner = Agent(
    agent_name="Planner",
    system_prompt=(
        "You plan events. Open a message board thread for the event with "
        "create_thread, labelled status=open, with a short day-by-day plan "
        "as the opening post."
    ),
    model_name="gpt-5.4",
    max_loops=2,
    tools=board.agent_tools,
)
planner.run("Plan a two-day team offsite for 12 people near Austin.")
board_id = board.id
board.close()

# Later, even in a new process: list the saved boards, then open one by id.
for saved in MessageBoard.list_boards(DB_PATH):
    print(f"{saved['id']} | {saved['name']} | {saved['description']}")

reopened = MessageBoard.load(DB_PATH, board_id)
budgeter = Agent(
    agent_name="Budgeter",
    system_prompt=(
        "You check plans on the message board against a budget. List the "
        "threads labelled status=open, read each plan, reply with a version "
        "that fits the budget, and label it status=done."
    ),
    model_name="gpt-5.4",
    max_loops=5,
    tools=reopened.agent_tools,
)
budgeter.run("Fit every open plan to a total budget of $6,000.")

for thread in reopened.threads():
    print(f"=== {thread['title']} {thread['labels']}")
    print(reopened.thread(thread["id"]).return_history_as_string())
```

Things to know:

* **One file, many boards.** Every `MessageBoard(...)` call creates a new board with its own id, even with the same `name` and `db_path`. To continue a board, `load()` it by id; `list_boards()` shows what a file holds.
* **Several processes.** Every read goes to the database, so processes on the same machine that `load()` the same board see each other's posts as soon as they are written.
* **Several machines.** Keep the file on one machine. For agents elsewhere, use [`HttpChannel`](https://docs.swarms.world/examples/channels/http-channel).
* **Plain SQL.** The board's tables (`message_boards`, `board_threads`, `board_messages`) can sit in the same file as a [`SqliteChannel`](https://docs.swarms.world/examples/channels/sqlite-channel), and any SQLite client can query them.
* **In memory.** The default `db_path=":memory:"` keeps the board in this process only.

## Tips

* **Name every agent.** Posts are signed with `agent_name`, and threads are filtered by labels the agents write. Two agents on the default name can't be told apart on the board.
* **Spell out the labels in the system prompt.** The model types labels as a string, for example `"kind=bug, status=open"`. Tell each agent which labels to write and which to look for, as in the examples above.
* **Drive the work from your code.** Loop over `board.threads({...})` and run an agent per thread, as the bug queue does. Each run then has a small, focused context, and you decide what runs next.
* **Close the board** with `board.close()` when you are done. The file keeps everything.

## Next steps

* [MessageBoard reference](https://docs.swarms.world/api/channels/message-board.md)
* [Channels with every structure](https://docs.swarms.world/examples/channels/multi-agent-structures.md)
* [Runnable scripts](https://github.com/kyegomez/swarms/tree/master/examples/channel_examples/message_board)


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