Skip to content

Commit 4f1dd51

Browse files
committed
fix: specify thinking budget for Claude thinking models
1 parent aefa744 commit 4f1dd51

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "web-codegen-scorer",
3-
"version": "0.0.38",
3+
"version": "0.0.39",
44
"scripts": {
55
"build-runner": "tsc",
66
"release-build": "tsx ./scripts/release-build.ts",

runner/codegen/ai-sdk-runner.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ import {combineAbortSignals} from '../utils/abort-signal.js';
2626

2727
const SUPPORTED_MODELS = [
2828
'claude-opus-4.1-no-thinking',
29-
'claude-opus-4.1-with-thinking',
29+
'claude-opus-4.1-with-thinking-16k',
3030
'claude-sonnet-4.5-no-thinking',
31-
'claude-sonnet-4.5-with-thinking',
31+
'claude-sonnet-4.5-with-thinking-16k',
3232
'gemini-2.5-flash-lite',
3333
'gemini-2.5-flash',
3434
'gemini-2.5-pro',
@@ -44,6 +44,7 @@ const SUPPORTED_MODELS = [
4444
// even if it involves many exponential backoff-waiting.
4545
const DEFAULT_MAX_RETRIES = 100000;
4646

47+
const claude16kThinkingTokenBudget = 16_000;
4748
export class AiSDKRunner implements LlmRunner {
4849
displayName = 'AI SDK';
4950
id = 'ai-sdk';
@@ -158,27 +159,33 @@ export class AiSDKRunner implements LlmRunner {
158159
const modelName = request.model as (typeof SUPPORTED_MODELS)[number];
159160
switch (modelName) {
160161
case 'claude-opus-4.1-no-thinking':
161-
case 'claude-opus-4.1-with-thinking': {
162-
const thinkingEnabled = request.model.endsWith('with-thinking');
162+
case 'claude-opus-4.1-with-thinking-16k': {
163+
const thinkingEnabled = modelName.includes('-with-thinking');
163164
return {
164165
model: anthropic('claude-opus-4-1'),
165166
providerOptions: {
166167
anthropic: {
167168
sendReasoning: thinkingEnabled,
168-
thinking: {type: thinkingEnabled ? 'enabled' : 'disabled'},
169+
thinking: {
170+
type: thinkingEnabled ? 'enabled' : 'disabled',
171+
budgetTokens: thinkingEnabled ? claude16kThinkingTokenBudget : undefined,
172+
},
169173
} satisfies AnthropicProviderOptions,
170174
},
171175
};
172176
}
173177
case 'claude-sonnet-4.5-no-thinking':
174-
case 'claude-sonnet-4.5-with-thinking': {
175-
const thinkingEnabled = request.model.endsWith('with-thinking');
178+
case 'claude-sonnet-4.5-with-thinking-16k': {
179+
const thinkingEnabled = modelName.includes('-with-thinking');
176180
return {
177181
model: anthropic('claude-sonnet-4-5'),
178182
providerOptions: {
179183
anthropic: {
180184
sendReasoning: thinkingEnabled,
181-
thinking: {type: thinkingEnabled ? 'enabled' : 'disabled'},
185+
thinking: {
186+
type: thinkingEnabled ? 'enabled' : 'disabled',
187+
budgetTokens: thinkingEnabled ? claude16kThinkingTokenBudget : undefined,
188+
},
182189
} satisfies AnthropicProviderOptions,
183190
},
184191
};

0 commit comments

Comments
 (0)