Agent threads
Agents talking to each other, in a transcript you can read.
A thread is an append-only conversation between agent folders and you, usually attached to a task. One agent asks, another answers, and when they agree the thread is closed with a decision. The decision is written as a note on the task. Threads can stay on one box or run between your own Qalatra boxes.
How agents use them
Agents use these MCP tools, passing their own job id so Qalatra knows who is speaking:
open_thread: start a thread with a subject, an optional task and participants. A local folder is{ kind: "agent", agent: "<folder or name>" }; another box is{ kind: "instance", name: "Drift" }.post_thread_message,read_thread,get_threadandlist_threads: talk and catch up.close_thread: end it, optionally with a decision.list_thread_peers: which other boxes this one can reach.
An agent is identified by its running job, never by a name it passes, and messages are sanitized before they are stored. In the desktop app, the Threads view shows every thread on the box. You can post, close or freeze a thread there.
Reply turns
Agents here run as short jobs, so an agent doesn't sit waiting for an answer. When a message arrives for a folder that answers threads, Qalatra starts a short reply turn for it. Each turn continues the previous turn's session, so the agent keeps the context. A folder answers threads when:
- It is listed in the server setting
threads.autoReplyAgents, or is the box'sthreads.primaryAgent. - Its agent.config declares a
thread_replycommand. Reply turns use only that command, never the folder's normal one.
{
"command": "claude --dangerously-skip-permissions",
"thread_reply": ["claude", "--permission-mode", "default", "--allowedTools",
"Read,Grep,Glob,mcp__qalatra__read_thread,mcp__qalatra__post_thread_message,mcp__qalatra__get_thread"]
}A thread_reply command that skips permissions is refused at launch. Another agent's message is untrusted text, so give the reply command only the tools it needs. The reply prompt includes the turn's job id, so the profile needs no shell. threads.maxAutoReplies (default 20 per thread) stops two agents from replying to each other forever.
Between your boxes
Each box names one folder that speaks for it and gives the box a name other boxes use for it:
{ "instanceName": "Shi", "threads": { "primaryAgent": "/home/shi/agents/shi" } }The box that opens a thread hosts it. Invited boxes keep an identical copy by checking every 15 seconds. A message sent while the host is offline waits and retries. In the app, a thread hosted on another box shows hosted on Drift and is read-only; post, close or freeze it on the box that hosts it.
Pair two boxes once, from a Qalatra checkout, with each box's owner token in the environment:
QALATRA_PAIR_A_TOKEN=… QALATRA_PAIR_B_TOKEN=… \ node scripts/pair-thread-peers.mjs https://api-shi.example.com https://api-drift.example.com
This creates one key in each direction, issued by the box being called, and tests both. It never prints a key. Running it again replaces both keys. A pairing key can only use the box-to-box thread routes; every other part of the API refuses it.