Orchestrating agent threads
By Stefan Garofalo
Click to launch a Track. Click a gated Track to approve it.
The Home Repo pattern is great when you work across several repositories. One starting directory holds your skills, shared docs, and pointers to sibling repos, so a single agent session can clone what it needs and open worktrees per feature.
That setup scales surprisingly far, until a feature touches three or four repositories that depend on each other. You can keep everything inside one session, where the context window fills up and unrelated branches get tangled together, or you can open parallel threads across repos. Once you do, you have a new problem: coordinating them without turning yourself into a human message router.
You don't need a custom orchestration framework or a background daemon to fix this. The only thing your harness has to support is cross-thread messaging. Once an agent can spawn a thread in another repo and send a message between threads, the rest is two Markdown files on disk and a few rules.
The problem it solves
Parallel threads get you past the single-session bottleneck, and they bring four headaches of their own. Threads finish out of order. A long-running coordinator forgets merge and deploy rules the moment context compacts. A newly launched thread can die silently before it ever sends a line back. And any blocking wait stalls every other thread queued behind it.
Three primitives
The whole setup comes down to three roles:
| Primitive | Lifetime | Owns |
|---|---|---|
| Orchestrator | Long lived | Routing events, dependencies, merges, rollouts, and human reports |
| Track | Durable per scope | One scoped change inside its target repo |
| Worker | Short lived | Subagent inside a Track or Orchestrator thread for a check, test run, or async wait |
Tracks are real, durable threads because each one needs its own history, git worktree, and branch inside its repo. You also want to be able to open any Track yourself and steer it when something gets tricky. Workers are just subagents inside a Track or Orchestrator thread. They do one quick job and stay out of your inbox, so the parent thread stays free to react to new events.
All you need is cross-thread messaging
You don't have to tie your rules to a specific tool. Your harness only needs to do two things:
- Spawn a thread in another repo with an initial brief.
- Send a message from one thread to another, waking it up if it's idle.
Everything else (forking a thread, spawning an async Worker, or watching a PR) is nice to have. It catches stalls faster and saves a few round trips, and if your tool doesn't support it, the Orchestrator can still check PR state the next time it wakes up.
Several coding harnesses already ship this:
| Harness | Cross-thread mechanism | Scope |
|---|---|---|
| T3 Code | Orchestrator MCP (t3_thread_launch, t3_thread_send) | Cross-project threads and delegated subagents |
| Codex app | codex_app MCP (list_threads, read_thread, send_message_to_thread, fork) | Persistent app and local threads |
| Claude Code | ListAgents and SendMessage, plus Agent Teams | Cross-session messaging and multi-session teams |
| Cursor Projects | Coordinator with inspectable parallel agents; side-chat relay | Project-scoped and multiplayer coordinators |
| Plugins and local brokers | opencode-mesh, opencode-courier, Agent Intercom | Adds peer messaging to runtimes without built-in thread tools |
When to orchestrate
You don't want orchestration overhead on every task. Start in a regular thread in your Home Repo, and look at two things before spinning up an Orchestrator: how coupled the work is across repos, and how big it is.
| Scopes | Size | Approach |
|---|---|---|
| Many, cross-dependent | Large | Orchestrator with parallel Tracks |
| Many | Small | Single thread |
| One | Large | Single thread |
That beats the two rules people usually try first. Counting PRs doesn't work: four tiny one-line bumps are faster in one thread than one big cross-repo feature. Asking the model if the task will fit in its context window is even worse, because models are terrible at guessing that.
Starting in one thread doesn't lock you in. If the task grows into coupled work across repos, fork that thread's history into a new Track with a short handoff and let the original thread take over as the Orchestrator.
Two Markdown files on disk
A long-lived Orchestrator will outlive its context window. If your rules or track status only live in chat history, the first compaction wipes out your merge policies and you start getting duplicate or stale updates.
Put all of that state in two Markdown files and have the Orchestrator read them at the start of every turn:
charter.mdholds the rules for the run: target repos, merge style, required checks, deploy targets, and human gates. If you change your mind mid-run, you edit one file.ledger.mdtracks where every Track stands, what's waiting on you, what decisions were made, and a short event log.
Two small habits keep ledger.md honest. First, write the new state to ledger.md before you act on it. If a "ready" message shows up twice, the second turn sees it's already handled and does nothing, so duplicate messages become a no-op. Second, order incoming messages by when they were sent, so a late ping can't clobber newer state.
## Tracks
| Track | Repo | Status | Branch | Ready Commit |
| --- | --- | --- | --- | --- |
| auth-token-refresh | auth-sdk | merged | feat/token-refresh | a1b2c3d |
| session-banner | web-app | gated (N1) | feat/session-banner | 9f8e7d6 |
## Needs you
- N1: Merge web-app PR #42 (new user-facing banner). Reply "go N1".
You can nuke the whole chat transcript, open a fresh session, point it at charter.md and ledger.md, and pick right back up without losing a Track.
If you've read Reliable agent workflows need state machines, this will look familiar: it's a Durable Workflow Graph one level up. Setup runs once to write charter.md, split the work, and spin up Tracks. After that, every incoming message wakes the Orchestrator up, it reads disk, decides the next step, and goes back to sleep.
Staying non-blocking
The AFK event loop
Assume you're away from the keyboard between check-ins. That means the Orchestrator's best state is idle.
Each turn handles one event (a Track update, a PR change, a Worker result, or a message from you), updates ledger.md, and finishes right away. Anything that keeps a turn open while waiting breaks the whole thing, because messages from other Tracks pile up unread behind it. An interactive prompt waiting on you, a sleep loop polling CI, or a slow inline test all freeze the coordinator the same way.
So don't wait inline. Hand waits and checks to async Workers, let the Orchestrator make routine calls it can easily revert, and drop anything that needs you into a Needs-you list in ledger.md. Only the Track waiting on you pauses; every other Track keeps moving.
How Tracks report in
Spell out the reporting rules in each Track's launch brief: its scope, upstream dependencies, base branch, where charter.md lives, and a simple rule to message the Orchestrator only when its state changes (started, ready <PR> @ <commit>, blocked, needs a decision, or done).
No "got it" replies from Tracks, and no polling timers on the Orchestrator, so idle chatter never wakes it up.
Firing off a thread and waiting for it to report back has one catch: spinning up a thread or creating a worktree can fail silently before the child ever sends started. Right after launching a Track, spawn a short-lived Worker to check that it came up. If it's still silent after a couple of minutes, mark it stalled in ledger.md.
Gates and scannable reports
Without a clear line in charter.md, a coordinator swings between two annoying extremes: bugging you over tiny fixes it should handle itself, or doing something irreversible without asking.
Put a short list of human gates in charter.md. Anything high-impact, irreversible, or externally visible waits for your go-ahead, and when in doubt, it waits. Everything else runs on its own and gets logged in ledger.md with a note on how to undo it.
Only open a gate on your own explicit approval. A paraphrased "the user said go" relayed by another agent doesn't count.
When you come back to check in, you want to grasp the whole run in ten seconds. Generate every status report straight from ledger.md in three fixed sections:
Needs you
- N1: Merge web-app PR #42 (new user-facing banner). Reply "go N1".
Changed since last report
- auth-sdk (auth-token-refresh): merged a1b2c3d, deployed to staging, end-to-end tests passed.
Running
- billing-worker (webhook-retries): implementing changes on feat/webhook-retries.
Use plain repo and scope names so you can unblock an item by replying with one short line.
Merge, rollout, and live verification
Each Track owns its branch from first commit through merge, so the Orchestrator never resolves code conflicts on a Track's behalf.
A Track never merges its own pull request. It reports ready <PR> @ <commit>, and the Orchestrator merges that exact commit once checks pass and the branch head hasn't moved.
Once a PR merges, the Orchestrator takes over the rollout. Deploys to the same target run one at a time while unrelated targets deploy in parallel. A Worker watches the rollout until it's live, and if a deploy breaks, the failure goes right back to the owning Track as a bug.
Green CI and a finished deploy only prove that the build packaged and uploaded. Once the new version is up, a Worker runs end-to-end tests against it.
Suppose auth-sdk and web-app are running in parallel. web-app finishes a new user-facing banner and sends ready #42 @ 9f8e7d6. User-facing changes sit behind a human gate in charter.md, so the Orchestrator writes gated (N1) to ledger.md, puts N1 in the report, and stops. Ten minutes later, auth-sdk sends ready #18 @ a1b2c3d for an internal token fix. The Orchestrator wakes up, checks that CI is green on a1b2c3d and the branch head hasn't moved, merges the PR on its own, kicks off the staging deploy, and hands the wait to a Worker. Once staging is live, another Worker runs end-to-end tests against it and marks auth-sdk as verified, all while N1 sits waiting for you.
Tradeoffs and getting started
Multi-thread orchestration burns more tokens than one session, and you do have to spend a couple of minutes writing down your rules in charter.md up front. It also can't hide host issues: API rate limits, message lag, and broken worktrees still happen, which is why the startup check and disk state are worth the trouble.
Why not one thread with subagents?
Subagents are great for quick jobs where you only care about the final answer. They can't replace Tracks because you can't jump into a subagent thread to steer a messy change, and a subagent vanishes when its parent's turn ends, so it can't own a long-running branch.
How fast can you try this?
If you already have a Home Repo and a harness with cross-thread messaging, you're almost there. Add a charter.md and ledger.md convention to your Home Repo and start your next multi-repo task in a single thread. Keep it there when the work is small, and spin up Tracks the moment cross-repo dependencies start getting in each other's way.
If you'd rather not write those rules yourself, the orchestrator skill packages this setup: the charter.md and ledger.md formats, the Track brief, the human gates, the three-part report, and a binding table for the harnesses above. It's written as a Durable Workflow Graph, so a fresh thread can resume a run from the two files.
npx skills add stefan-garofalo/skills -g --skill orchestrator
Invoke it from your Home Repo when one task turns into coupled work across several repos.