Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/quiet-variants-cache.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"kilo-code": patch
---

Preserve cached reasoning variants when starting new VS Code sessions.
17 changes: 13 additions & 4 deletions packages/kilo-vscode/tests/unit/session-variants.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,24 @@ describe("session variants", () => {

it("persists an explicit default selection", () => {
const state = setup()
state.selections["agent/code/anthropic/claude-sonnet-4"] = "high"
state.variants.select(undefined)
expect(state.selections).toEqual({ "agent/code/anthropic/claude-sonnet-4": "" })
expect(state.variants.current()).toBeUndefined()
expect(state.messages).toEqual([{ type: "persistVariant", key: "agent/code/anthropic/claude-sonnet-4", value: "" }])
})

it("carries the model default across model changes", () => {
const state = setup()
state.variants.carry(model, undefined, "code")
expect(state.selections).toEqual({ "agent/code/anthropic/claude-sonnet-4": "" })
it("does not shadow a cached variant when carrying the model default", () => {
const global = setup()
global.selections["agent/code/anthropic/claude-sonnet-4"] = "high"
global.variants.carry(model, undefined, "code")
expect(global.selections).toEqual({ "agent/code/anthropic/claude-sonnet-4": "high" })
expect(global.messages).toEqual([])

const session = setup("session-a")
session.selections["agent/code/anthropic/claude-sonnet-4"] = "high"
session.variants.carry(model, undefined, "code", "session-a")
expect(session.selections).toEqual({ "agent/code/anthropic/claude-sonnet-4": "high" })
expect(session.variants.current()).toBe("high")
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ export function createSessionVariants(options: Options) {
const carry = (selection: ModelSelection, value: string | undefined, name: string, sessionID?: string) => {
const list = Object.keys(options.find(selection)?.variants ?? {})
if (list.length === 0) return
const next = value === undefined ? DEFAULT_VARIANT : preserveVariant(value, list)
// An absent value means the model default, not an explicit user choice.
// Do not write a default sentinel here because it would shadow a cached
// agent-level variant when this selection is resolved for a new session.
const next = preserveVariant(value, list)
if (next === undefined) return
const key = variantKey(selection, name, sessionID)
options.set(key, next)
Expand Down
Loading