Overview
Every other channel is a single conversation.MessageBoard holds many threads, like a forum. A board has a name, a description and a unique id. Each thread has:
- a title;
- the agent that started it;
- labels such as
status=open; - its own messages.
board.agent_tools is a list of five functions that you pass straight in as Agent(tools=board.agent_tools). Every agent can get the same list; each one signs its threads and replies with its own agent_name. With them, the agent can:
- start threads;
- list and read them;
- reply to them;
- relabel them.
Import
Constructor
MessageBoard.load().
The SQLite file that holds the board, created if missing. Every change is written to it at once.
":memory:" keeps the board in this process only and writes nothing to disk.Attributes
Tables
The board creates three tables in the file. It leaves any other tables alone, so it can share a file with aSqliteChannel.
Agent tools
agent_tools
The tools agents use to work on the board, as a property.tools=board.agent_tools, or add your own tools next to it with tools=[*board.agent_tools, search_web]. When an Agent sets up its tools, it binds these to its own agent_name, so every thread and reply is signed with the name of the agent that posted it. Called outside an agent, create_thread and reply_to_thread post nothing and return a message saying so. Use reply() to post from your own code.
Each tool returns plain text for the model. A tool given an unknown thread id returns No thread '<id>' on board '<name>' instead of raising.
Labels are written as comma-separated
key=value pairs, for example "kind=bug, status=open", so the model can type them as a plain string.
An agent needs enough loops to use its tools and then answer. Give
max_loops=2 to an agent that only starts threads. An agent that lists, reads, replies to and labels several threads needs more. The tool names are fixed, so give an agent the tools of only one board.Methods
These are for your own code and for people. None of them creates a thread.load()
Open a board saved in a database file, by its id.KeyError if the file has no board with that id.
list_boards()
List the boards saved in a database file, oldest first. Each entry hasid, name, description and created_at.
threads()
List threads, most recent activity first. A thread’s activity is its last message, soset_labels() does not change the order.
labels, only threads that carry every one of those labels are returned. Each entry is a new dict:
thread()
Return a thread’s messages as aConversation, read from the database, so you can use any Conversation method on it, such as return_history_as_string() or to_messages(). Each message’s timestamp is when it was posted. The Conversation is a copy: changes to it are not saved, so post with reply().
reply()
Add a message to a thread. The thread moves to the top ofthreads(). Use it for a person’s reply.
set_labels()
Set or remove labels on a thread. A value ofNone removes that label.
channel()
Return one thread as aBoardThreadChannel, a regular comms channel. Use it to let an agent or swarm that does not hold the tools work in a thread an agent opened.
post(agent_name, content) calls board.reply(). Its messages() returns the thread’s messages as {"agent_name": ..., "content": ...} rows, oldest first. It has no clear().
thread(), reply(), set_labels() and channel() raise KeyError for an id the board doesn’t hold.
close()
Close the database connection. The file keeps every board, thread and message.Swarms in threads
Every method and tool takes the board’s lock. So agents and swarms running in different threads can post to the same board, or the same thread, without losing messages. Each swarm should have its own agents, as with any channel.db_path, processes on the same machine that load() the same board see each other’s posts as soon as they are written. To share a board across machines, keep the file on one machine and use HttpChannel for remote agents.
Saving and resuming
Examples
The channel examples include fourmessage_board_*.py scripts:
- agents that open and answer threads;
- a bug queue run on labels;
- two swarms working in threads at once;
- a board resumed from disk.