Skip to content

Commit 29efc96

Browse files
committed
fix: raise stale output ceilings on adaptive-thinking Claude models
LLM: written by Claude Opus 5; needs human review Claude 4.7+ models reason server-side whether or not a thinking payload is sent, so reasoning-off is not thinking-off. getModelMaxOutputTokens capped them at ANTHROPIC_DEFAULT_MAX_TOKENS (8192) with reasoning off and DEFAULT_HYBRID_REASONING_MODEL_MAX_TOKENS (16_384) with it on; thinking consumed the whole budget and Bedrock returned empty, fully billed turns with stop_reason max_tokens. Raise to max output tokens to 128_000 on the Bedrock entries claude-sonnet-5, claude-opus-5, claude-fable-5, claude-opus-4-7 and claude-opus-4-8, matching the values their anthropicModels twins already declare, and mirror claude-opus-5 on Vertex. 4-7 / 4-8 were audited rather than assumed: isAdaptiveThinkingModel matches them by model ID alone, so they take the identical adaptive-thinking API contract and the same shared output budget. Also updates one anthropic-vertex.spec.ts assertion that pinned the old 8192 for claude-opus-5. Resolve supportsReasoningBinary models from their own declared ceiling in both reasoning states instead, still subject to the 20% context-window clamp. Budget-controlled hybrid models (Sonnet 4.x, Opus 4.6 and earlier) keep the 8192 default — that branch is correct for them. Neither constant changed, only which models reach them.
1 parent b3de6e5 commit 29efc96

12 files changed

Lines changed: 486 additions & 168 deletions

File tree

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
import type { ModelInfo } from "../model.js"
2+
import { bedrockModels } from "../providers/bedrock.js"
3+
import { vertexModels } from "../providers/vertex.js"
4+
import { anthropicModels } from "../providers/anthropic.js"
5+
6+
// The Bedrock and Vertex registries are hand-maintained, so entries are copy-pasted and the
7+
// pre-adaptive-thinking `maxTokens: 8192` default silently drifts onto new Claude models.
8+
const REFERENCE_MODEL_ID = "anthropic.claude-fable-5-1"
9+
const VERTEX_REFERENCE_MODEL_ID = "claude-fable-5-1"
10+
const ADAPTIVE_THINKING_MAX_OUTPUT_TOKENS = 128_000
11+
12+
describe("bedrockModels adaptive-thinking output ceilings", () => {
13+
it("keeps the reference model at the documented 128K ceiling", () => {
14+
expect(bedrockModels[REFERENCE_MODEL_ID].maxTokens).toBe(ADAPTIVE_THINKING_MAX_OUTPUT_TOKENS)
15+
})
16+
17+
it.each([
18+
["anthropic.claude-opus-5", ADAPTIVE_THINKING_MAX_OUTPUT_TOKENS],
19+
["anthropic.claude-sonnet-5", ADAPTIVE_THINKING_MAX_OUTPUT_TOKENS],
20+
["anthropic.claude-fable-5", ADAPTIVE_THINKING_MAX_OUTPUT_TOKENS],
21+
["anthropic.claude-fable-5-1", ADAPTIVE_THINKING_MAX_OUTPUT_TOKENS],
22+
["anthropic.claude-opus-4-7", ADAPTIVE_THINKING_MAX_OUTPUT_TOKENS],
23+
["anthropic.claude-opus-4-8", ADAPTIVE_THINKING_MAX_OUTPUT_TOKENS],
24+
] as const)("declares maxTokens %s = %i", (modelId, expected) => {
25+
expect(bedrockModels[modelId].maxTokens).toBe(expected)
26+
})
27+
28+
it("gives every adaptive-thinking model the same ceiling as the reference model", () => {
29+
// Widening to ModelInfo: the const literal's inferred type only carries
30+
// `supportsReasoningBinary` on the members that declare it.
31+
const entries = Object.entries(bedrockModels as Record<string, ModelInfo>)
32+
const adaptiveThinkingEntries = entries.filter(([, info]) => info.supportsReasoningBinary === true)
33+
34+
// If the flag is ever renamed, an empty list must not pass silently.
35+
expect(adaptiveThinkingEntries.length).toBeGreaterThanOrEqual(4)
36+
37+
for (const [modelId, info] of adaptiveThinkingEntries) {
38+
expect(info.maxTokens, `${modelId} must share the adaptive-thinking output ceiling`).toBe(
39+
ADAPTIVE_THINKING_MAX_OUTPUT_TOKENS,
40+
)
41+
}
42+
})
43+
44+
it.each([
45+
["anthropic.claude-opus-5", "claude-opus-5"],
46+
["anthropic.claude-sonnet-5", "claude-sonnet-5"],
47+
["anthropic.claude-fable-5", "claude-fable-5"],
48+
["anthropic.claude-fable-5-1", "claude-fable-5-1"],
49+
["anthropic.claude-opus-4-7", "claude-opus-4-7"],
50+
["anthropic.claude-opus-4-8", "claude-opus-4-8"],
51+
] as const)("matches the Anthropic direct-API ceiling for %s", (bedrockId, anthropicId) => {
52+
expect(bedrockModels[bedrockId].maxTokens).toBe(anthropicModels[anthropicId].maxTokens)
53+
})
54+
55+
it.each([
56+
["anthropic.claude-opus-4-7"],
57+
["anthropic.claude-opus-4-8"],
58+
["anthropic.claude-opus-5"],
59+
["anthropic.claude-sonnet-5"],
60+
["anthropic.claude-fable-5"],
61+
["anthropic.claude-fable-5-1"],
62+
] as const)("marks %s as binary-reasoning", (modelId) => {
63+
expect(bedrockModels[modelId].supportsReasoningBinary).toBe(true)
64+
})
65+
66+
it("lets the user override the output budget on every adaptive-thinking model", () => {
67+
const entries = Object.entries(bedrockModels as Record<string, ModelInfo>)
68+
const adaptiveThinkingEntries = entries.filter(([, info]) => info.supportsReasoningBinary === true)
69+
70+
expect(adaptiveThinkingEntries.length).toBeGreaterThanOrEqual(4)
71+
72+
for (const [modelId, info] of adaptiveThinkingEntries) {
73+
expect(info.supportsMaxTokens, `${modelId} must expose a configurable output budget`).toBe(true)
74+
}
75+
})
76+
})
77+
78+
// Vertex is a second hand-maintained registry that drifts independently of Bedrock.
79+
describe("vertexModels adaptive-thinking output ceilings", () => {
80+
it("keeps the reference model at the documented 128K ceiling", () => {
81+
expect(vertexModels[VERTEX_REFERENCE_MODEL_ID].maxTokens).toBe(ADAPTIVE_THINKING_MAX_OUTPUT_TOKENS)
82+
})
83+
84+
it.each([
85+
["claude-opus-5", ADAPTIVE_THINKING_MAX_OUTPUT_TOKENS],
86+
["claude-sonnet-5", ADAPTIVE_THINKING_MAX_OUTPUT_TOKENS],
87+
["claude-fable-5", ADAPTIVE_THINKING_MAX_OUTPUT_TOKENS],
88+
["claude-fable-5-1", ADAPTIVE_THINKING_MAX_OUTPUT_TOKENS],
89+
["claude-opus-4-7", ADAPTIVE_THINKING_MAX_OUTPUT_TOKENS],
90+
["claude-opus-4-8", ADAPTIVE_THINKING_MAX_OUTPUT_TOKENS],
91+
] as const)("declares maxTokens %s = %i", (modelId, expected) => {
92+
expect(vertexModels[modelId].maxTokens).toBe(expected)
93+
})
94+
95+
it("gives every adaptive-thinking model the same ceiling as the reference model", () => {
96+
const entries = Object.entries(vertexModels as Record<string, ModelInfo>)
97+
const adaptiveThinkingEntries = entries.filter(([, info]) => info.supportsReasoningBinary === true)
98+
99+
expect(adaptiveThinkingEntries.length).toBeGreaterThanOrEqual(4)
100+
101+
for (const [modelId, info] of adaptiveThinkingEntries) {
102+
expect(info.maxTokens, `${modelId} must share the adaptive-thinking output ceiling`).toBe(
103+
ADAPTIVE_THINKING_MAX_OUTPUT_TOKENS,
104+
)
105+
}
106+
})
107+
108+
it.each([
109+
["claude-opus-5"],
110+
["claude-sonnet-5"],
111+
["claude-fable-5"],
112+
["claude-fable-5-1"],
113+
["claude-opus-4-7"],
114+
["claude-opus-4-8"],
115+
] as const)("matches the Anthropic direct-API ceiling for %s", (modelId) => {
116+
expect(vertexModels[modelId].maxTokens).toBe(anthropicModels[modelId].maxTokens)
117+
})
118+
119+
it("lets the user override the output budget on every adaptive-thinking model", () => {
120+
const entries = Object.entries(vertexModels as Record<string, ModelInfo>)
121+
const adaptiveThinkingEntries = entries.filter(([, info]) => info.supportsReasoningBinary === true)
122+
123+
expect(adaptiveThinkingEntries.length).toBeGreaterThanOrEqual(4)
124+
125+
for (const [modelId, info] of adaptiveThinkingEntries) {
126+
expect(info.supportsMaxTokens, `${modelId} must expose a configurable output budget`).toBe(true)
127+
}
128+
})
129+
})

‎packages/types/src/providers/bedrock.ts‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,13 @@ export const bedrockModels = {
5252
],
5353
},
5454
"anthropic.claude-sonnet-5": {
55-
maxTokens: 8192,
55+
maxTokens: 128_000,
5656
contextWindow: 1_000_000, // 1M context window native (no beta header required)
5757
supportsImages: true,
5858
supportsPromptCache: true,
5959
supportsReasoningBudget: true,
6060
supportsReasoningBinary: true,
61+
supportsMaxTokens: true,
6162
supportsTemperature: false,
6263
inputPrice: 2.0, // $2 per million input tokens (introductory pricing through Aug 31, 2026)
6364
outputPrice: 10.0, // $10 per million output tokens (introductory pricing through Aug 31, 2026)
@@ -186,11 +187,13 @@ export const bedrockModels = {
186187
],
187188
},
188189
"anthropic.claude-opus-4-7": {
189-
maxTokens: 8192,
190+
maxTokens: 128_000,
190191
contextWindow: 200_000, // Default 200K, extendable to 1M with beta flag 'context-1m-2025-08-07'
191192
supportsImages: true,
192193
supportsPromptCache: true,
193194
supportsReasoningBudget: true,
195+
supportsReasoningBinary: true,
196+
supportsMaxTokens: true,
194197
inputPrice: 5.0, // $5 per million input tokens (≤200K context) — verify against Bedrock console
195198
outputPrice: 25.0, // $25 per million output tokens (≤200K context) — verify against Bedrock console
196199
cacheWritesPrice: 6.25, // $6.25 per million tokens
@@ -210,11 +213,13 @@ export const bedrockModels = {
210213
],
211214
},
212215
"anthropic.claude-opus-4-8": {
213-
maxTokens: 8192,
216+
maxTokens: 128_000,
214217
contextWindow: 200_000, // Default 200K, extendable to 1M with beta flag 'context-1m-2025-08-07'
215218
supportsImages: true,
216219
supportsPromptCache: true,
217220
supportsReasoningBudget: true,
221+
supportsReasoningBinary: true,
222+
supportsMaxTokens: true,
218223
inputPrice: 5.0, // $5 per million input tokens (≤200K context) — verify against Bedrock console
219224
outputPrice: 25.0, // $25 per million output tokens (≤200K context) — verify against Bedrock console
220225
cacheWritesPrice: 6.25, // $6.25 per million tokens
@@ -236,12 +241,13 @@ export const bedrockModels = {
236241
],
237242
},
238243
"anthropic.claude-opus-5": {
239-
maxTokens: 8192,
244+
maxTokens: 128_000,
240245
contextWindow: 1_000_000, // 1M context window native (no beta header required)
241246
supportsImages: true,
242247
supportsPromptCache: true,
243248
supportsReasoningBudget: true,
244249
supportsReasoningBinary: true,
250+
supportsMaxTokens: true,
245251
supportsTemperature: false,
246252
inputPrice: 5.0, // $5 per million input tokens
247253
outputPrice: 25.0, // $25 per million output tokens
@@ -259,6 +265,7 @@ export const bedrockModels = {
259265
supportsPromptCache: true,
260266
supportsReasoningBudget: true,
261267
supportsReasoningBinary: true,
268+
supportsMaxTokens: true,
262269
supportsTemperature: false,
263270
inputPrice: 10.0,
264271
outputPrice: 50.0,
@@ -271,12 +278,13 @@ export const bedrockModels = {
271278
"Claude Fable 5.1 extends Fable 5 with stronger long-running agentic coding, multistep research, and document work.",
272279
},
273280
"anthropic.claude-fable-5": {
274-
maxTokens: 8192,
281+
maxTokens: 128_000,
275282
contextWindow: 1_000_000,
276283
supportsImages: true,
277284
supportsPromptCache: true,
278285
supportsReasoningBudget: true,
279286
supportsReasoningBinary: true,
287+
supportsMaxTokens: true,
280288
supportsTemperature: false,
281289
inputPrice: 10.0,
282290
outputPrice: 50.0,

‎packages/types/src/providers/vertex.ts‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ export const vertexModels = {
382382
],
383383
},
384384
"claude-sonnet-5": {
385-
maxTokens: 8192,
385+
maxTokens: 128_000,
386386
contextWindow: 1_000_000, // 1M context window native (no beta header required)
387387
supportsImages: true,
388388
supportsPromptCache: true,
@@ -392,6 +392,7 @@ export const vertexModels = {
392392
cacheReadsPrice: 0.2, // $0.20 per million tokens (introductory pricing through Aug 31, 2026)
393393
supportsReasoningBudget: true,
394394
supportsReasoningBinary: true,
395+
supportsMaxTokens: true,
395396
supportsTemperature: false,
396397
description:
397398
"Claude Sonnet 5 is the best combination of speed and intelligence, optimized for coding, tool use, and agentic workflows.",
@@ -429,7 +430,7 @@ export const vertexModels = {
429430
],
430431
},
431432
"claude-opus-4-7": {
432-
maxTokens: 8192,
433+
maxTokens: 128_000,
433434
contextWindow: 200_000, // Default 200K, extendable to 1M with beta flag 'context-1m-2025-08-07'
434435
supportsImages: true,
435436
supportsPromptCache: true,
@@ -439,6 +440,7 @@ export const vertexModels = {
439440
cacheReadsPrice: 0.5, // $0.50 per million tokens
440441
supportsReasoningBudget: true,
441442
supportsReasoningBinary: true,
443+
supportsMaxTokens: true,
442444
supportsTemperature: false,
443445
// Tiered pricing for extended context (requires beta flag 'context-1m-2025-08-07')
444446
tiers: [
@@ -452,7 +454,7 @@ export const vertexModels = {
452454
],
453455
},
454456
"claude-opus-4-8": {
455-
maxTokens: 8192,
457+
maxTokens: 128_000,
456458
contextWindow: 200_000, // Default 200K, extendable to 1M with beta flag 'context-1m-2025-08-07'
457459
supportsImages: true,
458460
supportsPromptCache: true,
@@ -462,6 +464,7 @@ export const vertexModels = {
462464
cacheReadsPrice: 0.5, // $0.50 per million tokens
463465
supportsReasoningBudget: true,
464466
supportsReasoningBinary: true,
467+
supportsMaxTokens: true,
465468
supportsTemperature: false,
466469
// 4.8 inherits the same Vertex pricing structure as 4.7 — no breaking changes.
467470
// Tiered pricing for extended context (requires beta flag 'context-1m-2025-08-07')
@@ -476,7 +479,7 @@ export const vertexModels = {
476479
],
477480
},
478481
"claude-opus-5": {
479-
maxTokens: 8192,
482+
maxTokens: 128_000,
480483
contextWindow: 1_000_000, // 1M context window native (no beta header required)
481484
supportsImages: true,
482485
supportsPromptCache: true,
@@ -486,6 +489,7 @@ export const vertexModels = {
486489
cacheReadsPrice: 0.5, // $0.50 per million tokens
487490
supportsReasoningBudget: true,
488491
supportsReasoningBinary: true,
492+
supportsMaxTokens: true,
489493
supportsTemperature: false,
490494
description: "Claude Opus 5 is Anthropic's most capable model for complex agentic coding and enterprise work.",
491495
},
@@ -500,12 +504,13 @@ export const vertexModels = {
500504
cacheReadsPrice: 0.25,
501505
supportsReasoningBudget: true,
502506
supportsReasoningBinary: true,
507+
supportsMaxTokens: true,
503508
supportsTemperature: false,
504509
description:
505510
"Claude Fable 5.1 extends Fable 5 with stronger long-running agentic coding, multistep research, and document work.",
506511
},
507512
"claude-fable-5": {
508-
maxTokens: 8192,
513+
maxTokens: 128_000,
509514
contextWindow: 1_000_000,
510515
supportsImages: true,
511516
supportsPromptCache: true,
@@ -515,6 +520,7 @@ export const vertexModels = {
515520
cacheReadsPrice: 1.0,
516521
supportsReasoningBudget: true,
517522
supportsReasoningBinary: true,
523+
supportsMaxTokens: true,
518524
supportsTemperature: false,
519525
description:
520526
"Claude Fable 5 is Anthropic's most capable widely released model for the most demanding reasoning and long-horizon agentic work.",

‎src/api/providers/__tests__/anthropic-vertex.spec.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,7 @@ describe("VertexHandler", () => {
984984

985985
const model = handler.getModel()
986986
expect(model.id).toBe("claude-fable-5")
987-
expect(model.info.maxTokens).toBe(8192)
987+
expect(model.info.maxTokens).toBe(128_000)
988988
expect(model.info.contextWindow).toBe(1_000_000)
989989
expect(model.info.supportsReasoningBinary).toBe(true)
990990
expect(model.info.supportsReasoningBudget).toBe(true)
@@ -1019,7 +1019,7 @@ describe("VertexHandler", () => {
10191019

10201020
const model = handler.getModel()
10211021
expect(model.id).toBe("claude-sonnet-5")
1022-
expect(model.info.maxTokens).toBe(8192)
1022+
expect(model.info.maxTokens).toBe(128_000)
10231023
expect(model.info.contextWindow).toBe(1_000_000)
10241024
expect(model.info.supportsReasoningBinary).toBe(true)
10251025
expect(model.info.supportsReasoningBudget).toBe(true)
@@ -1036,7 +1036,7 @@ describe("VertexHandler", () => {
10361036

10371037
const model = handler.getModel()
10381038
expect(model.id).toBe("claude-opus-5")
1039-
expect(model.info.maxTokens).toBe(8192)
1039+
expect(model.info.maxTokens).toBe(128_000)
10401040
expect(model.info.contextWindow).toBe(1_000_000)
10411041
expect(model.info.supportsReasoningBinary).toBe(true)
10421042
expect(model.info.supportsReasoningBudget).toBe(true)

0 commit comments

Comments
 (0)