fix(opencode): refuse a picked OpenCode model in any \\wsl$ repo (#28236)

OpenCode in a \\wsl$ repo runs in WSL whatever the project's setting, and Orca can't verify a
model there yet, so picking one is refused, as it already is for a project set to WSL, instead
of being checked on Windows.
This commit is contained in:
Brennan Benson
2026-10-14 13:10:31 -07:00
committed by GitHub
parent d40fbdba91
commit 941a0f2a8a
5 changed files with 9 additions and 36 deletions
@@ -24,8 +24,6 @@ type StartupScope = {
inputs: AgentStartupPlanInputs
cwd: string
isWsl?: boolean
/** TEMPORARY parity: the platform main checked this model on, when it differs. */
modelCheckPlatform?: NodeJS.Platform
hostIdentity?: string
signal?: AbortSignal
}
@@ -51,20 +49,20 @@ export async function prepareOpenCodeModelStartupInputs(
if (typeof model !== 'string' || model.trim().length === 0) {
refuseModel()
}
const platform = options.modelCheckPlatform ?? inputs.platform
if (
Object.entries(inputs.sessionOptions ?? {}).some(
([key, value]) => key !== 'model' && value !== undefined
) ||
inputs.isRemote ||
options.isWsl ||
platform !== process.platform ||
inputs.platform !== process.platform ||
options.signal?.aborted
) {
refuseModel()
}
const command =
inputs.cmdOverrides.opencode || getTuiAgentLaunchCommand(TUI_AGENT_CONFIG.opencode, platform)
inputs.cmdOverrides.opencode ||
getTuiAgentLaunchCommand(TUI_AGENT_CONFIG.opencode, inputs.platform)
const env: Record<string, string> = {}
for (const [key, value] of Object.entries({ ...process.env, ...inputs.agentEnv })) {
if (value !== undefined) {
@@ -69,22 +69,6 @@ export function agentLaunchProjectRuntime(
return pathDecides ? undefined : runtime
}
/** TEMPORARY parity: main checked an OpenCode model on the platform it quoted for, which in a
* `\\wsl$` repo not set to WSL was the Windows host. */
export function openCodeModelCheckPlatform(
store: LaunchScopeRuntimeStore,
scope: TerminalWorkspaceLaunchScope,
platform: NodeJS.Platform
): NodeJS.Platform {
return scope.repo && !scope.connectionId && isWslUncPath(scope.path)
? executionRuntimePlatform(
resolveLocalProjectRuntimeForWorktreeId(store, scope.id),
undefined,
process.platform
)
: platform
}
/** The one runtime fact for an agent launched into this workspace. Throws, under
* `PROJECT_RUNTIME_REPAIR_REQUIRED_CODE` and in the settings page's words, when its runtime needs
* repair. */
@@ -86,12 +86,13 @@ it('refuses an agent whose WSL distro is gone, under its own code', async () =>
expect(response).toMatchObject({ error: { code: PROJECT_RUNTIME_REPAIR_REQUIRED_CODE, message } })
})
// TEMPORARY parity: in a `\\wsl$` repo set to Windows host, OpenCode's model is checked on Windows,
// as on main; its command is still written for Linux, where it runs.
it('checks an OpenCode model on Windows in a WSL-share repo set to Windows host', async () => {
// OpenCode runs in WSL in a `\\wsl$` repo, where Orca can't verify a model yet, so picking one is
// refused rather than checked on Windows.
it('refuses an OpenCode model in a WSL-share repo set to Windows host', async () => {
const shareScope = { ...scope, id: 's', path: share.path, repo: share, folderWorkspace: null }
Object.assign(runtime, { resolveTerminalWorkspaceLaunchScope: async () => shareScope })
const request = { clientOperationId, worktree: 'id:s', agent: 'opencode' } as const
await runtime.createAgentSession({ ...request, launchPreferences: { model: 'm' } })
expect(spawned()).toEqual(['linux'])
const picked = runtime.createAgentSession({ ...request, launchPreferences: { model: 'm' } })
await expect(picked).rejects.toThrow('cannot verify this OpenCode')
expect(spawned()).toEqual([])
})
@@ -14,7 +14,6 @@ import { createHash } from 'node:crypto'
import { isTuiAgentEnabled } from '../../shared/tui-agent-selection'
import { resolveAgentStartupPlanInputs } from '../../shared/agent-startup-plan-inputs'
import { agentLaunchQuotingShell } from '../../shared/agent-launch-runtime'
import { openCodeModelCheckPlatform } from './agent-launch-scope-runtime'
import { buildExecutionHostAgentStartupPlan } from '../opencode/opencode-model-startup-plan'
import type { RuntimeTerminalCreate } from '../../shared/runtime-types'
import type {
@@ -147,11 +146,6 @@ export class OrcaRuntimeWithCreateAgentSession extends OrcaRuntimeWithGetAgentSe
})
const startup = await buildExecutionHostAgentStartupPlan({
inputs: startupArgs,
modelCheckPlatform: openCodeModelCheckPlatform(
this.store!,
workspace,
launchRuntime.platform
),
cwd: startupCwd ?? workspace.path,
prompt: request.prompt ?? '',
promptDelivery: request.promptDelivery,
@@ -27,7 +27,6 @@ import {
import {
agentLaunchPlatformForScope,
agentLaunchProjectRuntime,
openCodeModelCheckPlatform,
resolveAgentLaunchRuntime
} from './agent-launch-scope-runtime'
import { resolveQoderTerminalCommand } from './qoder-terminal-command-resolution'
@@ -182,9 +181,6 @@ async function buildRuntimeAgentTerminalStartupOptions(
shell: agentLaunchQuotingShell(runtime),
sessionOptions: host.toSessionOptions(opts.launchPreferences)
}),
...(host.store
? { modelCheckPlatform: openCodeModelCheckPlatform(host.store, workspace, runtime.platform) }
: {}),
prompt: opts.startupPrompt ?? '',
cwd: resolveTerminalStartupCwd(workspace.path, opts.cwd) ?? workspace.path,
hostIdentity: host.hostIdentity,