-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[WRONG BRANCH] fix: apply anthropic default reasoning effort #2468
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"); | ||||||||||||||||||||||||||||||||||||||||||||||
| expect(b.temperature).toBeUndefined(); | ||||||||||||||||||||||||||||||||||||||||||||||
| expect(b.top_p).toBeUndefined(); | ||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+43
to
+53
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 high-effort budget.
- expect(typeof thinking?.budget_tokens).toBe("number");
+ expect(thinking?.budget_tokens).toBe(16384);📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| 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.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: lidge-jun/opencodex
Length of output: 50376
🏁 Script executed:
Repository: lidge-jun/opencodex
Length of output: 35434
🏁 Script executed:
Repository: lidge-jun/opencodex
Length of output: 50375
🏁 Script executed:
Repository: lidge-jun/opencodex
Length of output: 50376
🏁 Script executed:
Repository: lidge-jun/opencodex
Length of output: 29703
🏁 Script executed:
Repository: lidge-jun/opencodex
Length of output: 920
Validate
modelDefaultReasoningEffortsbefore Anthropic request construction.providerConfigSchemaomitsmodelDefaultReasoningEffortsand ends with.passthrough(), soloadConfig()preserves arbitrary values.defaultReasoningEffort()then accepts them unchanged. Adaptive requests forward unknown values tooutput_config.effort, and budget requests map them to the medium budget. Add per-entry load/write sanitization and enforce membership in the effective model ladder. Mapminimaltolow, and map or rejectultrabecause Anthropic adaptive requests support onlylow|medium|high|xhigh|max.🤖 Prompt for AI Agents
Source: Linters/SAST tools