fix(opencode): preserve agent and reasoning options when steering#23981
Steering an OpenCode turn omits the selected agent and reasoning variant, so a thread using a custom agent can switch to OpenCode's default agent mid-turn. The steered prompt also loses the system instructions supplied at turn start.
Use the same prompt options for turn start and steering, retaining the explicit agent, plan-mode fallback, reasoning variant, and system instructions. This is a focused fix for an existing message-delivery path, with no new capability or product default.
Fixes #23508.
Validation on macOS arm64, Node 26.12.1:
- Adapter regression cases for custom agent (including precedence over plan mode), plan fallback, and default options failed on main because the steered payload omitted those fields; all pass after the fix.
vp run check:changedpassed format, lint, knip, affected-package typechecks, and all 34 adapter tests. Lint retains an existing unusedlayerwarning.- Runtime transcript from the real adapter with a fake SDK transport: start
agent=agent-b, variant=high→ steer previouslyagent=undefined, variant=undefined; nowagent=agent-b, variant=high, with identical system instructions and a fresh message ID. - A live authenticated OpenCode session was not run. The test exercises the adapter/SDK boundary; no UI changes.
Written with GPT-6 in the Codex desktop harness.
Checks
Added 1 commit
- fix(opencode): 保留追加消息的代理和推理配置d46aa4c
Approvability
Verdict: Approved at 667fc87
Macroscope's review found this PR approvable — This focused OpenCode adapter fix preserves the existing agent, reasoning variant, plan fallback, and system instructions when steering an active turn. Production behavior changes only in that previously incomplete steering path, with targeted regression coverage and no product-default or static-analysis changes.
You can add or adjust custom eligibility rules. Learn more.
No actionable comments were generated in the recent review.
External image Recent review info
-
External image Run configuration
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: main
- File: .coderabbit.config.ts
- Commit: be2ea30
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Advanced
- Run ID:
676294de-d27c-46a1-b9dd-6f4e04b5303d
External image Commits
Reviewing files that changed from the base of the PR and between 667fc87e005af0f78501fef6ebcdd8c4d2f80487 and 6877a55eb07e98e79624df1352937f82f068a276.
External image Files selected for processing: 2
packages/provider-opencode/src/server/adapter.test.tspackages/provider-opencode/src/server/adapter.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.
Walkthrough
Turn submission and steering now use shared OpenCode prompt options. The options include the selected agent and variant, the plan-mode agent fallback, and the combined system prompt. Tests cover custom, plan, and default interaction modes.
Changes: OpenCode prompt options
Layer / File(s) Summary Shared prompt options for turns and steering
packages/provider-opencode/src/server/adapter.ts,packages/provider-opencode/src/server/adapter.test.tsA shared helper derives the agent, variant, and system prompt from model selection and runtime policy. Turn submission and steering use these options. Tests check custom, plan, and default modes, including system prompt retention and distinct message IDs. Priority: External image Normal
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Possibly related issues
- pingdotgg/t3code#23508 — The change supplies the selected agent, variant, plan-mode fallback, and system prompt to steering prompts.
Possibly related PRs
- pingdotgg/t3code#24321 — Both changes use model selection to determine OpenCode agent behavior; this PR applies the selected agent’s permission rules.
Suggested reviewers:
juliusmarminge,marcodotio
Merge Risk: External image Minimal · up to 6877a
Steering preserves the selected options. No merge-blocking issue was established.
Pre-merge checks: Passed 4
Check name Status Explanation Title check Passed The title is concise, specific, and accurately describes preserving OpenCode agent and reasoning options during steering. Description check Passed The description covers the problem, solution, scope, issue reference, verification results, limitations, and testing environment. It provides the required information, although it does not use the tem… Linked Issues check Passed Issue [ #23508] requires OpenCode steering to preserve the selected agent and reasoning variant, including the plan-mode fallback.promptOptionsderivesagent,variant, and the shared system inst…Out of Scope Changes check Passed The changes remain within the OpenCode message-delivery path required by [ #23508]. The helper removes duplicated prompt-option construction, and the tests verify the steering behavior. No unrelated ca…Full details: Description check
Explanation
The description covers the problem, solution, scope, issue reference, verification results, limitations, and testing environment. It provides the required information, although it does not use the template's section headings.
Full details: Linked Issues check
Explanation
Issue [
#23508] requires OpenCode steering to preserve the selected agent and reasoning variant, including the plan-mode fallback.promptOptionsderivesagent,variant, and the shared system instructions from the active turn. BothstartTurnandsteerTurnuse this helper. The parameterized test covers custom-agent precedence, plan fallback, default options, system-prompt equality, and a fresh message ID.
Full details: Out of Scope Changes check
Explanation
The changes remain within the OpenCode message-delivery path required by [
#23508]. The helper removes duplicated prompt-option construction, and the tests verify the steering behavior. No unrelated capability, product default, or UI change appears in the reviewed diff.
Finishing Touches
🧪 Generate unit tests (beta)
- Create a new PR
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
Added 1 commit
- chore(opencode): 同步主线并整合追加消息回归测试667fc87
Merged main c3888da8b4 in 667fc87e00. Preserved steering agent/variant/system options and main's extracted-attachment/stop-race tests. The harness now accepts host overrides and model selection separately so neither side's coverage is lost. All 35 adapter tests and check:changed scoped gates pass. No real provider request was sent.
Added 1 commit
- chore(opencode): 整合主线权限刷新与追加消息测试6877a55
Merged main be2ea30d2b, preserving this PR's steering-options regression alongside main's new session/subagent permission-refresh tests. The production merge is unchanged in intent: initial and appended prompts share the selected agent, reasoning variant and system instructions.
vp run check:changed passed: all 37 OpenCode adapter tests, format, lint, both knip checks and all 10 affected-package typechecks.