Repository navigation
Host plans agent launches with the window's runtime rule and one runtime fact (C1) - #27692
Conversation
…me rule and one runtime fact Host-started agent launches now pick their platform with the same rule the window uses (project runtime, else a \\wsl$ path, else the host), and resolve one runtime fact that supplies both the command quoting and the PTY shell. Adds the agent.launch.terminal-inputs.v1 capability and its optional title/extraAgentArgs/requestKind/terminalOnly fields; no sender yet. OpenCode's createAgentSession stays on today's rules until C2 (temporary).
18b8025 to
d12a54e
Compare
…quoted commands carry it
Round-1 review fixes for C1:
- Window and host read a workspace's runtime through one shared resolver
(local-workspace-execution-runtime.ts); a repo-less \\wsl$ folder gets no
runtime, as in the window.
- The fact is { platform, remote, pty } with the spawn's own PTY type; the
quoting shell is derived from it, never stored.
- createAgentSession uses the same fact (its pre-C1 exception is deleted).
- Worktree startups quote from a fact for the repo and pass it on; a runtime
that needs repair fails the startup, not the create. `shell` is required
when building a launch command.
- The host planner stamps a fact only on commands quoted with it; a
caller-quoted command keeps the spawn's own rule.
- Qoder probes where the process runs (\\wsl$ cwd, then a WSL shell).
- wslShellRule 'host-legacy' keeps today's WSL-shell outcome where no
project chose a runtime (temporary, removed by C8).
- terminalOnly reaches the early-tab decision with an accurate receipt
sentence; the unused client gate is removed.
- Adds one host C0 row for a \\wsl$ repo with no saved runtime.
ed96cbc to
5326c88
Compare
… resolver, one answer per workspace Problem: the first round still carried request fields and window-parity switches that only the next step sends, added a new shared resolver that also changed window code, and left some background launches using a different runtime answer than the one they spawn with. - Move the agent.launch request fields, their capability and fingerprint handling, and the prompt/Codex parity switches out to the next step; today's host behaviour is kept. - Drop the shared resolver: main's resolveLocalWorkspaceRuntime now finds the project by repo id or source repos, folders borrow their single local repo, and a \\wsl$ path is not refused on a stale distro list. Window code is back to main. - Agents started in an existing worktree use that worktree's answer; the phone's fallback paths spawn with the answer they quoted for, and a runtime that needs repair shows its message instead of a plain shell. - The OpenCode model check looks where the agent will run. - A Windows --shell in a \\wsl$ workspace names the path, not a runtime setting that cannot change it. - The temporary folder rule names its follow-up, STA-10231.
…indows runtime Problem: once a folder follows its repo's WSL runtime, an OpenCode launch that picks a model would be checked and started inside WSL, where Orca cannot yet verify OpenCode models, so picks that work today could be refused. Where main had no runtime for the scope (only folders), a model-picked OpenCode launch keeps main's answer. Start, resume and the worker's model check read the same answer. Temporary until OpenCode models are verified inside WSL.
…s quoted for where they land Problem: round 2's OpenCode exception keyed on a model pick, so a resumed chat could run somewhere other than where it started, and the worker's model check read WSL from the Terminal shell and refused folders that work today. A new worktree's startup used the repo's answer even when the worktree lands in a WSL share. - In a folder whose repo runs in WSL, every OpenCode launch keeps main's Windows answer: create, resume and the worker's model check agree. The model check reads WSL from the path alone, as main did. STA-10251. - A new worktree's startup is planned for its WSL-share base folder when one is set (newWorktreeLaunchScope). - A \\wsl$ working directory runs in WSL whatever the project says, so non-OpenCode agents there are written for Linux. - The planner test derives the answer instead of passing it in. - Smaller shapes for the PTY settings type, the cache-less resolve, executionRuntimePlatform, spawnShellInputs and two comments.
…ides; OpenCode follows the WSL-share fix Problem: OpenCode in a repo on a WSL share whose project is saved as Windows host still got PowerShell quoting typed into WSL, because the WSL-share fix skipped OpenCode. The fix and the two temporary parity rules were also split across two returns, so deleting the temporary ones could take the permanent fix with them. - One expression decides when the path places the agent, each term labelled: WSL share + Windows host (permanent fix), folder + Windows host (STA-10231), OpenCode in a folder (STA-10251). - OpenCode now gets the WSL-share fix too; a model pick there is refused, as main's model check already did. - The OpenCode entry-point tests set a WSL Terminal shell, so the model check test fails if it reads WSL from that shell again. - Tests trimmed with no coverage loss; the spawn-precedence unit test is dropped (the C0 WSL-share row covers the reachable case).
…host-planner # Conflicts: # src/main/runtime/runtime-terminal-contracts.ts
…spawns Live Windows QA (Terminal shell wsl.exe, global default Windows host, repo with no project setting) saw an agent command written with PowerShell quoting typed into a WSL pane, so codex lost the apostrophes in its prompt. The host wrote the command for its own answer (Windows, PowerShell), but on routes where the window spawns the pane (the phone while a window is open, a focused desktop chat create, `orca terminal create --command` in a repo) the window spawned it by the Terminal shell, which is WSL. Quoting and the pane came from two different answers. Those routes ran in WSL with Linux-style quoting on main and worked, so the temporary host-legacy term (STA-10231) now also covers them: when the window spawns the pane, the path and Terminal shell decide, as on main. Background routes keep the approved change (PowerShell instead of cmd.exe with Linux-style quoting, which was broken on main). createTerminal and the pre-launch planning share one `windowSpawnsTerminal` rule so they can't disagree about who spawns the pane.
… window spawns" This reverts commit 3e4311d.
…ot an unknown outcome `orca agent launch` into a folder whose one repo is set to a WSL distro that is no longer installed printed "Orca could not confirm the launch outcome; the agent may already be running", although nothing had started. The host knew the launch was refused before any spawn, but the refusal went out as the generic `runtime_error`, which the CLI must treat as possibly started. The launch planner now raises that refusal under its own code, `project_runtime_repair_required`, with the same message, and the RPC layer passes the code through. The CLI then prints the repair message as a plain failure. Older CLIs read the unrecognised code as a failure too; a newer CLI against an older host still gets `runtime_error`, as before.
…em on a retry The repair refusal from the last commit read "Project runtime requires repair before terminal spawn: wsl-distro-missing", an internal reason code rather than what happened and what to do. It now says, for example, "No agent was started. Ubuntu is not installed in WSL. Choose an installed distro or switch this project to Windows.", adding "This project follows the default in Settings > Project Runtime." when the runtime came from the default. Those sentences are the project settings page's own. They now live in one shared module that maps each repair reason to the page's existing translation key; the settings page passes its translator, and the host writes English, since it also runs headless where the desktop's translations can't load. The planner checks for a repair before the shell lookup, so the shared spawn message, which window spawns still use, is untouched. A retried launch (`--retry-launch`, or a phone resend) used to answer with the bare error code. The failed launch record now keeps the refusal's words and the retry repeats them.
…eep the host's English equal to the window's A retried launch now repeats a coded refusal's own words, but nothing tested it. A new case refuses a launch with a coded error and checks the retry answers with the same words. The repair sentences live in one shared module whose English the host writes and whose keys the settings page translates. The localization checks can't see call sites outside the window and main, so the module's test now checks each sentence against the window's English catalog for its key. Smaller, behaviour-identical tidy-ups: the reason-to-words mapping is a table, the refusal type fits on one line, and the length cap the retry words share with folder refusals has a neutral name.
Status: ready for review (head b21a289)The problem, in one line. On Windows, agents that Orca's background service starts (the What changes for users. Only on Windows, only for background-started agents: a repo on a WSL share gets a Linux-style command and its arguments arrive intact; with the Terminal shell set to WSL, a repo on the Windows host starts in PowerShell with a PowerShell-style command; a folder with one repo uses that repo's runtime (and is refused, in main's words, when that WSL runtime needs repair). Everything else stays as on main. This PR was split (one thing per PR). Five other fixes that were in it are now their own drafts stacked on it, in merge order: #28232, #28233, #28234, #28235, #28236, #28237. Where this PR's new path would otherwise change behaviour for those cases, it keeps main's behaviour with temporary code and a test; each stacked PR removes its own piece. Review. Six full rounds before the split (to 20ce184). After the split: a delta review of the split (no findings), then one review of the whole stack that ran every pin (each passes on its PR and fails on the one below). That review found one change that had crept into this PR: the agent list for a folder in a group tagged for another host. f587ab5 puts that agent list back on main's code ( Folder agent list vs launch. Checked case by case against main (96 probe cases on each): no new disagreement. This PR changes no folder's agent list, and every folder launch it changes now agrees with the list. Six disagreements that main already has are listed in the body under "Known", each with its follow-up. Live QA on Windows (hidden test copies of Orca, real Claude, Codex and OpenCode, WSL Ubuntu-24.04), this PR at 2147865 vs main 1e48f44:
f587ab5 was not re-run live: it only changes the agent list back to main's code, covered by its test. Readiness against current main (4857afd, not merged in): merges cleanly; every touched file is under the line limit; the repo checks pass on the merged code (lint, code quality, typecheck), except one local tool step that cannot start here and that CI runs itself. Main merged in (b21a289): the branch had fallen into conflict with main, so main (0903ed9) was merged in once, as a merge commit. One file conflicted, CI: green on b21a289 (26 pass, 0 fail). Main's replay-test breakage that was red on f587ab5 was fixed by #28286. Not verified: macOS, Linux and SSH hosts live (nothing changes there; covered by tests); the window's "+" tab and the phone with a window open (unchanged in this PR); the share-folder and repo-id edge cases of the stacked PRs live (they need hand-made data). |
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to
|
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟡 Minor · Preserve the refusal message for replayed launches. · agent-launch.ts:248
src/main/runtime/rpc/methods/agent-launch.ts:248
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winPreserve the refusal message for replayed launches.
When an OpenCode
create-worktreeor reused-terminal launch includes unsupported model or session preferences,resolveUnlaunchedIntentthrows anOrchestrationErrorwith a specific refusal message. This catch stores only the error code, so retrying the same operation ID returns a generic message instead of the original refusal.Suggested fix
- await settleQuietly(admission.fail(agentLaunchFailureCode(error))) + await settleQuietly(admission.fail(agentLaunchFailureCode(error), error))
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
13010826-c3b7-42cf-9904-27ff213da5af
📒 Files selected for processing (49)
src/main/ipc/pty-launch-parity-host.test-cases.tssrc/main/ipc/pty/runtime/spawn-preflight.tssrc/main/ipc/pty/runtime/spawn-state.tssrc/main/local-project-runtime-resolution.tssrc/main/opencode/opencode-model-startup-plan.test.tssrc/main/preflight/workspace-agent-detection.tssrc/main/runtime/agent-launch-scope-runtime.test.tssrc/main/runtime/agent-launch-scope-runtime.tssrc/main/runtime/opencode-wsl-folder-launch-host.test.tssrc/main/runtime/orca-runtime-activate-managed-worktree.tssrc/main/runtime/orca-runtime-create-agent-session.tssrc/main/runtime/orca-runtime-create-managed-worktree.tssrc/main/runtime/orca-runtime-create-runtime-owned-mobile-session-terminal.tssrc/main/runtime/orca-runtime-create-terminal-dependencies.tssrc/main/runtime/orca-runtime-create-terminal.tssrc/main/runtime/orca-runtime-get-agent-session-execution-namespace.tssrc/main/runtime/orca-runtime-get-terminal-interactive-wait.tssrc/main/runtime/orca-runtime-perform-mobile-session-pty-records-refresh.tssrc/main/runtime/orca-runtime-resolve-mobile-session-terminal-command.tssrc/main/runtime/orca-runtime-resolve-worktree-removal-target.tssrc/main/runtime/orca-runtime-restore-structured-agent-session-tabs-once.tssrc/main/runtime/orca-runtime-run-create-mobile-session-terminal.tssrc/main/runtime/orca-runtime-terminal-create-deduplication.tssrc/main/runtime/qoder-terminal-command-resolution.tssrc/main/runtime/rpc/errors.tssrc/main/runtime/rpc/methods/agent-launch-execution-outcome.tssrc/main/runtime/rpc/methods/agent-launch-failure-code.tssrc/main/runtime/rpc/methods/agent-launch-pane-reservation.test.tssrc/main/runtime/rpc/methods/agent-launch-replay.tssrc/main/runtime/rpc/methods/agent-launch.tssrc/main/runtime/runtime-agent-launch-resolution.tssrc/main/runtime/runtime-agent-terminal-startup.test.tssrc/main/runtime/runtime-agent-terminal-startup.tssrc/main/runtime/runtime-folder-worktree-create.tssrc/main/runtime/runtime-local-worktree-terminal-startup.tssrc/main/runtime/runtime-pty-controller-contract.tssrc/main/runtime/runtime-terminal-contracts.tssrc/main/runtime/runtime-worktree-agent-startup.test.tssrc/main/runtime/runtime-worktree-agent-startup.tssrc/main/runtime/terminal-shell-override-host-support.tssrc/renderer/src/components/settings/ProjectWindowsRuntimeSetting.tsxsrc/renderer/src/i18n/en-runtime-required.jsonsrc/renderer/src/i18n/project-runtime-repair-message.test.tssrc/renderer/src/lib/launch-agent-background-session.tssrc/shared/agent-launch-runtime.tssrc/shared/agent-startup-plan-inputs-extra-agent-args.test.tssrc/shared/agent-startup-plan-inputs.test.tssrc/shared/agent-startup-plan-inputs.tssrc/shared/project-runtime-repair-message.ts
💤 Files with no reviewable changes (1)
- src/main/runtime/qoder-terminal-command-resolution.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
|
On the outside-diff note about |
|
Status: back to draft. This PR is being split into smaller stacked PRs so each one does one thing: this PR keeps the core (one runtime answer per launch, so a command's quoting and its shell always agree), and the earlier refusal for a WSL setup that needs repair, the |
… change it The repair refusal's own code and words, the \\wsl$ path's distro in the agent list, --shell refusals for agents (decision and words), OpenCode's model check in a \\wsl$ repo, and finding a repo's project by its id move to their own stacked PRs. Until they land, each keeps main's behaviour with temporary code and a test that pins it. A disabled agent is refused as disabled before its runtime is looked at again, as on main.
…names another host The agent list for a folder reads the folder's own host pin, as on main; only launches also read the containing group's host tag.
…core-split-local # Conflicts: # src/main/runtime/runtime-terminal-contracts.ts
…untime its build now returns
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟠 Major · Quote the agent startup command for the effective… · runtime-agent-terminal-startup.ts:119-139
src/main/runtime/runtime-agent-terminal-startup.ts:119-139
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy liftQuote the agent startup command for the effective startup cwd when that cwd is a WSL share.
When
startupAgentis set,opts.cwdis a\\wsl$path outside the workspace, and the workspace runtime is Windows, the planner still quotes the agent command for the workspace runtime. The PTY then starts underwsl.exefrom the startup cwd. The command can reach the WSL shell with PowerShell-style quoting, which can corrupt its arguments.The runtime comes from
resolveAgentLaunchRuntime(store, workspace, opts.shellOverride, plannedAgent), not from the startup cwd. The startup cwd isresolveTerminalStartupCwd(workspace.path, opts.cwd) ?? workspace.path, and that value is not constrained to the workspace. The Windows-host WSL exception checks only the workspace path. Choose the runtime from the effective startup cwd, or refuse when the runtime and the WSL-share cwd disagree. Changing only the session-creation caller leaves this path unchanged, because this path resolves its own runtime.
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
49a7b42b-dc7b-495c-9cca-1dfc5febe9ed
📒 Files selected for processing: 11
src/main/ipc/pty/runtime/spawn-state.tssrc/main/runtime/orca-runtime-activate-managed-worktree.tssrc/main/runtime/orca-runtime-create-agent-session.tssrc/main/runtime/orca-runtime-create-terminal.tssrc/main/runtime/orca-runtime-get-agent-session-execution-namespace.tssrc/main/runtime/orca-runtime-resolve-worktree-removal-target.tssrc/main/runtime/runtime-agent-terminal-startup.tssrc/main/runtime/runtime-local-worktree-terminal-startup.tssrc/main/runtime/runtime-pty-controller-contract.tssrc/main/runtime/runtime-terminal-contracts.tssrc/main/runtime/runtime-worktree-agent-startup.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
| const launchRuntime = this.resolveAgentLaunchRuntime(workspace, request.agent) | ||
| const startupArgs = resolveAgentStartupPlanInputs({ | ||
| agent: request.agent, | ||
| settings, | ||
| platform: this.getAgentLaunchPlatformForWorkspace(workspace), | ||
| platform: launchRuntime.platform, | ||
| shell: agentLaunchQuotingShell(launchRuntime), |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '95,160p' src/main/runtime/orca-runtime-create-agent-session.ts
sed -n '185,205p' src/main/runtime/orca-runtime-create-agent-session.ts
sed -n '15,55p' src/shared/terminal-startup-cwd.tsRepository: stablyai/orca
Length of output: 6001
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- changed hunk and relevant callers ---'
git diff --no-ext-diff --unified=35 0903ed9577fc46ce29e34ea49924dfa4fb5dc1ad b21a2899cdfdf32d27a5e2e9f3d9d1027cc04eb2 -- src/main/runtime/orca-runtime-create-agent-session.ts src/main/runtime/runtime-agent-terminal-startup.ts src/main/runtime/agent-launch-scope-runtime.ts src/main/providers/local-pty-launch-plan.ts
printf '%s\n' '--- request validation and startup CWD bindings ---'
rg -n -F --glob '*.ts' -e 'startupCwd' -e 'resolveWorkspaceTerminalStartupCwd' -e 'resolveAgentLaunchRuntime' src/main src/shared | head -160
printf '%s\n' '--- runtime resolver and PTY launch blocks ---'
rg -n -F --glob '*.ts' -e 'function resolveAgentLaunchRuntime' -e 'resolveAgentLaunchRuntime(' -e 'shellPath = ' -e 'wsl.exe' -e 'isWslUncPath' src/main | head -200
printf '%s\n' '--- exact source excerpts ---'
sed -n '1,240p' src/main/runtime/agent-launch-scope-runtime.ts
sed -n '150,245p' src/main/providers/local-pty-launch-plan.ts
sed -n '1,220p' src/main/runtime/runtime-agent-terminal-startup.tsRepository: stablyai/orca
Length of output: 43018
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- runtime helper contracts ---'
rg -n -F --glob '*.ts' -e 'export function agentLaunchQuotingShell' -e 'function agentLaunchQuotingShell' -e 'type AgentLaunchRuntime' -e 'interface AgentLaunchRuntime' src/shared src/main
sed -n '1,180p' src/shared/agent-launch-runtime.ts
printf '%s\n' '--- launchRuntime propagation and PTY projection ---'
rg -n -F --glob '*.ts' -e 'launchRuntime' -e 'terminalWindowsWslDistro' src/main/runtime src/main/providers src/main | head -220
rg -n -F --glob '*.ts' -e 'resolveLocalPtyOptions' -e 'resolvePlainTerminalPtyOptions' src/main
printf '%s\n' '--- request schema and effective CWD ---'
rg -n -F --glob '*.ts' -e 'RuntimeCreateAgentSessionRequest' -e 'startupCwd' src/shared src/main | head -180
sed -n '1,180p' src/shared/agent-session-host-authority.ts
printf '%s\n' '--- shell override refusal and runtime repair ---'
sed -n '1,240p' src/main/runtime/terminal-shell-override-host-support.ts
rg -n -F --glob '*.ts' -e 'runtime_needs_repair' -e 'needs repair' -e 'resolveLocalPtyOptions' src/main/local-project-runtime-resolution.ts src/main | head -160Repository: stablyai/orca
Length of output: 41811
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- shared runtime helper ---'
rg -n -F --glob '*.ts' -e 'agentLaunchQuotingShell' -e 'AgentLaunchRuntime' src/shared src/main | head -120
sed -n '1,180p' src/shared/agent-launch-runtime.ts
printf '%s\n' '--- exact launchRuntime consumers ---'
rg -n -F --glob '*.ts' -e 'launchRuntime' src/main | head -240
printf '%s\n' '--- local runtime resolution ---'
rg -n -F --glob '*.ts' -e 'function resolveLocalPtyOptions' -e 'export function resolveLocalPtyOptions' -e 'resolveLocalPtyOptions(' -e 'resolvePlainTerminalPtyOptions' src/main
sed -n '1,260p' src/main/local-project-runtime-resolution.ts
printf '%s\n' '--- request contract ---'
rg -n -F --glob '*.ts' -e 'RuntimeCreateAgentSessionRequest' -e 'startupCwd' src/shared/agent-session-host-authority.ts src/main | head -180
printf '%s\n' '--- refusal path ---'
sed -n '1,260p' src/main/runtime/terminal-shell-override-host-support.tsRepository: stablyai/orca
Length of output: 42133
Resolve the launch runtime from the effective startup CWD.
startupCwd can be a \\wsl$ path outside the workspace. The session currently quotes the command from the Windows workspace runtime, then passes that runtime with the WSL CWD to terminal creation. The local provider starts wsl.exe for that CWD, so the Windows-quoted command can be interpreted by a Linux shell.
Pass the effective CWD to runtime selection. Keep project-runtime resolution on the original workspace so repair-required runtimes still refuse before spawning.
Suggested fix
diff --git a/src/main/runtime/agent-launch-scope-runtime.ts b/src/main/runtime/agent-launch-scope-runtime.ts
@@
export function agentLaunchProjectRuntime(
store: LaunchScopeRuntimeStore,
scope: TerminalWorkspaceLaunchScope,
- agent: TuiAgent | undefined
+ agent: TuiAgent | undefined,
+ effectiveCwd = scope.path
): ProjectExecutionRuntimeResolution | undefined {
@@
- (onWindowsHost && isWslUncPath(scope.path)) ||
+ (onWindowsHost && isWslUncPath(effectiveCwd)) ||
@@
export function resolveAgentLaunchRuntime(
store: AgentLaunchRuntimeStore,
scope: TerminalWorkspaceLaunchScope,
requestedShellOverride: string | undefined,
- agent: TuiAgent | undefined
+ agent: TuiAgent | undefined,
+ effectiveCwd = scope.path
): AgentLaunchRuntime {
@@
- const projectRuntime = agentLaunchProjectRuntime(store, scope, agent)
+ const projectRuntime = agentLaunchProjectRuntime(store, scope, agent, effectiveCwd)
return {
- platform: executionRuntimePlatform(projectRuntime, scope.path, process.platform),
+ platform: executionRuntimePlatform(projectRuntime, effectiveCwd, process.platform),Update the agent-session caller and its runtime wrapper to pass startupCwd ?? workspace.path.
ELI5
Orca can start an agent (Claude, Codex, …) in a terminal two ways. The window starts it in a tab (the "+" button). Or the app's background service starts it: the phone, the
orcaCLI, orchestration workers, automations,worktree createwith a startup agent, resume, and new agent tabs from a paired desktop or the web client. Each side decides by itself whether the agent runs on Windows or in WSL, and they don't always agree. Worse, the background service picks how to write the command from one setting and which shell runs it from another, so a command can be written for one shell and typed into a different one, which mangles its arguments.This PR makes the background service decide the same way the window does, once per launch, and use that one answer both to write the command and to pick the shell it is typed into.
C-numbers below are steps of the launch-convergence plan: C0 is the characterization tests already on main; C2 is the next step, which moves the window's tab launches and the new
agent.launchinputs onto this background path.What Changed
The problem. The window picks where an agent runs from the project's saved runtime, then a
\\wsl$\…path, then the global default (Settings > Project Runtime). The background service had an older rule that:\\wsl$\Ubuntu\…with no WSL setting as Windows, so it writes the command for a Windows shell while the agent actually runs in WSL;cmd.exe.What you'll see differently. Only on Windows, and only for agents the background service starts. Agents started from a window tab, plain terminals, and everything on macOS, Linux and SSH hosts behave as before, with one exception: an OpenCode tab with a picked model opened from the desktop is started by the background service, so change 2 applies to it (in the folders under the temporary OpenCode difference below, it keeps today's behaviour).
\\wsl$\…) with no runtime setting of its own: its agents' commands are now written for Linux and the terminal is told it is WSL. The agent already ran in WSL; now its arguments arrive intact. The same goes for a repo stored elsewhere whose worktrees live in a WSL share: agents that automations and workers start in such a worktree, and a new worktree's startup agent, are written for Linux, matching where they run. A\\wsl$working directory always runs in WSL, so this holds even when the project is set to the Windows host; before, those commands were written for the Terminal shell, which broke them unless that shell was WSL. This also covers a plain folder (not a git repo) added as a project from a WSL share: with the Terminal shell set to PowerShell, its agents used to get a PowerShell-style command inside WSL; now the command is written for Linux.cmd.exe. What changes is how the command is written, per route:orca agent launch/agent.launch, a chat created in the background, the phone with no window open, orchestration workers, server-run automations, resume, a new worktree's startup agentcmd.exewith a Linux-style command: brokenorca terminal create --command <agent>in a repoA new worktree's startup agent whose worktree lands in a WSL share runs in WSL instead (change 1). A folder holding one such repo keeps today's behaviour on every route (temporary, see below).
3. A folder workspace holding exactly one repo now uses that repo's project runtime. If that project runs in WSL (its own setting or a WSL global default), the folder's agents now start in WSL, in that runtime's distro rather than the Terminal shell's. OpenCode is the exception (see the temporary differences below). Chats the background service started in such a folder before this change ran on Windows; resuming one now runs it in WSL. Chats the window started there were already in WSL. One more consequence:
orca terminal create --shell <a Windows shell>with an agent in such a folder is now refused when the repo's runtime is WSL, with the existing message for a project that runs in WSL. Before, the agent started in the requested shell; now that the agent runs in WSL, accepting the request would silently swap the shell for WSL, which--shellexists to prevent.4. A folder holding one repo whose WSL runtime needs repair (the distro is not installed, or WSL is unavailable): this follows from change 3. An agent the background service starts in such a folder is now refused, instead of starting in the Terminal shell. That covers
orca agent launch/agent.launch, chats created throughcreateAgentSession(including the desktop's OpenCode-with-model tab), the phone (with or without a window open), orchestration workers, automations and resume. The phone's refresh shows the same refusal instead of a plain shell under the agent's icon. The refusal uses the words a repo with a broken runtime already gets on main ("Project runtime requires repair before terminal spawn: wsl-distro-missing"), andorca agent launchprints the same "Orca could not confirm the launch outcome" line it prints for such a repo on main. That line wrongly suggests the agent may be running and offers a retry, though nothing started; the stacked S1 replaces it with a plain "No agent was started" sentence. OpenCode is excepted (see the temporary differences below). Launches the window spawns itself are unchanged:orca terminal create --command <agent>(the host does not plan a typed command in a folder) and the desktop's own "+" tab. Creating a workspace with a startup agent behaves as on main: a folder project (a repo added as a plain folder, without git) is still created and the startup's failure comes back as the create's warning; a git repo whose runtime needs repair is refused earlier, at git, with no workspace created. The refusal now happens while the launch is planned, before anything spawns, because the shell is decided once there; the words and the outcome are main's.Worktree startup agents. Two cases that used to break are fixed when the background service creates the worktree (
orca worktree create --agent, automations, the phone,agent.launchcreating a workspace): a startup agent in a worktree on a WSL share no longer gets a PowerShell-quoted line in WSL's bash, and with the Terminal shell set to WSL and the project on the Windows host it no longer gets a Linux-style line incmd.exe. A startup the window builds itself (the desktop's new-worktree dialog) is unchanged until C2.Mechanism.
resolveLocalWorkspaceRuntime(local-project-runtime-resolution.ts) to read like the window: the project is found by its source repos, as on main (the window also takes a project named after the repo; that moves to a stacked PR), a folder borrows its single local repo (findLocalFolderWorkspaceRuntimeRepo, which also checks the folder and its group are on this machine), a repo-less folder has no runtime, and for a launch a\\wsl$path with no saved runtime is not checked against main's distro list (main never refused these launches, because it read such a repo as Windows; the agent list still checks it, as on main). Window code is unchanged, apart from one line passingshell: undefinednow that the input is required (the window quotes by the Settings shell its tab's spawn also reads).AgentLaunchRuntime { platform, pty }(src/shared/agent-launch-runtime.ts), whereptyis the spawn's own shell-and-distro type. The command's quoting style is computed from it (agentLaunchQuotingShell), never stored, so it cannot disagree with the shell. Plain terminals and agents use one PTY function (resolveLocalPtyOptions).runtime-agent-terminal-startup.tsis the path every host terminal create goes through. An agent the host plans (asked for by name, or a typed bare command) is quoted from the runtime answer, and that answer rides in memory into the PTY spawn (spawn-preflight.tstakes the shell only from it). A command the caller wrote itself keeps today's spawn rule unless the caller passes the answer it used. Qoder's two-name check runs once here and probes where the process runs: a\\wsl$working directory first, then a WSL shell. The window's own Qoder check stays until C2.agent.launch, phone sessions (including the stalled-window fallback and the refresh path), resume,createAgentSession, worktree-create startups, automations and workers. An agent started in an existing worktree uses that worktree's answer. A new worktree's startup is planned before the worktree exists, so it uses where the worktree will land: its WSL-share base folder when one is set, else the repo (newWorktreeLaunchScope).shellis now a required input of the launch-command builder; the compiler enforces it in the typed planner files, and the other host callers (several runtime files skip type checking) were checked by reading.runtime-agent-terminal-startup.ts; it now runs before the runtime is looked up, so a disabled agent in a project whose runtime needs repair is refused as disabled, as on main (the earlier head of this PR gave the repair error first). A test pins it.Why
One rule and one answer remove the class of bug where a command's quoting and its shell come from different places, instead of patching each caller. The host resolves with main's own WSL data on purpose: the window's WSL facts are an earlier copy that can disagree before its first load, after its 30-second cache, or after an IPC failure. Alternatives considered: keeping two rules and syncing them (that is today's drift); a new shared resolver for both sides (more code, and it would change the window in a step meant to change only the host).
Approved departures from the plan (10-11)
agent.launchrequest fields (title,extraAgentArgs,requestKind,terminalOnly), their capability, their fingerprint handling, and the two window-parity switches (prompt on the command line, Codex waiting for the shell). C2 has their first sender; this PR keeps today's host behaviour for all of them.\\wsl$path and is never refused for repair.createAgentSession.runtime-agent-terminal-startup.ts.Rules that differ from the window or from a plain reading of the settings
The first three are in
agentLaunchProjectRuntime(agent-launch-scope-runtime.ts); the others name their file. Only the first row is permanent; it is a fix, not parity, and must stay when the temporary rows are removed.\\wsl$working directory in WSL whatever the setting says.\\wsl$path as WSL (orca-runtime-get-terminal-interactive-wait.ts).\\wsl$path with no saved runtime is not checked against Orca's cached distro list, but the agent list the phone, web and desktop show for such a worktree still is, as on main (trustsWslPathinlocal-project-runtime-resolution.ts).orca terminal create --shellwith an agent is refused if main's project-only runtime refuses it, before the agent's own runtime is checked (runtime-agent-terminal-startup.ts). So--shell wsl.exefor an agent in a\\wsl$repo saved as Windows host, or with no setting and a Windows-host default, is still refused. The refusal's words stay main's.\\wsl$repo not set to WSL: the model is checked on Windows, as on main, while the command is written for Linux, where OpenCode runs (openCodeModelCheckPlatform, used by the shared planner andcreateAgentSession).local-project-runtime-resolution.ts). Only differs for a project named after a repo that no longer lists it; projects Orca builds itself never look like that.runtime-agent-terminal-startup.ts).Known: a folder's agent list and its launch can disagree, unchanged from main
Checked case by case against main (96 probe cases on each). This PR changes no folder's agent list; where it changes a folder's launch, the launch now agrees with the list. These disagreements remain exactly as on main:
Size
Net production +455, tests +412 (against the main this branch merged; the automatic line-count table counts the 8-line C0 test-cases file as production, so it shows 8 more production and 8 fewer test lines).
workspace-agent-detection.tsis now identical to main; that file had dropped 14 net lines), plus one test that pins it (+18).History
Normal pushes only; no history rewrite since round 1. 2147865 moved the side fixes out to stacked PRs (a normal push). f587ab5 restored main's folder agent list, which the earlier head had changed by also reusing the launch lookup there (a normal push). Main was merged twice: once before the split (one import conflict in
runtime-terminal-contracts.ts, both kept), and again at b21a289 after the branch fell into conflict (one conflict in the same file: main's account-environment field and this PR's launch runtime field, both kept; plus one main test given the now-required runtime field).Stacked on this PR
Each is a draft with one change, stacked in this order:
\\wsl$worktree trusts the path's distro instead of Orca's cached list, which can be out of date.orca terminal create --shell wsl.exefor an agent in a\\wsl$repo runs instead of being refused.--shellrefusal names the\\wsl$path first, and names Settings > Project Runtime when the runtime comes from the default.\\wsl$repo is refused, instead of being checked on Windows while OpenCode runs in WSL.Linked Issue
Part of the launch-convergence plan (step C1). Follow-ups for the temporary differences: STA-10231 (WSL Terminal shell in folders), STA-10251 (OpenCode in WSL folders). Not changed here, as on main:
orca worktree create --agentstill prints "could not confirm" when the workspace was created but its agent was refused; a "workspace created, agent refused" answer is its own design question.Visual Proof
No new UI. Live QA on Windows (a hidden test copy of Orca with an isolated profile and real Claude/Codex; WSL Ubuntu-24.04), main 57a7c22 vs this PR (final rows on 20ce184). Re-QA of this head (2147865) against main 1e48f44 for the rows the split touched (hidden test copies, real Codex/Claude/OpenCode): the
--shellrefusals, the OpenCode picked-model refusal and the disabled-agent refusal read word for word as on main, including a disabled startup agent in a folder whose WSL runtime needs repair ("Agent codex is disabled. Choose an enabled agent.", before any repair message); an agent started in a folder whose one repo is set to a WSL distro that isn't installed is refused (main starts it on Windows), as change 4 says; W1 and W2 below are still fixed on this head.W2: Terminal shell set to WSL, a repo with no runtime of its own, global default Windows host, a worktree created with a startup agent and the prompt
it's W2: reply OK.Before (main): a Command Prompt pane with a Linux-style command, so Claude received
--dangerously-skip-permissionsas its message and the prompt was lost.After: a PowerShell pane with a PowerShell-style command; Claude receives
it's W2: reply OKand answers.W1 (worktree-create startup in a repo on a WSL share, Codex, prompt
it's a C1 test: reply with exactly the words 'two spaces' here; WSL panes render blank in hidden screenshots, so this is the argument list Codex received):its a C1 test: reply with exactly the words two spaces here(apostrophes lost)it's a C1 test: reply with exactly the words 'two spaces' hereTesting
New tests cover what later steps rely on: the runtime rule on the host (repo with a WSL project, folder holding one WSL repo, repo-less folder), main's distro list refusing a saved distro it doesn't know while a
\\wsl$repo is never refused at launch, the answer quoting for the shell the terminal gets, a\\wsl$path placing the agent whatever the setting, the temporary folder rule, OpenCode in a WSL folder staying on Windows at each entry point (create, resume, the worker's model check), the host path deriving the answer, quoting from it and handing it to the spawn, Qoder probing where it runs, a worktree startup quoting from its answer, a folder whose one repo's WSL distro is gone refused by the real planner through the real chat-create request with main's words, and a disabled agent refused as disabled before a runtime that needs repair. Each temporary behaviour kept from main has its own test (agent list distro check,--shellrefusal, OpenCode model check, project lookup); each stacked PR flips its test. The spawn taking its shell only from the answer is covered end to end by the C0 row below. Each was checked by breaking its production line and seeing it fail.Not tested: the OpenCode model-check test (picking a model in a
\\wsl$repo still checks it on Windows, as on main) runs throughcreateAgentSessiononly; the same check in the shared launch planner (runtime-agent-terminal-startup.ts, the routeorca agent launch --modeland C2's OpenCode tab use) was verified by reading the code, and live by the Windows re-QA row fororca agent launch --agent opencode --model. Also not tested: the phone's refresh path rethrowing a repair message (it re-derives the answer, which throws only when the runtime needs repair; the plain-shell fallback for other failures stays covered by main's phone tab tests), and a new worktree's startup reading its WSL-share base folder (newWorktreeLaunchScope).Characterization suites (C0). The C0 suites on main (
pty-launch-parity,pty-launch-race-parity,pty-pane-materialization-race,launch-parity-window-tab,launch-agent-background-session-launch-parity,terminal-startup-queue-restart) pass unchanged. This PR adds one row to the host table: Windows,\\wsl$repo with no saved runtime → Linux-style command,wsl.exe+Ubuntuat the terminal. It fails when the\\wsl$rule is removed.On 2147865:
tc:node,tc:webandtc:clipass. Vitest on 44 named files (every test that imports a module the split touched, the agent-launch request tests and the C0 suites): 604 pass. Each stacked branch passestc:node, the same files and the changed-code quality check. The earlier wide run (894 files, 10,842 tests) was on the previous head; in it one test failed locally, not from this change:orca-runtime-agent-session-operation"shapes the launch for the route it resolved" expects the Linux-onlyorca-idename, so it passes only on a Linux host (CI).orca-ci-checks --no-typecheckis clean except itstypecheck:cistep, which fails to start under bun locally ("Script not found check"); the typechecks above cover it, and CI runs it.AI Disclosure
Review
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reason (no new UI; before/after shell evidence above)pnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)