-
Notifications
You must be signed in to change notification settings - Fork 269
[Fix] Reasoning models stop thinking after model selection #1349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
zoomote
wants to merge
6
commits into
main
Choose a base branch
from
fix/reasoning-defaults-0j945ts7kju2e
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+536
−20
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
27a4b5a
fix(reasoning): apply model defaults when settings unset
roomote 002937e
test(reasoning): cover default state matrix
roomote dc1be12
test(reasoning): strengthen reasoning effort edge-case coverage
edelauna 80899b4
fix(reasoning): preserve required model defaults
roomote c3da7a6
test(reasoning): kill changed-code mutants
roomote ec54dcf
test(reasoning): cover boolean disable capability
roomote File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| import assert from "node:assert/strict" | ||
|
|
||
| type Effort = "disable" | "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | ||
| type Supported = true | readonly Effort[] | ||
|
|
||
| interface ModelState { | ||
| supported: Supported | ||
| required: boolean | ||
| modelDefault?: Effort | ||
| stored?: Effort | ||
| enabled?: boolean | ||
| } | ||
|
|
||
| const canonicalEfforts = ["low", "medium", "high", "xhigh", "max"] as const | ||
| const defaultEfforts = ["low", "medium", "high"] as const | ||
| const supportedSets: Supported[] = [ | ||
| true, | ||
| ["disable", "low", "high"], | ||
| ["low", "high"], | ||
| ["none", "low", "high"], | ||
| ["low", "medium", "high", "xhigh", "max"], | ||
| ] | ||
| const values = [undefined, "disable", "none", "low", "high", "max"] as const | ||
| const enabledValues = [undefined, false, true] as const | ||
|
|
||
| function availableOptions(state: ModelState): readonly Effort[] { | ||
| return state.supported === true | ||
| ? state.required | ||
| ? defaultEfforts | ||
| : ["disable", ...defaultEfforts] | ||
| : state.supported | ||
| } | ||
|
|
||
| function supportsEffort(supported: Supported, effort: Effort): boolean { | ||
| return supported === true || supported.includes(effort) | ||
| } | ||
|
|
||
| function resolveSelection(state: ModelState): Effort { | ||
| const available = availableOptions(state) | ||
| const defaultEffort = state.modelDefault ?? (state.required ? "medium" : "disable") | ||
| const raw = state.stored ?? defaultEffort | ||
| const fallback = available.includes(defaultEffort) ? defaultEffort : (available[0] ?? raw) | ||
| return available.includes(raw) ? raw : fallback | ||
| } | ||
|
|
||
| function resolveRequest(state: ModelState): Effort | undefined { | ||
| const disabled = state.stored === "disable" || state.stored === "none" || state.enabled === false | ||
| const canDisable = supportsEffort(state.supported, "disable") | ||
| if (disabled && canDisable) return undefined | ||
|
|
||
| const candidates = [disabled ? undefined : state.stored, state.modelDefault] | ||
| const supported = state.supported | ||
| if (supported !== true && !supported.includes("disable")) { | ||
| candidates.push(canonicalEfforts.find((effort) => supported.includes(effort))) | ||
| } | ||
|
|
||
| for (const effort of candidates) { | ||
| if ( | ||
| effort && | ||
| effort !== "disable" && | ||
| effort !== "none" && | ||
| effort !== "minimal" && | ||
| supportsEffort(state.supported, effort) | ||
| ) { | ||
| return effort | ||
| } | ||
| } | ||
|
|
||
| return state.required && state.modelDefault && state.modelDefault !== "none" ? state.modelDefault : undefined | ||
| } | ||
|
|
||
| let checked = 0 | ||
| for (const supported of supportedSets) { | ||
| for (const required of [false, true]) { | ||
| for (const modelDefault of values) { | ||
| for (const stored of values) { | ||
| for (const enabled of enabledValues) { | ||
| const state: ModelState = { supported, required, modelDefault, stored, enabled } | ||
| const selection = resolveSelection(state) | ||
| const available = availableOptions(state) | ||
| assert.ok(available.length === 0 || available.includes(selection), "selection must be supported") | ||
| if (!available.includes("disable")) | ||
| assert.notEqual(selection, "disable", "required reasoning cannot disable") | ||
|
|
||
| const normalized: ModelState = { | ||
| ...state, | ||
| stored: selection, | ||
| enabled: required || selection !== "disable", | ||
| } | ||
| const request = resolveRequest(normalized) | ||
| if (selection === "disable") { | ||
| assert.equal(request, undefined, "an explicit supported disable must omit reasoning") | ||
| } else if (canonicalEfforts.includes(selection as (typeof canonicalEfforts)[number])) { | ||
| assert.equal(request, selection, "a normalized effort must reach the request") | ||
| } | ||
|
|
||
| checked++ | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| console.log(`Reasoning defaults model check passed (${checked} states)`) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Do not treat explicitly enabled
"none"as"disable".When settings contain
reasoningEffort: "none"andenableReasoningEffort: true, a model withsupportsReasoningEffort: ["disable", "low", ...]enters the early return at Line 43. The request then omitsreasoning_effortinstead of resolving the canonical supported effort.Keep
"none"on the fallback path when reasoning is explicitly enabled. Add this supported-"disable"case to the"none"regression tests.🤖 Prompt for AI Agents
Source: Path instructions