Skip to content

fix(opencode): accept OpenCode CLI 1.18.35 in the worker model launch gate - #26683

Closed
ggbdpq wants to merge 3 commits into
stablyai:mainfrom
ggbdpq:fix/opencode-1-18-35-model-whitelist
Closed

ggbdpq wants to merge 3 commits into
stablyai:mainfrom
ggbdpq:fix/opencode-1-18-35-model-whitelist

Conversation

@ggbdpq

@ggbdpq ggbdpq commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

ELI5

A user on OpenCode CLI 1.18.35 asked a worker to launch with --model, the model was in the catalogue and the account was authenticated, but Orca still refused with capability_unsupported — purely because the launch-time verification gate only trusted two hand-verified 1.18.x builds. This teaches the gate about 1.18.35 and makes the refusal say which version was detected and which versions are accepted, so the next person no longer has to read the source to find out.

What Changed

Before — VERIFIED_LEGACY_MODEL_VERSIONS contained only 1.18.30 and 1.18.32. OpenCode 1.18.35 fell through to the refusal path with a generic message ("The execution host cannot verify this OpenCode model launch."), even though its model selection behaves like the already-verified 1.18.3x line.

After — 1.18.35 joins the verified legacy set and takes the existing legacy launch route (model availability probe, launch args preserved). Every other unverified version still fails closed. The refusal for an unverified version now reads: OpenCode CLI version <detected> cannot verify launch-time model selection. Use a verified OpenCode CLI (1.18.30, 1.18.32, 1.18.35, 2.0.16). — the list is derived from the policy module, so it cannot drift from the gate.

Mechanism: one version added to the set in opencode-model-version-policy.ts, a new VERIFIED_OPENCODE_MODEL_VERSIONS summary exported from the same module, and the combined version !== '2.0.16' || agentArgs refusal split into two checks so the version-specific message only fires for the version gate (the manual-args refusal keeps its generic message and behavior).

Why

The gate is intentionally an exact-version allowlist (plugin-API compatibility alone does not verify model selection), so the fix follows the established pattern of adding hand-verified versions one at a time rather than loosening to prefix matching. A capability-based gate for the 1.18.x line would need a probe we cannot run today, so the narrow allowlist addition plus a self-describing error is the safe increment. Fail-closed behavior is preserved and now pinned by an extra refused version (1.18.34) in tests.

Linked Issue

Fixes #26611

Visual Proof

N/A — no UI change; the observable difference is the capability_unsupported error text, covered by automated test assertions.

Testing

  • Automated tests added/updated
Check Result
New tests before the fix 6 failed (1.18.35 rejected by policy + startup plan; refusal message lacked version info)
Same tests after the fix 29/29 pass in the two touched files
Full src/main/opencode suite 55 files, 631 passed, 2 skipped
tsc --noEmit -p config/tsconfig.node.json pass
oxlint / oxfmt --check on touched files pass
Manual run against a real OpenCode CLI 1.18.35 not performed locally — no OpenCode CLI/opencode-go account on this machine; acceptance of 1.18.35 rests on the reproduction report in #26611 (model present in catalogue, auth OK) and on 1.18.35 sharing the already-verified 1.18.3x legacy semantics
  • I manually tested these changes locally (not applicable per table above; unit tests cover the gate and the new message)

AI Disclosure

Implementation assisted by ZCode with GLM-5.3-Flash (issue triage, test-first fix, verification).

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Security: no new inputs; the refusal message only echoes the CLI-reported version string into an OrchestrationError message, same trust level as existing capability handling. Cross-platform/SSH: unchanged — the version gate applies identically on every host. Backwards compatibility: verified versions and the 2.0.16 capability route behave exactly as before; only the previously-refused 1.18.35 changes outcome, and error messages are additive detail.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred) — touched-package tests, node typecheck, and lint/format run locally; full matrix left to CI

…h gate

OpenCode CLI 1.18.35 was refused by the worker-start --model version gate
(capability_unsupported) even when the requested model was available and
the account authenticated, because VERIFIED_LEGACY_MODEL_VERSIONS only
listed 1.18.30 and 1.18.32. Add 1.18.35 to the verified set, keeping the
fail-closed behavior for every other unverified version.

Also make the refusal message name the detected CLI version and the
verified version list, so a rejected launch no longer requires reading
the source to learn what would be accepted.

Fixes stablyai#26611

Generated-by: GLM-5.3-Flash (ZCode)
@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9a82881b-361b-42af-9448-86aa69ee7149
📥 Commits

Reviewing files that changed from the base of the PR and between fa3d6cd and c00557f.

📒 Files selected for processing (2)
  • src/main/opencode/opencode-model-startup-plan.test.ts
  • src/main/opencode/opencode-model-startup-plan.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.


📝 Walkthrough

Walkthrough

The verified legacy-version set now includes OpenCode CLI 1.18.35. Startup validation checks model availability for verified legacy versions and refuses nonempty manual launch arguments. Refusals for unsupported versions identify the detected version and verified-version list. Tests cover the added version and rejection of version 1.18.34.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to c0055

No actionable issue is identified for this change; it is mergeable after normal checks.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check Passed The title clearly identifies the primary change: accepting OpenCode CLI 1.18.35 in the worker model launch gate.
Description check Passed The description is complete and follows the repository template. It explains the user impact, mechanism, rationale, linked issue, testing, limitations, compatibility considerations, and checklist stat…
Linked Issues check Passed Issue #26611 requires support for verified OpenCode 1.18.35 model launches, invalid-model refusal, fail-closed behavior for unverified versions, and version details in refusal errors. The policy adds …
Out of Scope Changes check Passed The changes remain within issue #26611. They update the OpenCode version policy, startup validation, refusal detail, and focused tests. The helper docstrings document the touched verification behavior…
Docstring Coverage Passed Docstring coverage is 83.33% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 5 files.
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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: Advanced
  • Run ID: e0732909-8d35-4637-bbf6-e63aed2d30d9
📥 Commits

Reviewing files that changed from the base of the PR and between 4d1a3dd and bd89d7d.

📒 Files selected for processing (4)
  • src/main/opencode/opencode-model-startup-plan.test.ts
  • src/main/opencode/opencode-model-startup-plan.ts
  • src/main/opencode/opencode-model-version-policy.test.ts
  • src/main/opencode/opencode-model-version-policy.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.

@ggbdpq

ggbdpq commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

Addressing the review round (real-CLI verification + docstring coverage):

Real-CLI verification of 1.18.35 (new evidence)

Temporarily installed [email protected] via npm (system 1.18.34 untouched) on macOS ARM (darwin 24.6.0) and ran the checks the issue requires:

  1. Model catalog parsing (same invocation as the probe): opencode models — exit 0, 35 lines, one provider/model per line, matching the probe's verbatim whole-line comparison. Same shape as the installed 1.18.34.
  2. Invalid-model rejection (fail-closed): opencode run -m opencode/nonexistent-model-xyz "hi" — exit 1 with an error, no session started, no fallback to another model.
  3. Valid-model acceptance and actual selection: opencode run -m opencode/big-pickle "Reply with exactly: OK" --format json — exit 0, replied "OK"; opencode export <sessionID> shows providerID: "opencode", modelID: "big-pickle", i.e. the selected model equals the requested one.

Scope note: this is the non-interactive run path, which shares the CLI's model parsing/validation layer with the TUI launch; the issue reporter's environment is macOS x86_64 while this check ran on ARM — model catalog and --model parsing are architecture-independent. Fail-closed behavior for anything unverifiable is unchanged.

With these checks passing, the issue's "add support if tests pass" condition holds, so the allowlist entry stays (the suggested revert to fail-closed is not needed).

Docstring coverage

Added one-line docstrings to the touched helpers (allowlist predicate, executable resolution, availability probe, both startup-plan entry points) in fa3d6cd — comments only, no behavior change. Focused suites pass (29/29 across opencode-model-startup-plan.test.ts and opencode-model-version-policy.test.ts), oxfmt --check and oxlint clean on the touched files.

CodeRabbit flagged docstring coverage on the PR-touched functions.
Add one-line docstrings to the verified-version allowlist, the model
availability probe, and the startup plan entry points. No behavior
change.

Generated-by: GLM-5.3-Flash (ZCode)

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

🟠 Major · Restore the legacy-version agentArgs refusal. · opencode-model-startup-plan.ts:96-97

src/main/opencode/opencode-model-startup-plan.ts:96-97
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Restore the legacy-version agentArgs refusal.

For verified legacy versions, the early return { inputs } bypasses the existing inputs.agentArgs?.trim() refusal. A reachable worker can therefore continue with nonempty agentArgs, which the previous code rejected before launch. This permits caller-supplied OpenCode flags to accompany the generated --model command and can override or otherwise change model selection, breaking the fail-closed guarantee for manual launch arguments.

Restore the refusal before returning the legacy plan.

Suggested fix
+    if (inputs.agentArgs?.trim()) {
+      return refuseModel()
+    }
     return { inputs }
🧹 Nitpick comments (1)
src/main/opencode/opencode-model-startup-plan.test.ts (1)

113-125: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert the legacy availability probe in the startup-planner test.

The 1.18.35 test mocks probeOpenCodeModelAvailability to return true and checks only the launch command. A planner that skips the probe would still pass this test. The helper tests call the helper directly, so they do not detect this caller regression. Assert the probe call and add a false-result case that expects refusal.

Suggested fix
-      expect((await buildExecutionHostAgentStartupPlan(scope()))?.launchCommand).toContain(
-        '--model'
-      )
+      const plan = await buildExecutionHostAgentStartupPlan(scope())
+      expect(plan?.launchCommand).toContain('--model')
+      expect(probeOpenCodeModelAvailability).toHaveBeenCalledWith(
+        expect.objectContaining({ model: preferred, cwd: '/private/project' })
+      )
       expect(probeOpenCodeLaunchModelContext).not.toHaveBeenCalled()
     }
   )
 
+  it('refuses an unavailable model on the verified legacy route', async () => {
+    vi.mocked(probeOpenCodeLaunchCapabilities).mockResolvedValue({
+      version: '1.18.35',
+      pluginApi: 'v1',
+      promptMode: 'submit'
+    })
+    vi.mocked(probeOpenCodeModelAvailability).mockResolvedValue(false)
+
+    await expect(buildExecutionHostAgentStartupPlan(scope())).rejects.toMatchObject({
+      code: 'capability_unsupported'
+    })
+  })
+

ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a6b0c0bd-1614-4464-a023-ecc3a6c3072f
📥 Commits

Reviewing files that changed from the base of the PR and between bd89d7d and fa3d6cd.

📒 Files selected for processing (3)
  • src/main/opencode/opencode-model-availability.ts
  • src/main/opencode/opencode-model-startup-plan.ts
  • src/main/opencode/opencode-model-version-policy.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/main/opencode/opencode-model-version-policy.ts
  • src/main/opencode/opencode-model-startup-plan.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.

@ggbdpq

ggbdpq commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

Confirmed the Major and fixed it in c00557f.

I verified the regression against the base: the pre-PR check if (capabilities?.version !== '2.0.16' || inputs.agentArgs?.trim()) refused non-empty agentArgs for every version, and the refactor's new legacy early return (return { inputs }) bypassed it — so 1.18.x + model + agentArgs went from always-refused to launched with caller-supplied flags. The suggested restore matches the 2.0.16 route semantics.

Changes:

  • Restored the refusal before the legacy early return.
  • Added parameterized tests (--agent build, --continue, --server http://localhost) asserting verified-legacy launches with manual args refuse: all 3 fail without the fix, pass with it.
  • Added the unavailable-model refusal case on the legacy route (probeOpenCodeModelAvailability → false) and asserted the probe is called with the requested model in the legacy pass-through test (both nitpick suggestions).

Verification: vitest run src/main/opencode/ → 47 files, 573 passed / 2 skipped; oxfmt --check and oxlint clean on both touched files.

The legacy-version early return bypassed the unconditional
`agentArgs` refusal that the pre-refactor check enforced for every
version, so a reachable worker could keep caller-supplied OpenCode
flags alongside the verified `--model` launch. Restore the refusal
before returning the legacy plan and lock the route with tests:
manual args now refuse, an unavailable catalog model refuses, and
the legacy pass-through asserts the availability probe ran.

Generated-by: GLM-5.3-Flash (ZCode)
@SentimentalK

Copy link
Copy Markdown

Thx for the PR. But still this is a hardcode list. Once opencode upgrade we will face this prob again. I don't think this is ideal.

@ggbdpq

ggbdpq commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for following up - you're right that a hardcoded list isn't the ideal end state, and the issue's preference for capability-based verification is fair. I re-tested whether that's feasible for the 1.18.x line today, and it currently isn't, on three concrete grounds:

  • opencode serve on 1.18.35 ignores --port 0 and binds a fixed port (4096), so the preflight used for 2.0.16 (spawn a throwaway server on a random port, query it, tear it down) would collide with a user's own server or other workers on the host.
  • The model endpoints the 2.0.16 preflight reads don't exist on 1.18.35: /model and /model/default return the SPA's HTML fallback instead of JSON (same for /model/list, /models, /experimental/model).
  • /agent responds but with a different schema (name instead of id, no hidden field), and /config has a different shape too, so the preflight's strict response validation rejects them.

So there is no safe runtime capability probe for launch-time model selection on the legacy line today. The alternatives would be another schema map keyed by version (still hardcoded, and more brittle than the allowlist, plus the port problem) or accepting launches we cannot verify, which point 3 of this issue rules out. Until the legacy line exposes a port-safe, programmable way to confirm selection, the exact-version allowlist plus the opencode models catalog probe is the fail-closed implementation, and the refusal message now lists the verified versions so the next upgrade is a one-line, test-backed addition rather than a mystery.

If opencode adds a selection-verification surface to the 1.x line, I'm glad to switch this to capability probing and delete the list.

@SentimentalK

Copy link
Copy Markdown

Wouldn't it be better to use a denylist instead of an exact-version allowlist?

If "1.18.32" and "1.18.35" both work, I don't think we should assume every new patch version is incompatible.

We could perform a capability probe before launching the agent and fail early if the required behavior isn't supported. Runtime errors should also be handled explicitly.

This would avoid maintaining a version list every time OpenCode releases a patch, while still allowing us to block known incompatible versions.

@ggbdpq

ggbdpq commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for pushing on this — the maintenance concern is real, and nobody enjoys adding a version to a list every patch cycle. I considered the denylist shape specifically, and I believe it fails this issue's own acceptance criteria rather than it being a style preference:

  • A denylist is fail-open by construction. Acceptance item 3 asks to "Preserve fail-closed behavior when model selection cannot be verified." Under a denylist, every version not on it — including future ones nobody has tested — launches with --model unverified. That turns "we don't know whether this version verifies model selection" from a refusal into a launch, which is the exact failure mode this gate exists to prevent.
  • The allowlist doesn't assume unlisted versions are incompatible — it assumes nothing about them. Each entry (1.18.30, 1.18.32, 1.18.35) records a hand-verified run, and 1.18.34 stays refused precisely because it was never verified. "1.18.32 and 1.18.35 both work" is consistent with that; it just doesn't license skipping verification for the versions in between or after.
  • On the capability probe: I re-tested whether that's feasible on the 1.18.x line in my comment above — model endpoints return the SPA's HTML fallback instead of JSON, /agent has a different schema, and serve ignores --port 0 and binds a fixed port (4096), so a preflight server would collide with real ones. Until upstream ships endpoints that make the probe possible, "probe before launching" has nothing to probe.
  • On runtime errors: the launch gate can only refuse what it cannot verify up front; failures after launch belong to the agent process error path, outside this PR's scope. What this PR does add is a self-describing refusal — detected version plus the supported list, derived from the policy module so the message cannot drift from the gate.

In practice a new patch costs one verification run (the commands in #26611) plus a one-line addition. And if OpenCode ever exposes model endpoints on the legacy line, a capability gate becomes buildable and the list can retire — happy to revisit then.

@nwparker

Copy link
Copy Markdown
Contributor

Thanks @ggbdpq! The fix landed via #33307 (credited with Co-authored-by): instead of adding 1.18.35 to the exact list, model selection now uses per-major floors (>=1.18.30 for 1.x, >=2.0.14 for 2.x), verified against real CLI binaries through 1.19.4 and 2.1.4. Closing as superseded.

nwparker added a commit that referenced this pull request Oct 24, 2026
…election (#33307)

OpenCode model selection accepts per-major floors (1.x >= 1.18.30, 2.x >= 2.0.14; prereleases and 3.x refused) instead of exact version allowlists, so current releases launch with a picked model again. Fixes #26611. Supersedes #26683, #31985.

Co-authored-by: ggbdpq <[email protected]>
@nwparker nwparker closed this Oct 24, 2026
LuweiLiao pushed a commit to LuweiLiao/orca that referenced this pull request Oct 25, 2026
…election (stablyai#33307)

OpenCode model selection accepts per-major floors (1.x >= 1.18.30, 2.x >= 2.0.14; prereleases and 3.x refused) instead of exact version allowlists, so current releases launch with a picked model again. Fixes stablyai#26611. Supersedes stablyai#26683, stablyai#31985.

Co-authored-by: ggbdpq <[email protected]>
(cherry picked from commit d170b5a)
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]: OpenCode 1.18.35 rejected by worker-start --model due to narrow verified-version gate

3 participants