Skip to content

Orchestration v3: coordinators end their turn and Orca wakes them - #36137

Merged
Jinwoo-H merged 229 commits into
mainfrom
orchestration-v3-combined
Oct 30, 2026
Merged

Jinwoo-H merged 229 commits into
mainfrom
orchestration-v3-combined

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 169 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​4246 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2639 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1607
Prod 331 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​7097 $\color{#cf222e}{\Huge{\mathbf{−}}}$​12526 $\color{#cf222e}{\Huge{\mathbf{−}}}$​5429

ELI5

A coordinator agent now starts its workers, ends its turn, and gets woken by Orca when a worker reports. Before, coordinators waited inside their turn with long blocking calls, polled, and did bookkeeping (create a Run, acknowledge mail, release workers). Now Orca does that bookkeeping, wakes the coordinator wherever it is (a background or never-opened workspace, after an Orca restart, or mid-turn), tells it when a worker stops without reporting, and closes finished workers you never looked at.

This combines the orchestration PRs listed at the bottom into one change, plus the fixes found while testing them together.

What changes for users

  • Coordinators end their turn after starting workers. Orca types "You have N orchestration messages" into the coordinator (terminal) or queues it (chat) when a worker reports.
  • The wake reaches the coordinator in more places:
    • while it is mid-turn: recognized agents queue typed text, and unrecognized programs still wait for quiet output;
    • in a background or never-opened workspace: delivery goes to the terminal, not to a mounted pane;
    • after an Orca restart: surviving terminals are reattached at startup, and each agent's last reported status is restored.
  • Less bookkeeping:
    • worker-start creates the Run in one step;
    • reading the inbox acknowledges it;
    • receipts carry a next hint ("Orca wakes you when workers report; end your turn when you're done");
    • workers no longer send heartbeats, and old heartbeats are recorded as state, never as mail.
  • Stopped workers are reported. A worker that ends its turn without worker_done, or sits at a permission or question prompt, sends the coordinator one message with its last output. Nothing is settled automatically.
  • Finished workers close themselves. A worker's terminal or chat closes about 2 minutes after worker_done, unless you opened it (its tab was on screen while you were present) or typed into it. A new setting, "Auto-close finished workers" (on by default), turns this off.
  • A new Run no longer cuts a coordinator off from its earlier Run.
  • The guide and worker preamble are shorter. They describe only the current flow, and older-version help lives in error messages and next.

Mixed versions

Features are gated on capabilities the other side advertises, never on version numbers:

  • Older Orca, CLI path the agent can fix: the request fails up front with the reason and the command to run instead (for example, one-step start on an older Orca points at run-create).
  • A second Run on an older Orca: it succeeds, and next explains how to use run-use.
  • Auto-close on an older remote host: the home machine runs the 2-minute timer itself.

Measured (real app, 3 runs each, same fixture and prompts)

main this PR
Correct 26/27 27/27
Coordinator waited inside its turn 14 of 27 runs 0
Bookkeeping calls per run ~3 0
Tokens, two parallel workers 351k 232k (−34%)
Wall time, two parallel workers 87 s 72 s
Tokens, Codex terminal coordinator 364k 173k (−52%)

Final round on this head's predecessor, all passing:

  • woken with the workspace on screen, in the background, never opened, and never opened with a restart;
  • Codex terminal and Claude chat coordinators;
  • each stop report: no worker_done, a permission prompt, and a chat error;
  • auto-close: unopened workers close, viewed and typed-into workers stay, and with the setting off everything stays.

Known limits (follow-ups)

  • A worker whose agent process dies while its shell lives is not reported. This is the same as today; the coordinator waits until nudged. Planned follow-up: watch the agent's reported process.
  • Runs are still owned by pane key. Delivery resolves every pane that shows the terminal. Planned follow-up: own Runs by terminal session plus process incarnation, so a new agent in the same pane cannot inherit a coordinator's mail.
  • Restart memory. Reattaching every surviving terminal keeps a full-depth screen mirror for each one, roughly 10 MB per terminal at full scrollback. Planned follow-up: defer the mirror until something views it, without losing scrollback.

Supersedes

#34564, #34704, #34706, #34744, #34754, #34900, #35274, #35293, #35294, #35343, #33720, #34056. They will be closed with a link to this PR.

…ther terminal, and let settled structured workers take further tasks

A plain orchestration check consumed the named terminal's mail whatever terminal ran it, so a
coordinator checking a worker's handle took the worker's message. A consuming check from a
terminal whose own live pane is a different terminal's is now refused; --peek and --all still read
it without consuming.

worker-start --terminal and dispatch --inject routed a structured worker (structworker_ handle) as
a terminal and failed with terminal_unsupported_for_agent_session. Any agent-session party now
takes its task as a send into its session, while a structured worker keeps the pane and process
authority its first Dispatch had.
…jecting structured workers

Review fixes for the mail fence and structured worker reuse:
- The check fence compares the caller's and the mailbox's live terminal process instead of
  recorded panes, so exited terminals keep the old behaviour and two processes sharing a
  recorded pane are told apart. It also covers --ack in every read mode. The caller lookup is
  shared with the lifecycle caller fence.
- dispatch --inject to a structured worker stays refused as before: an injected Dispatch takes
  no custody, so releasing the first Dispatch could close a session working on the second.
  worker-start --terminal reuse transfers custody and stays supported.
- worker-start decides pane-less chat authority from the resolved party and passes the session
  down, so delivery and next commands no longer re-derive it from the address spelling.
- Receipts name an agent session, not a chat.
The caller lookup fell back to the env pane key whenever the env handle was not live, so an
exited terminal's pane resolved to whatever terminal now occupies it, and a tmux worker's own
check was refused. The pane fallback now applies only when the env handle is not proven exited.
…tart

Main now attaches every live local daemon session it adopts at startup,
not only ones a window pane or remote view is showing, and re-attaches
after a daemon endpoint drop. The attach snapshot seeds main's screen,
tail and title, and an attached-but-silent agent gets an output clock so
readiness can see it has gone quiet. Waits on a survivor main could not
attach fail at once instead of timing out.
…e attach state

- Endpoint loss re-attaches in main only sessions no renderer view reports; a pane restores its own.
- The attach hide skips views mid-attach and leaves a pane's own hidden claim alone on failure.
- One per-session stream state (attaching, attached, lost) replaces three sets and is forgotten on exit.
- Waits retry the attach before failing, including after a failed re-attach.
- The output clock starts wherever a reattach result is seeded, so pane reattaches get it too.
…s on unattached survivors fail at once; one ptyId output clock
…uiet clock per generation, keep main's hidden mark on failed attach
…d safety rules, fixed scope and settled wording
…gram still reports working

Claude Code keeps its OSC 7501 report on working while an agent-teams
teammate is alive, even after the lead's own turn ends. The mailbox gate,
idle edges and tui-idle all read that report, so worker mail was stored and
never typed. A hook turn end newer than the program's working report now
counts as rest; hook rows re-classify the PTY so the existing idle edge
delivers. Agent Teams panes now join their claude hook rows.
…ceipt

A child's hook restamps the row's receivedAt while the lead's turn is still
the old one, which could mark rest under a newer program working report.
Use the lead's turn-end stamp on this runtime's clock, after the latest input.
…aring clocks

Drop programActivitySince and the turn-end clock mapping: replays and SSH
host clocks made the comparison unreliable. A Claude lead counts as at rest
under a program working report when its hook turn end is a live transition
from this pane's host and launch, past the existing input and respawn floors.
…s converge with automatic release

- Record worker takeover at the owning runtime when it accepts UI input, before the bytes reach the PTY.
- Run remote attachment releases through the same per-resource single-flight as local ones.
- Apply the confirmed-release home projection when host observation reports a host-side release, and carry the host deadline in fleet snapshots.
- Prove restart recovery with a file-backed database reopened by a fresh runtime.
nwparker added a commit that referenced this pull request Nov 6, 2026
…eir stream

The daemon adapter's inventory listing reported every surviving session's
title as "shell", though the listing carries no title. That made-up value
became the fallback tab title when adoption ran before the attach seed, and a
terminal.create retry that adopted a survivor after a restart recorded it as
the terminal's observed title and returned it.

That create-retry adoption also never attached the session's stream, so the
adopted terminal's output never reached main: lastOutputAt stayed null and its
real title never landed until some later inventory refresh attached it.

- The daemon listing reports no title. The attach snapshot's lastTitle and the
  stream stay the single source, as for every other terminal.
- A create retry that adopts a survivor attaches it through the same main
  attachment inventory adoption uses.
- A new runtime record treats an empty title as unknown, as an update already
  does, so it never reads as a manual title.

Inventory adoption already attaches survivors (#36137); this closes the create
retry path and drops the made-up title. No wire change: old and new daemons
send the same listing.

Fixes #22809
nwparker added a commit that referenced this pull request Nov 6, 2026
…eir stream (#38760)

The daemon adapter's inventory listing reported every surviving session's
title as "shell", though the listing carries no title. That made-up value
became the fallback tab title when adoption ran before the attach seed, and a
terminal.create retry that adopted a survivor after a restart recorded it as
the terminal's observed title and returned it.

That create-retry adoption also never attached the session's stream, so the
adopted terminal's output never reached main: lastOutputAt stayed null and its
real title never landed until some later inventory refresh attached it.

- The daemon listing reports no title. The attach snapshot's lastTitle and the
  stream stay the single source, as for every other terminal.
- A create retry that adopts a survivor attaches it through the same main
  attachment inventory adoption uses.
- A new runtime record treats an empty title as unknown, as an update already
  does, so it never reads as a manual title.

Inventory adoption already attaches survivors (#36137); this closes the create
retry path and drops the made-up title. No wire change: old and new daemons
send the same listing.

Fixes #22809
hiphapis added a commit to hiphapis/orca that referenced this pull request Nov 9, 2026
Upstream's Orchestration v3 rewrite (stablyai#36137 and following) compressed the
guide and deleted the "Launch preferences" section this branch edited, so
re-home the policy in the new idiom instead of restoring the old prose:
extend the kernel's existing `--model` bullet to cover `--agent` and
`--effort` and to route `agent_unconfigured` back to the user, and drop
`--agent` from the worker-start examples. Regenerate the bundled guides.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011nnNsG3p4Do9eiyfXGr2rB
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants