Skip to content

Commit ac8714d

Browse files
authored
feat: enable interleaved thinking for Claude 4 models (#323)
*Issue #, if available:* closes #322 *Description of changes:* By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
1 parent 162a876 commit ac8714d

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

packages/agent-core/src/lib/converse.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@ const preProcessInput = (
144144
...input.inferenceConfig,
145145
maxTokens: Math.max(adjustedMaxToken, Math.min(budget * 2, modelConfig.maxOutputTokens)),
146146
};
147+
148+
if (modelConfig.interleavedThinkingSupport) {
149+
input.additionalModelRequestFields.anthropic_beta = ['interleaved-thinking-2025-05-14'];
150+
}
147151
} else {
148152
// when we disable reasoning, we have to remove
149153
// reasoningContent blocks from all the previous message contents

packages/agent-core/src/schema/model.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const modelConfigSchema = z.object({
2222
reasoningSupport: z.boolean(),
2323
toolChoiceSupport: z.array(z.enum(['any', 'auto', 'tool'])),
2424
isHidden: z.boolean().optional(),
25+
interleavedThinkingSupport: z.boolean().optional(),
2526
pricing: z.object({
2627
input: z.number(),
2728
output: z.number(),
@@ -92,6 +93,7 @@ export const modelConfigs: Record<ModelType, z.infer<typeof modelConfigSchema>>
9293
reasoningSupport: true,
9394
toolChoiceSupport: ['any', 'auto', 'tool'],
9495
isHidden: true,
96+
interleavedThinkingSupport: true,
9597
pricing: { input: 0.015, output: 0.075, cacheRead: 0.0015, cacheWrite: 0.01875 },
9698
},
9799
'opus4.1': {
@@ -102,6 +104,7 @@ export const modelConfigs: Record<ModelType, z.infer<typeof modelConfigSchema>>
102104
cacheSupport: ['system', 'message', 'tool'],
103105
reasoningSupport: true,
104106
toolChoiceSupport: ['any', 'auto', 'tool'],
107+
interleavedThinkingSupport: true,
105108
pricing: { input: 0.015, output: 0.075, cacheRead: 0.0015, cacheWrite: 0.01875 },
106109
},
107110
sonnet4: {
@@ -112,6 +115,7 @@ export const modelConfigs: Record<ModelType, z.infer<typeof modelConfigSchema>>
112115
cacheSupport: ['system', 'message', 'tool'],
113116
reasoningSupport: true,
114117
toolChoiceSupport: ['any', 'auto', 'tool'],
118+
interleavedThinkingSupport: true,
115119
pricing: { input: 0.003, output: 0.015, cacheRead: 0.0003, cacheWrite: 0.00375 },
116120
},
117121
};

0 commit comments

Comments
 (0)