Skip to content

Validate OpenCode worker model preferences on the execution host - #24624

Merged
nwparker merged 166 commits into
mainfrom
nwparker/opencode-worker-model
Oct 4, 2026
Merged

nwparker merged 166 commits into
mainfrom
nwparker/opencode-worker-model

Conversation

@nwparker

@nwparker nwparker commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​846 $\color{#cf222e}{\Huge{\mathbf{−}}}$​6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​840
Prod 24 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​492 $\color{#cf222e}{\Huge{\mathbf{−}}}$​52 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​440

ELI5

An OpenCode worker can use a requested model without changing the default for later launches.

What Changed

Validate the requested model on the execution host before creating a terminal or sending input. Preserve command arguments, startup, and resume behavior through Orca's existing launch preferences and receipts. Refuse truncated or visibly unfinished model catalogs. New-worktree requests explain that model selection requires the current or an existing worktree.

Why

The machine running OpenCode knows which CLI and models are available. Checking there prevents silent fallback. Reusing the launch path keeps validation before effects and preserves existing behavior.

Linked Issue

Part of #19980. Preserves #22134 and credits @user141514. OpenCode 2.0.16 model isolation follows in #24768.

Visual Proof

Actual installed-OpenCode model B and later default-model A turns, including screenshots pinned to source c8fdfdbe.

The catalog correction also has an actual macOS before/after check: installed OpenCode 2.0.16 returned 262,144 bytes ending mid-line. The old probe accepted a model in that prefix; the repaired probe refused it. Both probes accepted the complete small catalog. These four checks ran the actual CLI without model turns.

Testing

  • Installed CLI reproductions and screenshots retained.
  • Automated coverage for availability, arguments, early refusals, and resume.

Earlier feature qualification passed 147 focused tests and all three typechecks, lint, format, and quality checks; its later integration passed 52 tests and all three typechecks. Review corrections passed 93 targeted tests and all three typechecks. The final catalog correction passed 10 tests, Node typechecks for both PRs, and affected lint, format, and quality checks.

Actual testing used private macOS profiles and a controlled provider. Windows, WSL, and SSH boundaries have automated coverage.

Review

Independently reviewed. The complete original contribution is preserved. Exact verified legacy versions 1.18.30 and 1.18.32 are supported here; #24768 adds verified 2.0.16 support. Unsupported requests fail before launch.

Agent skill upstream boundary

  • Not applicable.

Notes

#22134 remains open until its complete replacement is merged. Linked model-isolation screenshots retain their original source identity. A final newline catches visibly incomplete catalog output; a cut exactly at a line boundary cannot be detected this way.

Checklist

  • Focused change; behavior, mechanism, and choice explained.
  • Visual proof linked.
  • Correctness, security, performance, and cross-platform/remote behavior reviewed.
  • Relevant tests, typechecks, lint, format, and quality checks pass.
  • Public CI and final head/base review complete.

brennanb2025 and others added 29 commits September 22, 2026 14:02
Allow supervised OpenCode workers to use per-launch model overrides through the existing launch-preference and receipt path.
Preserve existing OpenCode agent arguments while replacing only model flags, and reject unsupported effort values explicitly.
Keep Native Chat option exposure unchanged and update the worker CLI and orchestration guidance.
Reuse captured composer readiness on local and paired execution hosts and revoke launching-shell paste anchors.

Co-authored-by: Brennan Benson <79079362+brennanb2025@users.noreply.github.com>
…apability

Co-authored-by: user141514 <user141514@users.noreply.github.com>
Co-authored-by: Adnan Khan <adnank11427@gmail.com>
Reuse captured composer readiness on local and paired execution hosts and revoke launching-shell paste anchors.

Co-authored-by: Brennan Benson <79079362+brennanb2025@users.noreply.github.com>
@nwparker nwparker changed the title Gate OpenCode worker model preferences on execution-host support Validate OpenCode worker model preferences on the execution host Oct 4, 2026
@nwparker
nwparker changed the base branch from nwparker/OpenCode-Run-Positional-Prompt to main October 4, 2026 20:24
@coderabbitai

coderabbitai Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

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: 93c0868a-bffc-4ac8-83dc-169f5b45819a
📥 Commits

Reviewing files that changed from the base of the PR and between 8f95032 and a3f7e81.

📒 Files selected for processing (10)
  • docs/site/content/docs/cli/orchestration.mdx
  • skill-guides/orchestration/references/coordinator-loop.md
  • src/cli/bundled-skill-guides.ts
  • src/cli/specs/orchestration-worker-specs.ts
  • src/main/opencode/opencode-model-availability.test.ts
  • src/main/opencode/opencode-model-availability.ts
  • src/main/runtime/rpc/methods/orchestration/worker/worker-launch-preferences.test.ts
  • src/main/runtime/rpc/methods/orchestration/worker/worker-launch-preferences.ts
  • src/main/runtime/rpc/methods/orchestration/worker/worker-start-validation.ts
  • src/main/runtime/rpc/methods/orchestration/worker/workers-new-worktree.test.ts
🚧 Files skipped from review as they are similar to previous changes (7)
  • docs/site/content/docs/cli/orchestration.mdx
  • skill-guides/orchestration/references/coordinator-loop.md
  • src/main/runtime/rpc/methods/orchestration/worker/workers-new-worktree.test.ts
  • src/cli/specs/orchestration-worker-specs.ts
  • src/main/runtime/rpc/methods/orchestration/worker/worker-launch-preferences.test.ts
  • src/main/runtime/rpc/methods/orchestration/worker/worker-launch-preferences.ts
  • src/main/runtime/rpc/methods/orchestration/worker/worker-start-validation.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The change adds per-launch OpenCode model selection for execution hosts that verify the CLI version and model availability. It adds OpenCode launch-option serialization and runtime preflight checks. Worker and agent-launch paths reject unsupported preferences before launch effects. Tests cover model validation, supported and unsupported environments, PTY creation, and refusal handling.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to a3f7e

The launch flows continue to refuse unsupported configurations before starting and preserve existing promptless launches; no merge-blocking issue is established.

Security Architecture Review

Security architecture risk: 🔵 Low · up to a3f7e

The new launch preference is guarded and does not appear to widen access. Incomplete verification of command handling and failure recovery leaves limited residual uncertainty.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • observed — The reviewed worker entrypoint requires a coordinator bound to the current run and validates task ownership. Explicit terminal reuse is constrained to a recognized agent terminal in the resolved worktree. Federated calls carry an environment-pairing revision fence.

Security Findings and Attack Paths

  • observed — The caller-controlled selection must exactly match a catalog line before startup preparation succeeds. Catalog probing invokes a resolved executable with fixed arguments rather than interpolating the requested selection into a probe command. This verifies the probe boundary, not the uninspected final launch-command serialization.

Trust Boundaries and Controls

  • observed — Execution-host verification refuses remote-workspace, WSL, platform-mismatch, aborted, malformed, and unsupported-option requests. Executable resolution rejects multi-token commands and tokenization that diverges from shell interpretation. Federated host preparation performs its own support probe instead of treating home-side forwarding as verification.

Resilience and Maintainability Implications

  • observed — Local worker failure handling preserves resource ownership: reused terminals remain external, created terminals receive custody records, and failed starts retain created terminals for explicit worker release while discarding structured sessions. This is deliberate recovery ownership, not evidence that every failure immediately removes all resources.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 30 functions across 33 files. (2 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the main change: validating OpenCode worker model preferences on the execution host.
Description check ✅ Passed The description explains the change, rationale, testing, visual evidence, and platform considerations. It includes linked issue references and addresses the required template sections; the empty Revie…
Full details: Docstring Coverage

Explanation

Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 30 functions across 33 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • 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: 2


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 71e5504b-1d8a-4ed4-9782-42093df61909
📥 Commits

Reviewing files that changed from the base of the PR and between ddefd52 and 8f95032.

📒 Files selected for processing (37)
  • docs/site/content/docs/cli/orchestration.mdx
  • skill-guides/orchestration/references/coordinator-loop.md
  • src/cli/bundled-skill-guides.ts
  • src/cli/specs/orchestration-worker-specs.ts
  • src/main/agent-launch/__fixtures__/host-agent-startup-call-sites.txt
  • src/main/agent-launch/agent-launch-executor.ts
  • src/main/agent-launch/agent-launch-opencode-model.test.ts
  • src/main/opencode/opencode-model-availability.test.ts
  • src/main/opencode/opencode-model-availability.ts
  • 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
  • src/main/runtime/opencode-model-worktree-create.test.ts
  • src/main/runtime/orca-runtime-create-agent-session.ts
  • src/main/runtime/orca-runtime-create-managed-worktree.ts
  • src/main/runtime/orca-runtime-get-agent-session-execution-namespace.ts
  • src/main/runtime/orca-runtime-get-terminal-interactive-wait.ts
  • src/main/runtime/orca-runtime-resolve-worktree-removal-target.ts
  • src/main/runtime/orchestration-opencode-model-host.test.ts
  • src/main/runtime/rpc/methods/agent-launch-failure-code.ts
  • src/main/runtime/rpc/methods/agent-launch-prestart-failure.test.ts
  • src/main/runtime/rpc/methods/agent-launch.ts
  • src/main/runtime/rpc/methods/orchestration/federation/federation.ts
  • src/main/runtime/rpc/methods/orchestration/worker/local-worker-start.ts
  • src/main/runtime/rpc/methods/orchestration/worker/worker-launch-preferences.test.ts
  • src/main/runtime/rpc/methods/orchestration/worker/worker-launch-preferences.ts
  • src/main/runtime/rpc/methods/orchestration/worker/worker-opencode-model-preflight.ts
  • src/main/runtime/rpc/methods/orchestration/worker/worker-start-validation.ts
  • src/main/runtime/rpc/methods/orchestration/worker/workers-new-worktree.test.ts
  • src/main/runtime/runtime-worktree-agent-startup.ts
  • src/renderer/src/components/terminal-pane/ipc-pty-opencode-model.test.ts
  • src/renderer/src/components/terminal-pane/ipc-pty-spawn-request.ts
  • src/shared/agent-session-option-catalog-opencode.test.ts
  • src/shared/agent-session-option-catalog-opencode.ts
  • src/shared/agent-session-option-launch.ts
  • src/shared/tui-agent-startup-session-options.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

Comment thread src/main/opencode/opencode-model-availability.ts

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

✅ No new issues found.

Reviewed changes

  • Refused OpenCode model catalogs whose opencode models output was truncated by runProcess or ends mid-line — probeOpenCodeModelAvailability now also requires !outputTruncated and stdout.endsWith('\n'), so an incomplete catalog can no longer validate a model.
  • Added an explicit existing-worktree requirement to resolveWorkerLaunchPreferences: an OpenCode --model with createsWorktree refuses first, with a worktree-specific capability_unsupported message, before the CLI-verification refusal.
  • Threaded createsWorktree through prepareLocalWorkerStart and prepareFederationAttachmentWorkerStart so both start paths reach that guard before any worktree or terminal effect.
  • Updated the CLI spec, the orchestration docs page, and the coordinator-loop reference to state that OpenCode --model is existing-worktree-only; regenerated bundled-skill-guides.ts stays in sync with the reference.
  • Added focused coverage: truncated and unterminated catalog refusal, LF/CRLF acceptance, and the worktree-specific refusal message on both start paths (asserting no probe and no side effects).

The delta responds directly to both CodeRabbit findings at these locations and reconciles the prior review's new-worktree concern. 44 tests across the two directly-changed test files plus 24 in workers-new-worktree.test.ts pass, and the bundled-skill-guide verifier is clean at a3f7e81. The residual heuristic gap — a catalog cut exactly at a line boundary — is already documented in the PR notes and is a deliberate fail-closed tradeoff.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker merged commit 8e5080c into main Oct 4, 2026
41 checks passed
hiphapis added a commit to hiphapis/orca that referenced this pull request Oct 7, 2026
Accepted upstream's deletion of config/scripts/orchestration-skill-guidance.test.mjs.
stablyai#25791 removed all four skill-guidance test files as a category with no
replacement, so this branch's assertions go with them; the guidance text they
pinned is unchanged. references/coordinator-loop.md auto-merged cleanly: stablyai#24624
rewrote the OpenCode paragraph in the slot this branch had already placed it,
and the defaults policy around it is intact.

src/cli/bundled-skill-guides.ts is generated and was regenerated, not resolved.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011nnNsG3p4Do9eiyfXGr2rB
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.

4 participants