What is a thread?
A thread is the persisted conversation or work history an agent can use to continue from where it left off. In MeshAgent, a thread is stored as a Room sync document. It is the durable state behind things like:- an ongoing chat with a
ChatBot - a resumable
TaskRunnerworkflow - a
Workerjob history you want to keep and revisit
- Session/context is the in-memory state for the current run
- Thread is the persisted state that future runs can reload
Threads vs rooms, sessions, tools, and skills
These concepts work together, but they are not the same:- Room: the shared collaboration environment where people, agents, files, tools, and documents live
- Session/context: the current in-memory LLM conversation state for one run
- Thread: the persisted transcript or work log that an agent session can resume from
- Tool: a callable capability such as storage, shell, or web search
- Skill: reusable guidance that helps an agent decide how to approach a task
- Sessions are live
- Threads persist
What lives in a thread?
A MeshAgent thread can store more than plain chat text. A thread can contain:- user and assistant messages
- file attachments
- tool and command output
- reasoning summaries
- UI events
- generated images and related status
- a memory source for future agent runs
- a durable audit trail of what happened
Do all agents use threads?
No. Different agents use threads in different ways.ChatBot
ForChatBot, threads are the normal model. A chat conversation is typically backed by a thread path, and the agent reopens that thread to reload prior history and continue the conversation.
If a chat UI supports multiple conversations, each conversation is usually a different thread.
TaskRunner
TaskRunner does not have to use threads. It can run as a clean, one-off invocation with no persisted conversation state.
If you enable threading, a TaskRunner can write its work into a thread and resume from that thread later.
Use this when you want a structured agent invocation to be resumable or inspectable over time.
Worker
Worker also does not have to use threads. A worker can simply process queue messages and return results with fresh context each time.
If you enable threading, the worker can persist the work into thread documents so jobs have durable history.
Use this when queued work should leave behind a readable log, or when later work should build on earlier work.
When should I think about threads?
You should think about threads when you want:- conversations to continue across turns or sessions
- a user or agent to reopen earlier work
- multiple runs to build on the same history
- an auditable record of tool use, outputs, or reasoning
- multiple agents to collaborate through shared persisted state
- every run should start fresh
- the output is purely one-shot
- there is no need to reopen or inspect the history later
Shared threads
Agents can share threads. This is not a separate special feature or agent mode. It simply means that multiple agents or clients read from and write to the same thread path. That is useful when:- a conversational agent and a background agent should collaborate on the same work
- one agent creates work and another agent continues it
- you want a user-facing conversation and background processing to stay in one shared history
- same thread path = same persisted history
What is a thread directory?
A thread directory is a path prefix used to organize many thread documents together. For example:- one
.threadfile per conversation or work item - one
index.threadlfile that lists the known threads
Example: ChatBot with thread-related CLI flags
Here is a simpleChatBot command that enables a thread-aware chat UI and stores its thread documents under a dedicated thread directory:
bash
--threading-mode default-new: tells chat UIs to treat this agent as thread-oriented and to show a new-thread composer before loading an existing thread--thread-dir ".threads/support-bot": tells the agent where its thread documents and thread list should live in Room sync/storage
- one chatbot should support many separate conversations
- you want a UI to show a thread list
- you want to keep this agent’s threads separate from other agents in the same Room
--thread-dir, the ChatBot CLI will choose a default thread directory for you. If you omit thread-related settings entirely, you can still chat with the agent, but you are no longer explicitly configuring thread list behavior or thread organization.
What is index.threadl?
index.threadl is the thread list document for a thread directory.
It is not the source of truth for the thread contents. The .thread files hold the actual history. The index exists so UIs and agents can:
- list available threads
- sort them by recent activity
- show readable names
- open a thread by path
.threadstores the conversation or work itselfindex.threadlstores the list of threads
How UIs use threads
Many chat-style UIs need two things:- a thread list
- a selected thread path
index.threadl, and the selected conversation comes from a specific .thread path.
This is why thread directories matter most for conversational agents like ChatBot: they let a UI show many conversations instead of only one.
Choosing the right model
Use one of these mental models:- No thread: best for isolated, one-off work
- One thread per user/agent pair: best for simple persistent chat
- One thread per task or case: best for work that evolves over time
- One shared thread across agents: best for collaboration on the same persisted history
- A thread directory with many threads: best for multi-conversation chat UIs
Where to go next
- ChatBot: the main thread-oriented conversational agent
- TaskRunner: structured invocations that can optionally persist to threads
- Worker: queue-driven processing with optional thread persistence
- Key Concepts: Rooms, agents, tools, and services