Skip to content

feat(orchestration): start chat workers on a paired server - #40151

Closed
Jinwoo-H wants to merge 2 commits into
jinwoo/orch-stage2-remote-follow-upfrom
jinwoo/orch-stage2-remote-chat-workers
Closed

Jinwoo-H wants to merge 2 commits into
jinwoo/orch-stage2-remote-follow-upfrom
jinwoo/orch-stage2-remote-chat-workers

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

If a server is set to open agents as chats, a worker you started there from another computer still opened as a terminal. Now the server picks chat or terminal from its own settings, the same way it does for workers started on it directly. The chat worker gets its task, reports home, takes its coordinator's messages and closes when stopped or released, like a local chat worker.

Stacked on #40123 (base branch jinwoo/orch-stage2-remote-follow-up).

Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​324 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​324
Prod 22 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​729 $\color{#cf222e}{\Huge{\mathbf{−}}}$​204 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​525

What Changed

Before (A is paired to server devB; devB is set to open Claude as a chat):

orca orchestration worker-start --from <A terminal> --on devB --worktree new-top-level --repo id:<repo> --agent claude --spec "..."
# -> {"state":"ready","mode":"terminal","terminal":"term_...", ...}   # devB ignores its chat setting

After:

orca orchestration worker-start --from <A terminal> --on devB --worktree new-top-level --repo id:<repo> --agent claude --spec "..."
# -> {"state":"ready","mode":"structured","terminal":"structworker_...", ...}
#    The chat's `send`, a turn that ends without a report, and its worker_done reach A's `check`.
#    `orca orchestration send --to dispatch:<id>` from A reaches the chat as a new turn.
#    `orca orchestration worker-release --dispatch <id>` (or worker-stop, or automatic release) closes the chat.

orca orchestration worker-show --dispatch <id> --json --full
# -> liveness: unverifiable, reason: "Orca cannot read the state of a chat worker on a paired server yet; open its chat on that server to see it."

Reading a remote chat worker (worker-show live state, worker-read, its output) is not supported yet and says so plainly instead of showing a wrong state. A follow-up PR adds it, and adds reusing an existing chat with --on <server> --terminal orca_session_id:<id>.

Mechanism (server side, reusing the local paths, no remote-only copies):

  • Start: federationAttachStart decides the mode with decideWorkerStartMode / resolveWorkerStartModeOnHost and launches through executeAgentLaunch with the same chat-session factory local workers use (createStructuredWorkerSessionForWorktree). A new worktree with a wait-for-setup policy waits for setup before the chat takes its task. The brief is the chat's first turn; if the chat hasn't taken it yet, the start is reported unknown (not failed) and the chat stays for the worker to report.
  • Identity: the attachment records the chat's own pane key and process identity, so the one terminal claim from fix(orchestration): refuse a paired-server worker start onto a busy terminal before any wait #40102 and the relay's process checks cover it.
  • Mail and reports: a dispatch: mailbox that is only a remote attachment now resolves to its chat while the attachment is ready and exact, so the coordinator's relayed mail arrives as a turn. Turn stops of a remote chat report home through the existing remote turn-stop report.
  • Stop and release: the chat closes with the local chat stop and release helpers, after the same transcript capture, releasing commit and working-agent deferral a local chat release uses.
  • Mixed versions: a home sends protocol version 5 only to a server that advertises orchestration.federation-chat-workers.v1. The server starts a chat only for a version-5 request; anything older gets a terminal through the same terminalOnly launch main uses. The receipt carries mode, and the home shows the server's mode. Older servers send no mode, so the home keeps its own.

Why

This removes the remote-only terminal fallback so a remote start follows the server's own chat or terminal setting, the same as a local start. All the per-kind behaviour comes from the code local chat workers already use.

Linked Issue

Part of the cross-machine orchestration plan (gap W2).

Visual Proof

N/A: no UI change. CLI before/after is above.

Testing

  • I manually tested this on two isolated paired dev Orcas, with a real Claude worker from the normal user setup. Each run: worker-start --on <server>, the worker sends a status note and ends its turn, the coordinator sends it one more instruction, the worker sends worker_done, then worker-show and worker-release.
    • New home and a new server set to chats: mode: structured. The note, the turn-stop report, the coordinator's message (as a new chat turn), worker_done, the plain unsupported-read reason and the release (closed_agent_terminal) all worked.
    • New home and an origin/main server set to chats: mode: terminal (the Before above), and the same flow works as it does today.
    • origin/main home and a new server set to chats: a real terminal worker (term_…), and its worker_done settled.
  • Automated tests added: remote-chat-worker-attach.test.ts has 10 cases. They cover start as a chat, mail home, a turn-stop report, coordinator mail as a new turn, the plain refusal from show, read and read-output, stop, release after the report, automatic release, a new worktree waiting for setup, and a terminal for a request from an older home.
  • Each case fails when its fix is reverted (checked one fix at a time).

pnpm tc:node, the orchestration suites (1203 tests), and the changed-code quality gate pass. pnpm check:changed passed 25/25 on the main commit. After the protocol-gate commit (which touches a shared capabilities file and so runs the full suite), it passed 26/27: the unit-test failures were server-hook-session-binding.test.ts, which also fails on origin/main on this machine, and three files that pass when run alone on both this branch and its base. A Codex adversarial review found two P1s and a P2: automatic release never committed to releasing, a new-worktree chat skipped the wait-for-setup gate, and live reads reported a changed identity. All three are fixed here; the delta review verdict was ship. A follow-up commit gates chat workers on the home's protocol version.

Risk

Level: Medium

  • A server that prefers chats now starts remote workers as chats. Anything the home does that needs a terminal (reading live output, reusing a chat with --terminal) is refused with a plain message until the follow-up PR lands.
  • The mailbox change covers only a dispatch: mailbox with no local Dispatch row; local mailboxes resolve as before.
  • Older homes keep getting terminals: the server starts a chat only for a request at the new federated protocol version 5. A home sends version 5 only when the server advertises orchestration.federation-chat-workers.v1.
  • Revert is a plain revert: remote starts go back to terminals.

Review

Self-review plus an adversarial Codex review of the commit and its fix delta; final verdict ship.

Agent skill upstream boundary

  • Not applicable.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I stated the risk
  • N/A for screenshots (CLI only)
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (runtime logic only)
  • Typecheck and tests pass locally; pnpm check:changed results are above; CI covers the rest

Jinwoo-H added a commit that referenced this pull request Nov 9, 2026
# Conflicts:
#	src/main/runtime/rpc/methods/orchestration/federation/federated-worker-agent-launch.ts
A server that prefers chats now starts a remote worker as a chat, the
same way a local start does. The chat takes its task as its first turn
(after a wait-for-setup setup finishes), reports home over the relay
(mail, turn stops, worker_done), takes its coordinator's mail as new
turns, and closes on stop or release, including automatic release.
Reading a remote chat worker's state says plainly that it is not
supported yet.
…nows one

A new federated protocol version 5, sent only when the server advertises
orchestration.federation-chat-workers.v1, says the home understands a chat
worker. An older home gets a terminal, exactly as before, so its receipt
never calls a chat a terminal.
@Jinwoo-H
Jinwoo-H force-pushed the jinwoo/orch-stage2-remote-follow-up branch from f91ab49 to 31f28d6 Compare November 9, 2026 08:49
@Jinwoo-H
Jinwoo-H force-pushed the jinwoo/orch-stage2-remote-chat-workers branch from 063a3df to ba767ed Compare November 9, 2026 08:49
@Jinwoo-H

Copy link
Copy Markdown
Contributor Author

Closing in favour of a different design. A worker started on a paired server will become an ordinary worker owned by that server, and the coordinator's computer forwards commands and records results. Follow-ups, chat workers and reads then use the same code as local workers, instead of a separate remote path. The test scenarios from this PR carry over to that work.

@Jinwoo-H Jinwoo-H closed this Nov 10, 2026
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.

1 participant