Skip to content

Commit e8474d4

Browse files
ruben-benaconh2
authored andcommitted
fix: raise stale output ceilings on adaptive-thinking Claude models
LLM: written by Claude Opus 5; needs human review getModelMaxOutputTokens capped adaptive-thinking Claude models at ANTHROPIC_DEFAULT_MAX_TOKENS (8192) with reasoning off and DEFAULT_HYBRID_REASONING_MODEL_MAX_TOKENS (16_384) with it on. Thinking tokens count toward max_tokens, so thinking could consume the whole budget, and Bedrock returned empty, fully billed turns with stop_reason max_tokens. Reasoning-off is not thinking-off on most of these models: Omitting the thinking field selects adaptive thinking on Opus 5 and Sonnet 5, and Fable 5 / 5.1 reject thinking type "disabled" outright. Opus 4.7 and 4.8 are the exception: they don't think unless adaptive thinking is requested, so with reasoning off 8192 was not too small for them, but with reasoning on 16_384 was. Resolve supportsReasoningBinary models from their own declared ceiling in both reasoning states, still subject to the 20% context-window clamp. For Opus 4.7 / 4.8 with reasoning off this only raises the max_tokens ceiling; only generated tokens are billed. 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. This is broader than upstream Zoo-Code-Org#1854 (closing Zoo-Code-Org#1853), which fixed the same 8K/16K budget only for direct-Anthropic Opus 5.5 by dropping its supportsReasoningBudget flag. Keying on supportsReasoningBinary instead covers every provider and sibling model that still declares both flags. Raise maxTokens 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 them on Vertex. Also updates the spec assertions that pinned the old 8192 / 16_384.
1 parent f838eee commit e8474d4

11 files changed

Lines changed: 520 additions & 194 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: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@ export const bedrockModels = {
192192
supportsImages: true,
193193
supportsPromptCache: true,
194194
supportsReasoningBudget: true,
195+
supportsReasoningBinary: true,
196+
supportsMaxTokens: true,
195197
inputPrice: 5.0, // $5 per million input tokens (≤200K context) — verify against Bedrock console
196198
outputPrice: 25.0, // $25 per million output tokens (≤200K context) — verify against Bedrock console
197199
cacheWritesPrice: 6.25, // $6.25 per million tokens
@@ -216,6 +218,8 @@ export const bedrockModels = {
216218
supportsImages: true,
217219
supportsPromptCache: true,
218220
supportsReasoningBudget: true,
221+
supportsReasoningBinary: true,
222+
supportsMaxTokens: true,
219223
inputPrice: 5.0, // $5 per million input tokens (≤200K context) — verify against Bedrock console
220224
outputPrice: 25.0, // $25 per million output tokens (≤200K context) — verify against Bedrock console
221225
cacheWritesPrice: 6.25, // $6.25 per million tokens
@@ -283,6 +287,7 @@ export const bedrockModels = {
283287
supportsPromptCache: true,
284288
supportsReasoningBudget: true,
285289
supportsReasoningBinary: true,
290+
supportsMaxTokens: true,
286291
supportsTemperature: false,
287292
inputPrice: 10.0,
288293
outputPrice: 50.0,
@@ -295,12 +300,13 @@ export const bedrockModels = {
295300
"Claude Fable 5.1 extends Fable 5 with stronger long-running agentic coding, multistep research, and document work.",
296301
},
297302
"anthropic.claude-fable-5": {
298-
maxTokens: 8192,
303+
maxTokens: 128_000,
299304
contextWindow: 1_000_000,
300305
supportsImages: true,
301306
supportsPromptCache: true,
302307
supportsReasoningBudget: true,
303308
supportsReasoningBinary: true,
309+
supportsMaxTokens: true,
304310
supportsTemperature: false,
305311
inputPrice: 10.0,
306312
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
},
@@ -515,12 +519,13 @@ export const vertexModels = {
515519
cacheReadsPrice: 0.25,
516520
supportsReasoningBudget: true,
517521
supportsReasoningBinary: true,
522+
supportsMaxTokens: true,
518523
supportsTemperature: false,
519524
description:
520525
"Claude Fable 5.1 extends Fable 5 with stronger long-running agentic coding, multistep research, and document work.",
521526
},
522527
"claude-fable-5": {
523-
maxTokens: 8192,
528+
maxTokens: 128_000,
524529
contextWindow: 1_000_000,
525530
supportsImages: true,
526531
supportsPromptCache: true,
@@ -530,6 +535,7 @@ export const vertexModels = {
530535
cacheReadsPrice: 1.0,
531536
supportsReasoningBudget: true,
532537
supportsReasoningBinary: true,
538+
supportsMaxTokens: true,
533539
supportsTemperature: false,
534540
description:
535541
"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)

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ describe("AnthropicHandler", () => {
248248

249249
const requestBody = mockCreate.mock.calls[mockCreate.mock.calls.length - 1]?.[0]
250250
expect(requestBody?.thinking).toEqual({ type: "adaptive" })
251-
expect(requestBody?.max_tokens).toBe(16384)
251+
expect(requestBody?.max_tokens).toBe(128_000)
252252
})
253253

254254
it("should omit thinking for Claude Opus 4.7 when reasoning is disabled", async () => {
@@ -269,7 +269,8 @@ describe("AnthropicHandler", () => {
269269

270270
const requestBody = mockCreate.mock.calls[mockCreate.mock.calls.length - 1]?.[0]
271271
expect(requestBody?.thinking).toBeUndefined()
272-
expect(requestBody?.max_tokens).toBe(8192)
272+
// Opus 4.7 doesn't think without a thinking payload; the ceiling is shared with reasoning-on.
273+
expect(requestBody?.max_tokens).toBe(128_000)
273274
})
274275

275276
it("should preserve custom maxTokens for Claude Opus 4.7 when reasoning is enabled", async () => {
@@ -335,7 +336,7 @@ describe("AnthropicHandler", () => {
335336

336337
const requestBody = mockCreate.mock.calls[mockCreate.mock.calls.length - 1]?.[0]
337338
expect(requestBody?.thinking).toEqual({ type: "adaptive" })
338-
expect(requestBody?.max_tokens).toBe(16384)
339+
expect(requestBody?.max_tokens).toBe(128_000)
339340
})
340341

341342
it("should omit thinking for Claude Opus 4.8 when reasoning is disabled", async () => {
@@ -356,7 +357,7 @@ describe("AnthropicHandler", () => {
356357

357358
const requestBody = mockCreate.mock.calls[mockCreate.mock.calls.length - 1]?.[0]
358359
expect(requestBody?.thinking).toBeUndefined()
359-
expect(requestBody?.max_tokens).toBe(8192)
360+
expect(requestBody?.max_tokens).toBe(128_000)
360361
})
361362

362363
it("should preserve custom maxTokens for Claude Opus 4.8 when reasoning is enabled", async () => {
@@ -645,7 +646,7 @@ describe("AnthropicHandler", () => {
645646
expect(model.id).toBe("claude-opus-4-7")
646647
expect(model.info.maxTokens).toBe(128000)
647648
expect(model.info.contextWindow).toBe(1000000)
648-
expect(model.maxTokens).toBe(8192)
649+
expect(model.maxTokens).toBe(128000)
649650
expect(model.info.supportsReasoningBinary).toBe(true)
650651
expect(model.info.supportsReasoningBudget).toBe(true)
651652
expect(model.info.supportsPromptCache).toBe(true)
@@ -661,7 +662,7 @@ describe("AnthropicHandler", () => {
661662
expect(model.id).toBe("claude-opus-4-8")
662663
expect(model.info.maxTokens).toBe(128000)
663664
expect(model.info.contextWindow).toBe(1000000)
664-
expect(model.maxTokens).toBe(8192)
665+
expect(model.maxTokens).toBe(128000)
665666
expect(model.info.supportsReasoningBinary).toBe(true)
666667
expect(model.info.supportsReasoningBudget).toBe(true)
667668
expect(model.info.supportsPromptCache).toBe(true)
@@ -678,7 +679,7 @@ describe("AnthropicHandler", () => {
678679
expect(model.id).toBe("claude-fable-5")
679680
expect(model.info.maxTokens).toBe(128000)
680681
expect(model.info.contextWindow).toBe(1000000)
681-
expect(model.maxTokens).toBe(8192)
682+
expect(model.maxTokens).toBe(128000)
682683
expect(model.info.supportsReasoningBinary).toBe(true)
683684
expect(model.info.supportsReasoningBudget).toBe(true)
684685
expect(model.info.supportsPromptCache).toBe(true)
@@ -695,7 +696,7 @@ describe("AnthropicHandler", () => {
695696
expect(model.id).toBe("claude-fable-5-1")
696697
expect(model.info.maxTokens).toBe(128000)
697698
expect(model.info.contextWindow).toBe(1000000)
698-
expect(model.maxTokens).toBe(8192)
699+
expect(model.maxTokens).toBe(128000)
699700
expect(model.info.inputPrice).toBe(10)
700701
expect(model.info.outputPrice).toBe(50)
701702
expect(model.info.cacheWritesPrice).toBe(12.5)
@@ -716,7 +717,7 @@ describe("AnthropicHandler", () => {
716717
expect(model.id).toBe("claude-sonnet-5")
717718
expect(model.info.maxTokens).toBe(128000)
718719
expect(model.info.contextWindow).toBe(1000000)
719-
expect(model.maxTokens).toBe(8192)
720+
expect(model.maxTokens).toBe(128000)
720721
expect(model.info.supportsReasoningBinary).toBe(true)
721722
expect(model.info.supportsReasoningBudget).toBe(true)
722723
expect(model.info.supportsPromptCache).toBe(true)
@@ -733,7 +734,7 @@ describe("AnthropicHandler", () => {
733734
expect(model.id).toBe("claude-opus-5")
734735
expect(model.info.maxTokens).toBe(128000)
735736
expect(model.info.contextWindow).toBe(1000000)
736-
expect(model.maxTokens).toBe(8192)
737+
expect(model.maxTokens).toBe(128000)
737738
expect(model.info.supportsReasoningBinary).toBe(true)
738739
expect(model.info.supportsReasoningBudget).toBe(true)
739740
expect(model.info.supportsPromptCache).toBe(true)

0 commit comments

Comments
 (0)