Repository navigation
fix(anthropic): apply provider default reasoning effort when caller omits it #2494
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -40,6 +40,28 @@ describe("anthropic extended-thinking gate", () => { | |||||||||||||
| expect(b.top_p).toBe(0.8); | ||||||||||||||
| }); | ||||||||||||||
|
|
||||||||||||||
| test("modelDefaultReasoningEfforts supplies reasoning when caller omits it", async () => { | ||||||||||||||
| const b = await bodyOf(parsed(undefined, { temperature: 0.5, topP: 0.8 }, "always-thinking-model"), { | ||||||||||||||
| ...provider, | ||||||||||||||
| modelDefaultReasoningEfforts: { "always-thinking-model": "high" }, | ||||||||||||||
| }); | ||||||||||||||
| const thinking = b.thinking as { type: string; budget_tokens: number } | undefined; | ||||||||||||||
| expect(thinking?.type).toBe("enabled"); | ||||||||||||||
| expect(typeof thinking?.budget_tokens).toBe("number"); | ||||||||||||||
|
Comment on lines
+48
to
+50
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Assert the configured default value, not only the thinking shape. The test configures Assert that the budget is Proposed test fix- expect(typeof thinking?.budget_tokens).toBe("number");
+ expect(thinking?.budget_tokens).toBe(16384);As per path instructions: 📝 Committable suggestion
Suggested change
🤖 Prompt for AI AgentsSource: Path instructions |
||||||||||||||
| expect(b.temperature).toBeUndefined(); | ||||||||||||||
| expect(b.top_p).toBeUndefined(); | ||||||||||||||
| }); | ||||||||||||||
|
|
||||||||||||||
| test("explicit reasoning overrides modelDefaultReasoningEfforts", async () => { | ||||||||||||||
| const b = await bodyOf(parsed("low", {}, "always-thinking-model"), { | ||||||||||||||
| ...provider, | ||||||||||||||
| modelDefaultReasoningEfforts: { "always-thinking-model": "high" }, | ||||||||||||||
| }); | ||||||||||||||
| const thinking = b.thinking as { type: string; budget_tokens: number } | undefined; | ||||||||||||||
| expect(thinking?.type).toBe("enabled"); | ||||||||||||||
| expect(thinking?.budget_tokens).toBe(4096); | ||||||||||||||
| }); | ||||||||||||||
|
|
||||||||||||||
| test("reasoning 'high' enables thinking and drops sampling (extended-thinking rule)", async () => { | ||||||||||||||
| const b = await bodyOf(parsed("high", { temperature: 0.3, topP: 0.9 })); | ||||||||||||||
| const thinking = b.thinking as { type: string; budget_tokens: number } | undefined; | ||||||||||||||
|
|
||||||||||||||
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.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: lidge-jun/opencodex
Length of output: 50376
🏁 Script executed:
Repository: lidge-jun/opencodex
Length of output: 39716
🏁 Script executed:
Repository: lidge-jun/opencodex
Length of output: 21310
🏁 Script executed:
Repository: lidge-jun/opencodex
Length of output: 21310
🏁 Script executed:
Repository: lidge-jun/opencodex
Length of output: 47646
🏁 Script executed:
Repository: lidge-jun/opencodex
Length of output: 50375
🏁 Script executed:
Repository: lidge-jun/opencodex
Length of output: 253
🏁 Script executed:
Repository: lidge-jun/opencodex
Length of output: 50376
🏁 Script executed:
Repository: lidge-jun/opencodex
Length of output: 50375
🏁 Script executed:
Repository: lidge-jun/opencodex
Length of output: 532
🏁 Script executed:
Repository: lidge-jun/opencodex
Length of output: 48372
🏁 Script executed:
Repository: lidge-jun/opencodex
Length of output: 359
Validate Anthropic reasoning defaults before request construction.
providerConfigSchemapassesmodelDefaultReasoningEffortsthrough without validation. An invalid value therefore reachessrc/adapters/anthropic.ts:522-525. The adaptive branch sends values such as"ultra"or"bogus"as unsupportedoutput_config.effort; the traditional branch silently maps them to the8192-token default. Reject or ignore defaults unless they are in the model’s effective Anthropic-supported ladder (minimal,low,medium,high,xhigh, ormax), and add coverage for both thinking branches.🤖 Prompt for AI Agents
Source: Path instructions