Multi-agent thread orchestration
Run a team of NAMED subagents that coordinate in shared THREADS, all driven by one
orchestrator. Each subagent has its own identity and inbox, and posts to threads the
relevant peers are members of.
When to use it
Orchestrate subagents when:
- Multiple reviewers need to see each other's work (code review, audit, cross-validation).
- A subagent should hand off findings to a peer for verification.
- The team needs a shared narrative (all readable in one thread history).
- You want to parallelize independent work (each agent runs concurrently) and then synthesize.
Setup
Start a thread and name its members. A thread is addressed by at least two of three
coordinates — {subject, path-glob, members}. For a private team, list the members explicitly
so only they see it; discovery is scoped, never global, so unrelated agents never surface it.
agents {mode: "thread_start", subject: "review-pr-42", members: ["security", "perf"]}
Assign each subagent a short name. Pass as_agent to every tool call the subagent makes.
Names like "security", "perf", "correctness" are clearer than defaults. A named member
must join with agents mode join (or be added with mode add_member) before it can post.
Distribute the subagent contract. Each subagent's prompt should include:
- Its assigned
as_agent name (e.g. "security").
- The shared thread's subject (e.g.
"review-pr-42").
- Instructions to:
- Call
agents {mode: "register", as_agent: "security", name: "Security Reviewer", …} once.
- Call
agents {mode: "join", thread: "review-pr-42", as_agent: "security"} to participate.
- Call
agents mode post with as_agent: "security" to share findings.
- Call
agents mode inbox with as_agent: "security" to see addressed messages.
Broadcast vs targeted hand-off
Thread post (agents mode post + as_agent): everyone on the thread sees it. Use for:
- Announcing a finding the whole team should see.
- Replying to a peer's discovery (
reply_to: <id> keeps it linked).
- Summarizing your work.
Targeted hand-off: to reach one peer privately, use agents mode thread_start for a two-member thread
(members: ["security", "perf"]) — only those two discover it. Use for:
- Asking a peer to cross-check your finding.
- Sharing a detail not ready for the whole team.
- Hand-off:
"I found X; can you validate my approach?".
Reading and synthesis
As the orchestrator:
- Let all subagents post to their threads (in parallel).
- Read the shared thread:
agents {mode: "history", thread: "review-pr-42"} (front-matter only).
- For each message that matters, fetch the body:
agents {mode: "message", message_id: "…"}.
- Read each subagent's inbox with
agents mode inbox and its as_agent identity.
(Messages appear as front-matter; bodies come from mode message.)
- Synthesize: combine the findings into a verdict, decision, or report.
Example: two-agent security + performance cross-check
Orchestrator setup:
agents {mode: "thread_start", subject: "review-auth-pr", members: ["security", "perf"]}
# Spawn agent "security"
# Prompt: "You are agent 'security' on thread 'review-auth-pr'. Register yourself,
# join the thread, analyze the diff for auth bugs, post findings, and start a
# two-member thread with 'perf' asking them to check your fix's perf implications."
# Spawn agent "perf"
# Prompt: "You are agent 'perf' on thread 'review-auth-pr'. Register yourself,
# join the thread, analyze the diff for performance regressions, post findings, and
# reply to 'security' with your take on their auth fix."
Agent "security" steps:
agents {
mode: "register", as_agent: "security", name: "Security Reviewer", description: "Auth auditor"
}
agents {mode: "join", thread: "review-auth-pr", as_agent: "security"}
agents {
mode: "post", thread: "review-auth-pr", as_agent: "security", subject: "SQL injection check",
body: "Parameter X is quoted..."
}
agents {
mode: "thread_start", subject: "cross-check-sanitized-input",
members: ["security", "perf"], as_agent: "security"
}
agents {
mode: "post", thread: "cross-check-sanitized-input", as_agent: "security",
subject: "Cross-check: sanitized input",
body: "I added validation at line 42..."
}
agents {mode: "inbox", as_agent: "security", mark_read: true} # See perf's response
Agent "perf" steps:
agents {
mode: "register", as_agent: "perf", name: "Performance Reviewer", description: "Latency auditor"
}
agents {mode: "join", thread: "review-auth-pr", as_agent: "perf"}
agents {
mode: "post", thread: "review-auth-pr", as_agent: "perf", subject: "Cache impact check",
body: "New validation adds ~2ms..."
}
agents {
mode: "post", thread: "cross-check-sanitized-input", as_agent: "perf",
subject: "Auth fix validated",
body: "Sanitization looks solid...", reply_to: "msg-sec-2"
}
Orchestrator synthesis:
agents {mode: "history", thread: "review-auth-pr"} # See front matter
agents {mode: "message", message_id: "msg-sec-1"} # Get security's body
agents {mode: "message", message_id: "msg-perf-1"} # Get perf's body
agents {mode: "history", thread: "cross-check-sanitized-input"}
agents {mode: "message", message_id: "msg-perf-2"} # Get perf's hand-off body
# Synthesize: "Security + perf sign off. Ready to merge."
Recency and thread freshness
Reads default to RECENT so stale chatter never confuses an agent:
agents modes history / inbox return only the last 24 hours by default. Pass
since_hours: N for a wider window, or since_hours: 0 for the full append-only log. Nothing is
ever deleted — older history stays reachable explicitly.
- Every front-matter row carries
age_secs (seconds since the message was posted) so you can gauge
staleness without converting timestamps yourself.
agents mode thread_list flags each thread stale: true after over 7 days without a post.
The CLI renders this as an ACTIVE / STALE marker per thread. Idle threads auto-archive; skip
stale ones unless you are intentionally reviewing old context.
Notes
- A named member must join with
agents mode join (or be added with add_member) before posting.
- A private two-member thread reaches exactly one peer — only its members discover it.
- Front-matter-only reads (history, inbox) are cheap. Fetch bodies only when needed.
- The CLI offers parity:
basemind agents post … --as-agent security,
basemind agents thread-start --subject <subject> --member perf --as-agent security,
basemind agents history <thread> --since-hours 0 (all history),
basemind agents thread-list (shows ACTIVE / STALE per thread).
1---2name: multi-agent-room-23description: Orchestrate a team of named subagents in shared threads. One orchestrator drives multiple peers with distinct identities; each subagent sees its own inbox and can cross-check findings by posting to a thread the peer is a member of.4---56<!--7AI-RULEZ :: GENERATED FILE — DO NOT EDIT8Content-Hash: blake3:09b9d7a7cee923f0dd2ec9893d6648d26eab4b6701de928c7b1cd55898d39fd19Source-Hash: blake3:85ad00af4214850487da665406023114ffe204d5194afab7f5ee823c398a421810Schema-Version: v111-->1213# Multi-agent thread orchestration1415Run a team of NAMED subagents that coordinate in shared THREADS, all driven by one16orchestrator. Each subagent has its own identity and inbox, and posts to threads the17relevant peers are members of.1819## When to use it2021Orchestrate subagents when:2223- Multiple reviewers need to see each other's work (code review, audit, cross-validation).24- A subagent should hand off findings to a peer for verification.25- The team needs a shared narrative (all readable in one thread history).26- You want to parallelize independent work (each agent runs concurrently) and then synthesize.2728## Setup29301. **Start a thread and name its members.** A thread is addressed by at least two of three31 coordinates — `{subject, path-glob, members}`. For a private team, list the members explicitly32 so only they see it; discovery is scoped, never global, so unrelated agents never surface it.3334 ```text35 agents {mode: "thread_start", subject: "review-pr-42", members: ["security", "perf"]}36 ```37382. **Assign each subagent a short name.** Pass `as_agent` to every tool call the subagent makes.39 Names like `"security"`, `"perf"`, `"correctness"` are clearer than defaults. A named member40 must join with `agents` mode `join` (or be added with mode `add_member`) before it can post.41423. **Distribute the subagent contract.** Each subagent's prompt should include:43 - Its assigned `as_agent` name (e.g. `"security"`).44 - The shared thread's subject (e.g. `"review-pr-42"`).45 - Instructions to:46 - Call `agents {mode: "register", as_agent: "security", name: "Security Reviewer", …}` once.47 - Call `agents {mode: "join", thread: "review-pr-42", as_agent: "security"}` to participate.48 - Call `agents` mode `post` with `as_agent: "security"` to share findings.49 - Call `agents` mode `inbox` with `as_agent: "security"` to see addressed messages.5051## Broadcast vs targeted hand-off5253- **Thread post** (`agents` mode `post` + `as_agent`): everyone on the thread sees it. Use for:54 - Announcing a finding the whole team should see.55 - Replying to a peer's discovery (`reply_to: <id>` keeps it linked).56 - Summarizing your work.5758- **Targeted hand-off**: to reach one peer privately, use `agents` mode `thread_start` for a two-member thread59 (`members: ["security", "perf"]`) — only those two discover it. Use for:60 - Asking a peer to cross-check your finding.61 - Sharing a detail not ready for the whole team.62 - Hand-off: `"I found X; can you validate my approach?"`.6364## Reading and synthesis6566As the orchestrator:67681. Let all subagents post to their threads (in parallel).692. Read the shared thread: `agents {mode: "history", thread: "review-pr-42"}` (front-matter only).703. For each message that matters, fetch the body: `agents {mode: "message", message_id: "…"}`.714. Read each subagent's inbox with `agents` mode `inbox` and its `as_agent` identity.72 (Messages appear as front-matter; bodies come from mode `message`.)735. Synthesize: combine the findings into a verdict, decision, or report.7475## Example: two-agent security + performance cross-check7677**Orchestrator setup:**7879```text80agents {mode: "thread_start", subject: "review-auth-pr", members: ["security", "perf"]}8182# Spawn agent "security"83# Prompt: "You are agent 'security' on thread 'review-auth-pr'. Register yourself,84# join the thread, analyze the diff for auth bugs, post findings, and start a85# two-member thread with 'perf' asking them to check your fix's perf implications."8687# Spawn agent "perf"88# Prompt: "You are agent 'perf' on thread 'review-auth-pr'. Register yourself,89# join the thread, analyze the diff for performance regressions, post findings, and90# reply to 'security' with your take on their auth fix."91```9293**Agent "security" steps:**9495```text96agents {97 mode: "register", as_agent: "security", name: "Security Reviewer", description: "Auth auditor"98}99agents {mode: "join", thread: "review-auth-pr", as_agent: "security"}100agents {101 mode: "post", thread: "review-auth-pr", as_agent: "security", subject: "SQL injection check",102 body: "Parameter X is quoted..."103}104agents {105 mode: "thread_start", subject: "cross-check-sanitized-input",106 members: ["security", "perf"], as_agent: "security"107}108agents {109 mode: "post", thread: "cross-check-sanitized-input", as_agent: "security",110 subject: "Cross-check: sanitized input",111 body: "I added validation at line 42..."112}113agents {mode: "inbox", as_agent: "security", mark_read: true} # See perf's response114```115116**Agent "perf" steps:**117118```text119agents {120 mode: "register", as_agent: "perf", name: "Performance Reviewer", description: "Latency auditor"121}122agents {mode: "join", thread: "review-auth-pr", as_agent: "perf"}123agents {124 mode: "post", thread: "review-auth-pr", as_agent: "perf", subject: "Cache impact check",125 body: "New validation adds ~2ms..."126}127agents {128 mode: "post", thread: "cross-check-sanitized-input", as_agent: "perf",129 subject: "Auth fix validated",130 body: "Sanitization looks solid...", reply_to: "msg-sec-2"131}132```133134**Orchestrator synthesis:**135136```text137agents {mode: "history", thread: "review-auth-pr"} # See front matter138agents {mode: "message", message_id: "msg-sec-1"} # Get security's body139agents {mode: "message", message_id: "msg-perf-1"} # Get perf's body140agents {mode: "history", thread: "cross-check-sanitized-input"}141agents {mode: "message", message_id: "msg-perf-2"} # Get perf's hand-off body142# Synthesize: "Security + perf sign off. Ready to merge."143```144145## Recency and thread freshness146147Reads default to RECENT so stale chatter never confuses an agent:148149- `agents` modes `history` / `inbox` return only the **last 24 hours** by default. Pass150 `since_hours: N` for a wider window, or `since_hours: 0` for the full append-only log. Nothing is151 ever deleted — older history stays reachable explicitly.152- Every front-matter row carries `age_secs` (seconds since the message was posted) so you can gauge153 staleness without converting timestamps yourself.154- `agents` mode `thread_list` flags each thread `stale: true` after over 7 days without a post.155 The CLI renders this as an `ACTIVE` / `STALE` marker per thread. Idle threads auto-archive; skip156 stale ones unless you are intentionally reviewing old context.157158## Notes159160- A named member must join with `agents` mode `join` (or be added with `add_member`) before posting.161- A private two-member thread reaches exactly one peer — only its members discover it.162- Front-matter-only reads (history, inbox) are cheap. Fetch bodies only when needed.163- The CLI offers parity: `basemind agents post … --as-agent security`,164 `basemind agents thread-start --subject <subject> --member perf --as-agent security`,165 `basemind agents history <thread> --since-hours 0` (all history),166 `basemind agents thread-list` (shows ACTIVE / STALE per thread).