|
| 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 | +}) |
0 commit comments