Threads, Leads and the queue
A thread is one agent session (Claude Code, Codex or Copilot CLI) working in a project folder. A project's Lead is a thread that steers the others: it starts them, queues them, messages them and reads what they did. The queue holds threads that should start later, and placement picks the machine each one runs on.
Threads
A thread runs its agent inside herdr-core, a terminal host on each machine, so the session outlives Hive's window and Hive attaches to it again when it opens. Each machine runs a small Hive node that hosts its threads, runs their hooks and keeps its event log.
State. The thread's own machine decides its state: working, idle, waiting for you, suspended, ended or failed. Lists show it with a glyph rather than a coloured dot: a spinner while working, a hand while waiting on you, a warning when it stopped, a clock while queued.
Tasks. A thread takes on pieces of work one after another. It calls task_start with a short title when it
begins one and task_done when it has landed, with a one-sentence outcome, what it landed as (a commit or a
version), or dropped. Other threads, the queue and the Lead can wait on a task.
Cards. A thread reaches you through the deck, and only by its own call: ask for a decision (a question and
two to four answers), present_proof for finished work you need to see or judge (screenshots, a before and after,
a recording, findings). Hive never makes a card on a thread's behalf, and a thread shows as waiting only when it has
asked.
Suspend and resume. A thread idle for 45 minutes (5 once its work has landed) is suspended: its process ends, its conversation stays, and a message resumes it where it was. Threads that are working, waiting on you or running background work are never suspended. Settings ▸ Machines changes the time, or turns it off.
Close and archive. close_thread ends a session but keeps the thread in the list; archive_thread takes it out
of the list and keeps its conversation.
Permission. A thread runs in one of its agent's permission modes: ask, acceptEdits, plan or full. Nothing a thread starts or queues may have more permission than the thread itself.
Leads
Each project has one Lead, on its project page. It's a Claude Code thread like any other, with instructions to know the project and steer its threads. It doesn't change files unless you ask it to; real work goes to a thread.
What it uses, all from Hive's MCP server:
| Tool | Does |
|---|---|
start_thread |
Start a thread now, with a full brief (it starts without the Lead's context). Options: agent, model, effort, permission, cwd (a lane or a folder in the project), on (where it runs) |
queue_thread |
Queue a thread to start once its conditions hold and there's room |
send_to_thread |
Message a thread and, by default, wait up to 3 minutes for its reply |
read_thread, list_threads |
What a thread said and did, and what's waiting on it |
watch_task |
Be told when another thread's task ends, instead of polling |
automate, automations, events |
Be told what passes a filter on the project's events; list those; read the log |
list_queue, update_queue_item, cancel_queue_item |
See and change the queue: reorder, pause, retry, start now |
close_thread, restart_thread |
End a finished thread's session; restart a thread with its conversation |
send_to_lead |
Ask another project's Lead something. Leads may exchange 4 messages before you speak again |
A work thread gets a smaller set. It can start threads and queue them in its own project, at priority 0 or below, and change only items it queued. Reordering the queue, starting an item now and moving threads between machines stay with the Lead.
Watching instead of polling. A Lead doesn't sleep and check. Its default automation tells it when a thread
finishes, asks, fails or goes stale, a task ends, a lane merges or CI fails, and when a machine one of its threads works on goes down or critical. For anything else
it calls automate (or watch_task for one task) and ends its turn, and Hive messages it. A queue item can wait on the same thing with a task condition. See Events and
automation for what else can wake it.
The queue
queue_thread takes the brief and, optionally, a title, agent, model, effort, permission, priority, conditions and
placement. The item waits until all its conditions hold, the pool has room, and a machine fits; then Hive starts
it as its own thread.
{
"prompt": "Update the API docs for the new auth flow. The change is in lane fix-login.",
"title": "Docs for the auth flow",
"conditions": [{ "type": "merged", "lane": "fix-login" }, { "type": "load" }],
"placement": { "on": "auto", "needs": ["linux"] }
}
- Conditions:
load,merged(a lane or a pull request),thread(until itsdoneor its nextturn),item,task,event(a jq filter on the project's bus),after(a time). The table is on Events and automation. - Order. Higher priority starts first; within a priority, the order you dragged them into, then the oldest. Priority defaults to 0; only you and the Lead can set it higher.
- Dispatch. Hive looks every 5 seconds, or at once when something changes, and starts at most one item per look. A start that fails for a reason that may pass is tried up to 3 times. With Hive's window closed, each machine's node runs the queue for its own items.
- Start now.
update_queue_itemwithstart_nowskips the conditions, the pool limit and load, but never a machine's budget. - History. Started, failed and cancelled items are kept for a day, unless another item still waits on them.
Placement
on says where a thread runs:
local, the default forstart_thread: this computer.- A machine's name: pinned there.
auto: the scheduler picks among machines that joined the pool. It triespreferfirst, then the machine with the fewest sessions per core, then the lowest load per core.needslimits the choice:macos,linux,arm64,x86_64,agent:<name>,repo:<origin>.
A machine is skipped when it's unreachable, lacks the agent or isn't signed in to it, can't clone the project, lacks a need, is at its budget, or its load is critical.
Machines. Add one in Settings ▸ Machines by SSH target. Hive installs its node there, and the machine joins the
pool. list_machines shows each one's OS, cores, memory, load, sessions (working and idle; its Leads' apart), budget and agents.
Load. CPU is at warning above 1 (load per core over a minute) and critical above 2; memory at warning above
80% used and critical above 92%. A machine at warning runs one queued thread at a time; a critical one gets nothing
new for 30 seconds after its last critical reading. rebalance moves idle threads off machines that are over
budget or loaded.
Sandboxes. A pool can include a sandbox: a short-lived Linux VM made on demand when work is placed there, deleted after 15 minutes with no live session (its work is brought back first). It's in preview and not in public builds yet.
Limits
| Limit | Default |
|---|---|
| Queued threads working at once, across the pool | 2 (Settings ▸ Machines, 1 to 16) |
| A machine's budget of agent sessions | 80% of its cores, at least 1 |
| Idle before a thread is suspended | 45 minutes; 5 once its work has landed |
Waiting for a reply to send_to_thread |
3 minutes |
| Messages between Leads before you speak | 4 |
| Tries to start a queued thread | 3 |
| Finished queue items kept | 1 day |
| A sandbox with no live session | 15 minutes |
When a machine is at its budget, Hive suspends its longest-idle threads to make room; if none can go, the item waits. Leads don't count against the budget. A message you send is never held back by it.
This page's source is pages/threads.md in hive/docs.