Skip to content

fix(orchestration): worker-start launches the configured agent CLI, not the raw agent id - #12148

Merged
OrcaWin merged 6 commits into
mainfrom
OrcaWin/bug-worker-start-worktree-current-launches-curso
Aug 3, 2026
Merged

OrcaWin merged 6 commits into
mainfrom
OrcaWin/bug-worker-start-worktree-current-launches-curso

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Aug 3, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #11926

Problem

On Windows, orca orchestration worker-start --worktree current --agent cursor opened the Cursor desktop app instead of the Cursor Agent CLI, left a blank PowerShell session, and failed at agent_readiness with timeout.

The worker terminal was created by passing the Orca agent id straight through as a shell command:

runtime.createTerminal(`id:${worktreeId}`, { command: args.agent, ... })

createTerminal tries to recover the agent from that string via resolveBareAgentLaunchCommand, but that matches against launch commands, not ids. cursor's launch command is cursor-agent, so nothing matched, the string fell through as user-authored shell, and Windows PATH resolved cursor → cursor.cmd → the IDE.

It worked for claude/codex/gemini only because their id happens to equal their launch command. The same gap hit every agent where they differ: cursor→cursor-agent, continue→cn, aug→auggie, kiro→kiro-cli chat --tui, qwen-code→qwen, mistral-vibe→vibe, antigravity→agy, trae→traecli, mimo-code→mimo, hermes→hermes --tui, command-code→command-code --trust, claude-agent-teams→orca claude-teams.

Fix

Added TerminalCreateOptions.startupAgent so a caller that already knows the agent names it outright instead of encoding it as a command string. resolveAgentTerminalCreateOptions then builds the launch from the TUI agent config — resolved command, agentCmdOverrides, default args/env, and preflight trust (cursor needs its .workspace-trusted marker or the first-launch menu swallows the dispatch preamble).

Both orchestration worker-start terminal creates use it: the local path (orchestration-worker-topology.ts) and the federated one (orchestration-federation.ts).

Two side benefits:

  • Folder workspaces are covered. They have repo: null, so the old !workspace.repo guard skipped agent resolution entirely and spawned the bare string.
  • An explicit agent that cannot resolve now fails loudly instead of silently spawning a plain shell that can only time out at agent_readiness — the exact symptom in the report. That covers a disabled agent, an unbuildable launch plan, a missing workspace selector, and a caller that contradicts itself by also supplying env/launchConfig/launchAgent/startupCommandDelivery/claudeAgentTeamsSourceCommand/command/resumeProviderSession.

New-worktree worker-start (--worktree new-child / new-top-level) was already correct; it goes through createManagedWorktree({ startupAgent }).

Verification

Reproduced first — createTerminal(path, { command: 'cursor' }) spawned the literal cursor.

The non-startupAgent path is provably unchanged. The guard was restructured, so I enumerated all 256 combinations of its eight inputs: zero divergences from the original. isRemote is likewise unchanged there, since repo is guaranteed truthy on that path.

No regressions. Full src/main is 167 failures on this branch and 167 on a clean baseline — identical. Those are pre-existing Windows path/symlink/fsync assumptions in untouched areas (orca-runtime-files, ai-vault, node-markdown-document-discovery), verified by stashing.

Tests are not tautological — verified by mutation, not assumption. Reverting the local call site fails 3 tests; neutering the resolver fails 3; reverting the federated call site fails its test. Each restored and re-confirmed.

New coverage:

  • Agent id resolves to cursor-agent with configured args/env, launchAgent, and trust marked before spawn.
  • Windows (cmd.exe) quoting, asserted exactly — confirmed platform-sensitive by flipping to darwin, which fails on quote style.
  • Platform matrix over claude-agent-teams, the only agent with launchCmdByPlatform (orca.cmd / orca-ide / orca claude-teams).
  • agentCmdOverrides honored, so anyone who set an override as a workaround keeps it.
  • Repo-less folder workspace.
  • All seven contradictory-caller combinations, plus disabled agent and missing selector.
  • The federated call site, which had zero coverage; asserts the handler reaches state: 'ready', not just the spy.

Checks: tsc clean (node/cli/web); oxlint code-quality native + type-aware clean; max-lines ratchet and reliability gates pass; PR CI green.

Not verified by hand: I don't have the Cursor Agent CLI installed, so the end-to-end desktop-vs-CLI launch is covered by spawn-level assertions rather than a live run.

Out of scope

Two pre-existing issues surfaced during review and deliberately left alone, as neither is caused by this change:

  1. detectUnsupportedRuntimes is never enforced, so --agent claude-agent-teams builds a launch on Windows despite win32 being marked unsupported. Shared with worktree create --agent.
  2. agent-catalog.tsx shows detectCmd in the settings override placeholder, so editing from it drops required flags (kiro-cli vs kiro-cli chat --tui).

…t id

worker-start passed the Orca agent id straight to the shell as the worker
terminal command. That only worked for agents whose id matches their launch
command; `--agent cursor` ran `cursor`, which on Windows resolves to Cursor
IDE's cursor.cmd and opened the desktop app, leaving a blank shell that timed
out at agent_readiness. The same gap hit continue/aug/kiro/qwen-code and the
other agents whose CLI binary differs from their id.

Add TerminalCreateOptions.startupAgent so a caller can name the agent outright.
createTerminal then builds the launch through the TUI agent config (command,
default args/env, preflight trust) instead of sniffing the command string, and
this also covers repo-less folder workspaces, which previously skipped
resolution entirely.

Fixes #11926
@greptile-apps

greptile-apps Bot commented Aug 3, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR fixes a Windows-specific bug where orca orchestration worker-start --agent cursor launched the Cursor desktop IDE instead of the cursor-agent CLI, because the agent id was passed verbatim as a shell command. The fix introduces TerminalCreateOptions.startupAgent so callers declare the agent by id and the runtime resolves the correct launch command, arguments, environment, and preflight trust markers from the TUI agent configuration.

  • Core fix (orca-runtime.ts): resolveAgentTerminalCreateOptions now has a dedicated startupAgent branch that resolves the id through buildAgentStartupPlan, validates against the disabled-agent list, and throws loudly if no plan is found — rather than silently spawning a bare shell that times out at agent_readiness.
  • Call sites (orchestration-worker-topology.ts, orchestration-federation.ts): Both createExistingWorktreeWorkerTerminal and the federated attach path switch from command: agent to startupAgent: agent.
  • Side benefits: Folder workspaces (where workspace.repo is null) are now correctly resolved, and isRemote derivation is fixed to use connectionId when no repo is present.

Confidence Score: 5/5

Safe to merge. The change is narrowly scoped to how agent ids are translated to launch commands, both existing code paths are covered by updated and new tests, and the fix is directly verified at the spawn level.

The root cause was a missing id-to-command translation step that the new startupAgent option closes cleanly. Conflict detection, disabled-agent guarding, and explicit failure on unresolvable plans all prevent the silent-timeout regression from recurring. Eight new unit tests and an end-to-end federation test cover all branches.

Files Needing Attention: No files require special attention.

Important Files Changed

Filename Overview
src/main/runtime/orca-runtime.ts Adds startupAgent to TerminalCreateOptions and extends resolveAgentTerminalCreateOptions to resolve an agent id to its configured CLI launch, with conflict detection, disabled-agent guard, and explicit error on unresolvable plan; also fixes folder workspace isRemote derivation.
src/main/runtime/rpc/methods/orchestration-worker-topology.ts Switches createExistingWorktreeWorkerTerminal from command: args.agent to startupAgent: args.agent, routing the agent id through the runtime's launch resolver instead of passing it as a raw shell command.
src/main/runtime/rpc/methods/orchestration-federation.ts Same one-line change as the topology file: the federated attach path now uses startupAgent instead of command when creating the worker terminal for an existing worktree.
src/main/runtime/orca-runtime.test.ts Adds eight new tests covering: correct CLI resolution for cursor, Windows cmd.exe quoting, platform-aware launcher name (claude-agent-teams), agentCmdOverrides honoring, selector-less rejection, folder workspace coverage, conflicting-options rejection, and disabled-agent rejection.
src/main/runtime/rpc/methods/orchestration-federation-agent-launch.test.ts New test file verifying the federated federationAttachStart handler calls createTerminal with startupAgent (not command) and that the worker reaches ready state end-to-end.
src/main/runtime/rpc/methods/orchestration.test.ts Updates existing workerStart assertion from command: 'codex' to startupAgent: 'codex' and adds a new regression test asserting cursor never appears as a raw shell command.

Reviews (5): Last reviewed commit: "fix(orchestration): reject a startupAgen..." | Re-trigger Greptile

@coderabbitai

coderabbitai Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The runtime now accepts startupAgent separately from shell commands. It resolves explicit agents in repository and repo-less workspaces, validates launch settings and disabled agents, and reports missing launch plans. Federated and existing-worktree terminal creation pass agent identities through startupAgent. Tests cover Cursor resolution, platform-specific executable selection, workspace trust, validation failures, disabled agents, and worker-start behavior.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes satisfy issue #11926 by resolving the configured agent ID to its CLI launch plan and preventing raw agent commands on Windows.
Out of Scope Changes check ✅ Passed The runtime changes, orchestration updates, and regression tests are directly related to the linked issue and stated pull request objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly identifies the primary fix: launching the configured agent CLI instead of the raw agent ID.
Description check ✅ Passed The description clearly covers the problem, implementation, testing, cross-platform behavior, risks, and out-of-scope follow-up.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1a86bf35-3f60-4bd3-b4ed-fe4d721ba9da

📥 Commits

Reviewing files that changed from the base of the PR and between 1685b96 and 3e38d67.

📒 Files selected for processing (5)
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/methods/orchestration-federation.ts
  • src/main/runtime/rpc/methods/orchestration-worker-topology.ts
  • src/main/runtime/rpc/methods/orchestration.test.ts

Comment thread src/main/runtime/orca-runtime.ts Resolved
OrcaWin added 3 commits August 2, 2026 17:37
…olve

The guard ordering let a caller that set startupAgent together with a
caller-supplied launch (env/launchConfig/launchAgent/startupCommandDelivery/
claudeAgentTeamsSourceCommand), a raw command, a resume session, or that hit an
unavailable store, fall through with an unresolved command and spawn a bare
shell — the exact silent timeout at agent_readiness that startupAgent exists to
prevent. No current caller does this, so it was latent rather than live.

Those combinations now throw instead. A raw `command` counts as a contradiction
because it would be silently overwritten by the built launch, and
`resumeProviderSession` because it survives to spawn and would pair resume
identity with a freshly built fresh-launch command.

The non-startupAgent path is unchanged: verified bit-for-bit over all 256
combinations of the eight guard inputs.

Also covers the repo-less folder-workspace branch with a test, which the new
isRemote fallback made reachable for the first time.
Three gaps found in adversarial review of the previous two commits:

- The federated worker terminal create had zero coverage. Added a test that
  drives orchestration.federationAttachStart to that call site; verified it is
  not vacuous by reverting the call site and watching it fail.
- The Windows assertion was platform-insensitive: `cursor` has no
  launchCmdByPlatform and the prefix regex would have passed on any OS. It now
  asserts the full cmd.exe-quoted command.
- No agent whose launcher name varies by platform was covered. Added a matrix
  over claude-agent-teams (orca.cmd / orca-ide / orca claude-teams), the only
  agent with launchCmdByPlatform, which proves resolution is platform-aware.

Also extended the conflict table to all six caller-supplied-launch operands
rather than the four that happened to differ.
…ared default

The exact-string assertion inherited `--yolo` from the shared
YOLO_TUI_AGENT_ARGS map, so an unrelated change to cursor's default args would
break a test that exists to check cmd.exe quoting. Pin the arg in the test
instead.

Verified the assertion is genuinely platform-sensitive: flipping setPlatform to
darwin fails it on the quote style ('--force' vs "--force").

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/main/runtime/rpc/methods/orchestration-federation-agent-launch.test.ts (1)

6-9: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Reduce this comment to one concise line.

Keep the Windows Cursor regression context and issue reference. Remove the step-by-step explanation.

Suggested revision
-// Why: a federated worker terminal is created from an agent id. Passing that id
-// as a shell command launched Cursor's desktop app instead of `cursor-agent`
-// (issue `#11926`), so the remote path must resolve through the TUI agent config
-// exactly like the local one.
+// Resolve federated agent IDs through `startupAgent` to avoid Cursor Desktop on Windows (`#11926`).

As per coding guidelines, comments must be concise, limited to non-obvious information, and preferably one line.

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2f3b0b12-2865-4720-8501-950f5e372343

📥 Commits

Reviewing files that changed from the base of the PR and between b9cf69a and 7615df7.

📒 Files selected for processing (2)
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/rpc/methods/orchestration-federation-agent-launch.test.ts

OrcaWin added 2 commits August 2, 2026 17:50
Anyone who worked around this bug by pointing agentCmdOverrides.cursor at their
own cursor-agent path must keep that override once the id resolves properly.
Verified it survives: `cursor-agent --beta '--force'`.

Also trims the conflict-guard comment to the repo's brevity rule; no logic
change.
…lector

Two findings from adversarial review of the previous commits:

- createTerminal resolves the launch against a workspace, so with no selector
  `startupAgent` was silently dropped and the terminal came up as a bare shell —
  the failure this option exists to prevent. Now rejected up front, before any
  window or PTY work. Not reachable from either current call site, so this
  closes a future-caller trap rather than a live bug.

- The federated worker test asserted only on the createTerminal spy, so it
  stayed green while the handler actually returned
  state:"failed"/stable_pane_required: the pane getters were never stubbed. It
  now stubs them and asserts state:"ready", so it covers every stage rather than
  just terminal_create. Re-verified it still fails when the call site is
  reverted to `command:`.
@OrcaWin
OrcaWin merged commit 95c431f into main Aug 3, 2026
43 checks passed
u20024804 pushed a commit to u20024804/orca that referenced this pull request Aug 4, 2026
…nt matrix

Upstream stablyai#12148 added a platform matrix asserting win32 resolves to
'orca.cmd claude-teams'. This change deliberately bypasses the Orca CLI
wrapper on Windows — Electron-as-node has no TTY stdin, so the wrapper
cannot run the Claude TUI — and launches 'claude --teammate-mode auto'
directly. Update the win32 expectation to the actual launch command.

Co-Authored-By: Claude Opus 5 <[email protected]>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…ot the raw agent id (stablyai#12148)

Worker-start passed the Orca agent id straight to the shell as the worker terminal command, so `--agent cursor` ran `cursor` — which on Windows resolves to Cursor IDE's cursor.cmd and opened the desktop app, leaving a blank shell that timed out at agent_readiness. The same gap hit every agent whose CLI binary differs from its id (continue/aug/kiro/qwen-code/mistral-vibe/antigravity/trae/mimo-code/hermes/command-code/claude-agent-teams).

Adds TerminalCreateOptions.startupAgent so callers name the agent outright; createTerminal then builds the launch from the TUI agent config (command, agentCmdOverrides, default args/env, preflight trust) instead of sniffing the command string. Also covers repo-less folder workspaces, which previously skipped resolution entirely, and fails loudly instead of spawning a bare shell when an explicit agent cannot resolve.

Fixes stablyai#11926
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.

[Bug]: worker-start --worktree current launches Cursor desktop instead of cursor-agent on Windows

1 participant