Skip to content

fix(vscode): preserve model variants on switch - #12944

Merged
marius-kilocode merged 4 commits into
mainfrom
persist-model-variant-selection
Aug 6, 2026
Merged

fix(vscode): preserve model variants on switch#12944
marius-kilocode merged 4 commits into
mainfrom
persist-model-variant-selection

Conversation

@marius-kilocode

Copy link
Copy Markdown
Collaborator

Switching models currently clears the selected reasoning variant even when the new model supports the same variant or a compatible reasoning effort. This makes model selection unexpectedly change the user’s reasoning configuration.

Preserve exact variants across model switches and fall back to the nearest supported standard effort, including none, minimal, low, medium, high, xhigh, and max. Binary variants such as instant and thinking, plus custom provider-specific variants, remain exact-match-only so they are never mapped to an unrelated effort.

The behavior is applied to the CLI TUI, VS Code session selectors, Agent Manager sessions and new-worktree flow, and settings-backed mode, subagent, and workflow selectors. The CLI-specific fallback algorithm and tests live in Kilo-owned paths to minimize upstream merge conflicts.

Comment thread packages/opencode/src/cli/cmd/run/runtime.ts Outdated
@kilo-code-bot

kilo-code-bot Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Notes

  • Incremental review at 230f1581. The previous WARNING on runtime.ts (explicit --variant flag remapped instead of honored verbatim) is resolved: the new resolvePreservedVariant(ctx.variant, ...) in packages/opencode/src/kilocode/cli/cmd/run/variant.ts returns the CLI flag verbatim (input ?? preserveVariant(...)), matching resolveVariant's unconditional flag-wins semantics and the documented "CLI --variant flag > saved preference > session history" priority. Both call sites (model switch and async catalog arrival) now behave identically and consistently across variant kinds.
  • The head bump since the last review is a merge of main into the branch; the PR-authored surface is still the same 13 files. Merge inflow in runtime.ts (KiloRunTerminal refactor) and session.tsx (model-usage history) comes from separately reviewed main PRs and is outside this PR's diff.
  • New test coverage exercises the real implementation (verbatim flag for effort and binary variants), no mocks. No new subscriptions, timers, or listeners introduced — no memory-leak surface.
Files Reviewed (13 files)
  • .changeset/preserve-model-variants.md
  • packages/kilo-vscode/tests/unit/mode-model.test.ts
  • packages/kilo-vscode/tests/unit/session-variant-store.test.ts
  • packages/kilo-vscode/webview-ui/agent-manager/NewWorktreeDialog.tsx
  • packages/kilo-vscode/webview-ui/src/components/settings/ModelsTab.tsx
  • packages/kilo-vscode/webview-ui/src/components/settings/agent-behaviour/WorkflowsTab.tsx
  • packages/kilo-vscode/webview-ui/src/components/settings/mode-model.ts
  • packages/kilo-vscode/webview-ui/src/context/session-variant-store.ts
  • packages/kilo-vscode/webview-ui/src/context/session.tsx
  • packages/opencode/src/cli/cmd/run/footer.ts
  • packages/opencode/src/cli/cmd/run/runtime.ts
  • packages/opencode/src/kilocode/cli/cmd/run/variant.ts
  • packages/opencode/test/kilocode/cli/run/variant.test.ts
Previous Review Summary (commit 1e17055)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 1e17055)

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
packages/opencode/src/cli/cmd/run/runtime.ts 460 preserveVariant now runs before resolveVariant on catalog arrival, so an explicit --variant <standard-effort> flag not in the model's catalog is silently remapped to the nearest effort instead of honored verbatim — contradicting the documented CLI-flag priority; custom/binary flag values still pass through verbatim, making flag handling inconsistent.

Notes

  • The preserveVariant algorithm itself is sound: valid total-order sort, effort-family isolation (binary/custom variants never mapped), and both copies (CLI + webview) are covered by real-implementation tests.
  • VS Code-side integration (carryVariant in session.tsx, ModelsTab, WorkflowsTab, mode-model.ts, NewWorktreeDialog) captures the old variant before applying the new model and composes correctly with updateConfig deep-merge/null-stripping semantics.
  • Checked for memory leaks: no new subscriptions, timers, listeners, or unclosed resources; the state.switching promise lifecycle is unchanged.
  • Changeset present, user-facing, and fixed versioning covers @kilocode/cli.

Fix these issues in Kilo Cloud

Files Reviewed (13 files)
  • .changeset/preserve-model-variants.md
  • packages/kilo-vscode/tests/unit/mode-model.test.ts
  • packages/kilo-vscode/tests/unit/session-variant-store.test.ts
  • packages/kilo-vscode/webview-ui/agent-manager/NewWorktreeDialog.tsx
  • packages/kilo-vscode/webview-ui/src/components/settings/ModelsTab.tsx
  • packages/kilo-vscode/webview-ui/src/components/settings/agent-behaviour/WorkflowsTab.tsx
  • packages/kilo-vscode/webview-ui/src/components/settings/mode-model.ts
  • packages/kilo-vscode/webview-ui/src/context/session-variant-store.ts
  • packages/kilo-vscode/webview-ui/src/context/session.tsx
  • packages/opencode/src/cli/cmd/run/footer.ts
  • packages/opencode/src/cli/cmd/run/runtime.ts - 1 issue
  • packages/opencode/src/kilocode/cli/cmd/run/variant.ts
  • packages/opencode/test/kilocode/cli/run/variant.test.ts

Reviewed by kimi-k3 · Input: 83.5K · Output: 13.8K · Cached: 697.3K

Review guidance: REVIEW.md from base branch main

@marius-kilocode
marius-kilocode force-pushed the persist-model-variant-selection branch from d787f25 to 40f2c13 Compare August 6, 2026 12:35
@marius-kilocode
marius-kilocode merged commit d4e17e7 into main Aug 6, 2026
30 of 31 checks passed
@marius-kilocode
marius-kilocode deleted the persist-model-variant-selection branch August 6, 2026 14:29
t7tran pushed a commit to t7tran/kilocode that referenced this pull request Aug 14, 2026
…-selection

fix(vscode): preserve model variants on switch
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.

2 participants