Skip to content

Chats and threads

Markdown

Every agent is its chat plus its threads.

The owner talks to an agent in its chat, and other agents send it work there. A chat does no work itself and has no work tools. A chat turn takes at most 4 steps, deciding where the work goes, in this order:

  1. If it can answer from what it knows, its memory or a thread’s answer, it answers.
  2. If a thread holds the work, it sends it there with message_thread, even a thread that stopped or is idle: the thread keeps everything it did and goes on from there.
  3. If it’s another agent’s job, it hands it off with hand_off. Roadstar’s chat makes an agent first if no agent’s job covers lasting work like it.
  4. Otherwise it starts a thread with start_thread.
  5. If it’s unclear, it asks the owner one question.

After sending work, the chat says in a few words where it went, and stops. The thread’s answer reaches the owner on its own.

A thread is a long-lived workstream: one per client, project or job, such as “Juniper Dental”. Each thread is its own actor with its own memory, and it does the work with every tool. It finishes with one answer, which goes back to whoever asked.

  • Fresh threads start empty, with the packet: the task, notes and links. Start fresh unless the work needs the chat’s conversation.
  • Fork threads start from the chat’s memory.

A thread can’t start threads. It hands work to other agents with hand_off, and their answers come back to it.

Independent parts of one piece of work get a thread each. When their answers make one answer, give each the same andThen: the chat answers once, when the last is in.

A thread takes up to 40 steps on one piece of work, then answers with what it has. An agent keeps up to 30 open threads, and only a few run at once: the rest wait their turn. Close a thread whose work is over with close_thread: it stays readable, and a message reopens it. The exact numbers are on limits.

Each routine has a thread of its own, named after it, and every run goes there, so it remembers the runs before it. See routines and skills.

Threads has start_thread, message_thread, read_thread and close_thread, with their inputs.