Skip to content

Commit e2d9002

Browse files
obuchowskisteipete
authored andcommitted
fix(thinking): clamp below-range requests down to the cheapest level, not up
resolveSupportedThinkingLevelFromProfile sorts the supported levels descending, then, when every supported level exceeds the request (e.g. a stored `off` on a profile that has no off level), fell through to `ranked.find(non-off)` — the first entry of a descending list, i.e. the most expensive level. A session carrying thinking `off` that switched onto such a model was silently remapped to maximum reasoning and persisted (src/auto-reply/reply/directive-handling.persist.ts). Use `ranked.findLast(non-off)` so a below-range request resolves to the cheapest non-off level instead. Regression test included (red before, green after). This surfaces with the first bundled no-off thinking profiles (Fireworks GPT-OSS 120B, see #92217), but the clamp lives in shared core logic, so it ships on its own.
1 parent 094c0d4 commit e2d9002

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

src/auto-reply/thinking.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,20 @@ describe("listThinkingLevels", () => {
648648
}),
649649
).toBe("high");
650650
});
651+
652+
it("clamps a below-range request down to the cheapest level on a no-off profile", () => {
653+
providerRuntimeMocks.resolveProviderThinkingProfile.mockReturnValue({
654+
levels: [{ id: "low" }, { id: "medium" }, { id: "high" }],
655+
});
656+
657+
expect(
658+
resolveSupportedThinkingLevel({
659+
provider: "demo-noff",
660+
model: "demo-model",
661+
level: "off",
662+
}),
663+
).toBe("low");
664+
});
651665
});
652666

653667
describe("listThinkingLevelLabels", () => {

src/auto-reply/thinking.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ function resolveSupportedThinkingLevelFromProfile(
350350
const ranked = profile.levels.toSorted((a, b) => b.rank - a.rank);
351351
return (
352352
ranked.find((entry) => entry.id !== "off" && entry.rank <= requestedRank)?.id ??
353-
ranked.find((entry) => entry.id !== "off")?.id ??
353+
ranked.findLast((entry) => entry.id !== "off")?.id ??
354354
"off"
355355
);
356356
}

0 commit comments

Comments
 (0)