Repository navigation
Start orchestration workers and remote workers through the launch executor - #26724
Conversation
The host's worktree.create handler now starts a requested agent (startupAgent, or a linked startupDraft) through executeAgentLaunch instead of calling the create directly. Nothing on the wire changes: the request, the reply and agentTerminalHandle are the same, the agent is still the workspace's startup terminal whatever the chat default says, and the create still delivers the text itself (folded into the command at any length, a follow-up for agents that read it after start, and the draft pasted unsent). Adds three host-internal executor inputs: terminalOnly, the legacy-host prompt policy, and a shared entry (createWorktreeWithStartupAgent) that host producers can call in place of createManagedWorktree.
Problem: after worktree.create moved onto the launch executor, a create from a linked issue (phone "create from issue", or a raw worktree.create with startupDraft) could differ from before in two narrow cases. When the draft's agent came from the settings default or from detection and its launch command could not be built (for example unbalanced quotes in the saved agent arguments), the workspace was recorded as created with that agent even though it never started, and a background create opened no terminal at all instead of its plain shell. When no agent was found, detection ran twice (an extra SSH round trip on remote repos). User-facing change: none intended; both cases now behave exactly as before the executor move. Mechanism: - The entry hands the draft's chosen agent to the create as a main-internal startupDraftAgent, which steers only the draft; createdWithAgent stays what the caller sent. A draft that resolves no agent is created without the draft, so the create does not detect again. - AgentLaunchExecution is a discriminated union: every normal launch must bring its surface factory, and a legacy-host launch must be terminal-only, bring a workspace factory, and cannot bring surfaces. The runtime guards the types replace are gone; the target kind is checked before any create. - Legacy-host receipts follow the delivery module's rule: a blank prompt is no prompt, a submit folded into the launch command is handed-to-terminal, a post-start send the create does not await is unconfirmed (host-internal), a draft is not-delivered. - The no-agent error lives with the legacy-host policy and is caught only by the shared entry. - Tests: a real-runtime parity test (stored agent, terminal spawns, detection count vs the create alone, including the unbuildable plan), exact-argument checks over every non-agent startup field, compile-time checks for the union, and direct tests of the draft agent resolver.
Two comments stated that headless automations and federation already go through createWorktreeWithStartupAgent; both still call createManagedWorktree directly. Reword them as the plan. Comment-only.
…cutor A fresh worker (new worktree or existing, terminal or structured) and a federated worker on its receiving host now start their agent through executeAgentLaunch with the worker's own workspace and surface factories. The worker hands in the mode it decided before its dispatch record existed (decidedMode), so the host is asked once and the stored receipt is the one that ran. Effects, setup receipt, stage rows and their order are unchanged; a refused structured worker still fails rather than becoming a terminal.
…er launch step strands - decidedMode is now exclusive with terminalOnly and callerRendersStructured in the type, labelled temporary until one planner settles every launch. - connectionId's doc says what is true: the executor carries it and nothing reads it yet. - A worker launch that throws after its structured session exists discards that session itself, since the caller only tears down a returned placement. - A federated create refuses a launch with no startup agent and narrows repo/name before recording its first stage. - Tests: exact federated existing-path stages, a created-worktree host refusal that starts a worker terminal, and the stranded-session discard.
…efusal at compile time
Review and QA summary (final head e551764)The problem. Orchestration workers ( What changes for the user: nothing, by design. Workers start the same way, with the same tabs ( Fixed during review (three review rounds; no blocking findings in any round):
Deferred (not blocking):
Verified:
Not verified:
|
…ers-executor # Conflicts: # src/main/agent-launch/agent-launch-execution.ts # src/main/agent-launch/agent-launch-executor.ts
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (11)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughThe launch executor can use a caller-supplied mode receipt or resolve a mode during preflight. Local worker placement and federated attachment launch now use executor-based flows. Local placement handles structured-session teardown after launch failures. Federated launch creates or reuses a worktree and provisions a worker terminal. Added tests cover the mode contract, local placement paths, failure handling, and federated launch behavior. Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to No actionable launch regression is established; the PR is mergeable after normal checks. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Retargeted to This PR was stacked on #26709. #26709 has now been squash-merged into main as d7e985c, so the base is now
|
ELI5
Orca has one host operation that starts agents (the launch executor). Orchestration workers (
orca orchestration worker-start) and remote workers (a worker placed on another Orca server) still started their agents their own way, beside it. This PR sends them through the executor too. Nothing you see changes.What Changed
The problem. A fresh worker's agent was started by the worker code itself: it created the worktree, asked the host whether it could run a chat session, and built either a chat session or a terminal. The launch executor does the same sequence for every other launch. Two copies of that sequence have to be kept in step by hand, and the worker copy was the last host producer (with automations) outside the shared one.
What is different for the user: nothing, by design. Same worker records, same tabs, same sidebar:
worker-start --worktree new-childwith "new agent tabs open as chat" off: a terminal worker titledworker-<task>, the sidebar does not move, the task brief arrives as its first turn.--worktree <existing>in both modes behaves the same;--terminal <handle>still reuses a running agent without starting anything.worker-showeffects, the setup receipt, the stage rows and their order, and residual resources are byte-identical. They are durable dispatch records the coordinator reads.The mechanism.
placeWorkerAgent(local workers) keeps the--terminalreuse branch and otherwise callsexecuteAgentLaunchwith the worker's own factories: the workspace factory is the existingcreateWorkerWorktree(agent-first exactly when the worker is a terminal), and the surface factory is the existing background chat session or theworker-<task>terminal withsurfaceOwner: false, each recording theterminal_creatingstage where it was recorded before.decidedMode: a worker decides its mode before its dispatch record exists and stores it there, so it hands that decision in instead of letting the executor decide again. For an existing worktree it already carries the host's answer, so the executor does not ask the host a second time; for a new worktree the executor asks after creating it, as the worker did.orchestration.federationAttachStartruns the executorterminalOnly(the input Start worktree.create's agent through the launch executor #26709 added) with federation's own factories: the same agent-first worktree create and the same backgroundworker-<task>terminal. The request and reply are unchanged.Why
This is phase 1b, step 3 of moving every fresh agent start onto one executor. Workers already shared the mode decision; this moves the sequencing too, so a later change to how launches are sequenced reaches workers without a second edit.
Why hand the decision in rather than let the executor decide: the worker's decision differs on purpose (only Claude and Codex are chat-session workers; other registered chat agents start as terminal workers) and is written to the dispatch record before the launch runs. Re-deciding inside the executor would either change which agents become chat workers or store a receipt that is not the one that ran.
Differences from the common pattern, labeled:
decidedMode). The type refuses it alongside the inputs the executor's own decision reads. It goes away when one planning step decides every launch (phase 2).Linked Issue
Maintainer change; part of the launch-unification work (no separate issue). Stacked on #26709.
Visual Proof
No visual change by design. Hidden test app with a stand-in Claude that logs what it receives; before = this PR's base (main's worker code), after = this PR.
worker-start --worktree <existing>with chat off: a newworker-<task>tab next to the workspace's agent, the brief arrives, the sidebar stays where it was.worker-start --worktree new-childwith "new agent tabs open as chat" on, and no real Claude behind the chat: the chat worker fails the same way on both, and neither falls back to a terminal.Testing
worker-start-launch-executor-parity.test.ts(refused chat worker fails with no terminal, in an existing and a new worktree; host asked once; host refusal in a created worktree gives theworker-<task>terminal with the same stages; exact terminal arguments;--terminalreuse starts nothing),worker-start-agent-placement-teardown.test.tsandfederated-worker-agent-launch.test.ts(exact create arguments and effects, setup reported before a no-terminal failure, backgroundworker-<task>terminal, still a terminal with chat on).tc:node) and CI static checks pass; CI is green on the final head.--terminalreuse, wait-for-setup, and a remote worker on a second local Orca server (existing remote workspace and a new top-level worktree). Replies, CLI text andworker-showrecords were identical after normalizing ids; the onlyworker-showdifference was the captured terminal preview text, which also varies on the unchanged--terminalpath.Notes