diff --git a/packages/types/src/providers/bedrock.ts b/packages/types/src/providers/bedrock.ts index 8951778318..492089be5b 100644 --- a/packages/types/src/providers/bedrock.ts +++ b/packages/types/src/providers/bedrock.ts @@ -14,7 +14,7 @@ export const bedrockDefaultPromptRouterModelId: BedrockModelId = "anthropic.clau // feature. export const bedrockModels = { "anthropic.claude-sonnet-4-5-20250929-v1:0": { - maxTokens: 8192, + maxTokens: 64_000, contextWindow: 200_000, supportsImages: true, supportsPromptCache: true, @@ -28,7 +28,7 @@ export const bedrockModels = { cachableFields: ["system", "messages", "tools"], }, "anthropic.claude-sonnet-4-6": { - maxTokens: 8192, + maxTokens: 64_000, contextWindow: 200_000, // Default 200K, extendable to 1M with beta flag 'context-1m-2025-08-07' supportsImages: true, supportsPromptCache: true, @@ -52,7 +52,8 @@ export const bedrockModels = { ], }, "anthropic.claude-sonnet-5": { - maxTokens: 8192, + maxTokens: 128_000, + supportsMaxTokens: true, contextWindow: 1_000_000, // 1M context window native (no beta header required) supportsImages: true, supportsPromptCache: true, @@ -186,7 +187,7 @@ export const bedrockModels = { ], }, "anthropic.claude-opus-4-7": { - maxTokens: 8192, + maxTokens: 128_000, contextWindow: 200_000, // Default 200K, extendable to 1M with beta flag 'context-1m-2025-08-07' supportsImages: true, supportsPromptCache: true, @@ -210,7 +211,7 @@ export const bedrockModels = { ], }, "anthropic.claude-opus-4-8": { - maxTokens: 8192, + maxTokens: 128_000, contextWindow: 200_000, // Default 200K, extendable to 1M with beta flag 'context-1m-2025-08-07' supportsImages: true, supportsPromptCache: true, @@ -236,7 +237,8 @@ export const bedrockModels = { ], }, "anthropic.claude-opus-5": { - maxTokens: 8192, + maxTokens: 128_000, + supportsMaxTokens: true, contextWindow: 1_000_000, // 1M context window native (no beta header required) supportsImages: true, supportsPromptCache: true, @@ -672,6 +674,14 @@ export const BEDROCK_1M_CONTEXT_MODEL_IDS = [ "anthropic.claude-opus-4-8", ] as const +// Amazon Bedrock models whose adaptive thinking is on by default and must be +// turned off with an explicit `thinking: { type: "disabled" }`. Adaptive-only +// models (Fable 5/5.1, Opus 5.5) reject that field with a 400, so they are +// intentionally absent. +// https://docs.aws.amazon.com/bedrock/latest/userguide/model-card-anthropic-claude-sonnet-5.html +// https://docs.aws.amazon.com/bedrock/latest/userguide/model-card-anthropic-claude-opus-5.html +export const BEDROCK_THINKING_DISABLE_MODEL_IDS = ["anthropic.claude-sonnet-5", "anthropic.claude-opus-5"] as const + // Amazon Bedrock models that support Global Inference profiles // As of Nov 2025, AWS supports Global Inference for: // - Claude Sonnet 4 diff --git a/src/api/providers/__tests__/bedrock.spec.ts b/src/api/providers/__tests__/bedrock.spec.ts index 000e61e253..fd6da53a9b 100644 --- a/src/api/providers/__tests__/bedrock.spec.ts +++ b/src/api/providers/__tests__/bedrock.spec.ts @@ -70,6 +70,9 @@ import { HttpsProxyAgent } from "https-proxy-agent" import { makeCreateMessageMetadata } from "../../../test-utils/api" import { clearAllMocks } from "../../../test-utils/reset" +import { asyncStreamFrom, collectStream } from "../../../test-utils/stream" +import type { ApiStreamChunk } from "../../transform/stream" +import { OutputTokenLimitError } from "../utils/output-token-limit-error" // Get access to the mocked functions const mockConverseStreamCommand = vi.mocked(ConverseStreamCommand) @@ -94,6 +97,73 @@ describe("AwsBedrockHandler", () => { }) }) + it.each(["max_tokens", "end_turn", "tool_use", "stop_sequence"])( + "reports truncation only for %s, after preserving usage", + async (stopReason) => { + handler["client"].send = vi.fn().mockResolvedValue({ + stream: asyncStreamFrom([ + { contentBlockDelta: { delta: { reasoningContent: { text: "Still thinking" } } } }, + { messageStop: { stopReason } }, + { metadata: { usage: { inputTokens: 37, outputTokens: 16384 } } }, + ]), + }) + const chunks: ApiStreamChunk[] = [] + const consume = async () => { + for await (const chunk of handler.createMessage("system", [{ role: "user", content: "hello" }])) { + chunks.push(chunk) + } + } + if (stopReason === "max_tokens") { + const error = await consume().then( + () => undefined, + (e: unknown) => e, + ) + expect(error).toBeInstanceOf(OutputTokenLimitError) + expect((error as Error).message).toContain( + "Output token limit reached. Consider increasing Max Output Tokens", + ) + } else { + await expect(consume()).resolves.toBeUndefined() + } + expect(chunks).toEqual( + expect.arrayContaining([ + { type: "reasoning", text: "Still thinking" }, + expect.objectContaining({ type: "usage", inputTokens: 37, outputTokens: 16384 }), + ]), + ) + }, + ) + + it.each([ + ["anthropic.claude-sonnet-4-5-20250929-v1:0", 64_000], + ["anthropic.claude-sonnet-4-6", 64_000], + ["anthropic.claude-sonnet-5", 128_000], + ["anthropic.claude-opus-4-7", 128_000], + ["anthropic.claude-opus-4-8", 128_000], + ["anthropic.claude-opus-5", 128_000], + ] as const)("exposes %s output ceiling without raising request defaults", async (apiModelId, ceiling) => { + for (const enableReasoningEffort of [true, false]) { + for (const modelMaxTokens of [undefined, ceiling]) { + const provider = new AwsBedrockHandler({ apiModelId, enableReasoningEffort, modelMaxTokens }) + expect(provider.getModel().info.maxTokens).toBe(ceiling) + provider["client"].send = vi.fn().mockResolvedValue({ stream: asyncStreamFrom([]) }) + await collectStream(provider.createMessage("system", [{ role: "user", content: "hello" }])) + const configurableWithoutReasoning = apiModelId.endsWith("-5") + const expected = + modelMaxTokens && (enableReasoningEffort || configurableWithoutReasoning) + ? ceiling + : enableReasoningEffort + ? 16_384 + : 8192 + expect(mockConverseStreamCommand).toHaveBeenLastCalledWith( + expect.objectContaining({ + inferenceConfig: expect.objectContaining({ maxTokens: expected }), + }), + ) + } + } + }) + describe("getModel", () => { it("should return the correct model info for a standard model", () => { const modelInfo = handler.getModel() @@ -1735,23 +1805,51 @@ describe("AwsBedrockHandler", () => { }) it("should omit thinking and temperature for Claude Opus 4.8 when reasoning is disabled", async () => { - const opus48Handler = new AwsBedrockHandler({ + const provider = new AwsBedrockHandler({ apiModelId: "anthropic.claude-opus-4-8", - awsAccessKey: "test-access-key", - awsSecretKey: "test-secret-key", - awsRegion: "us-east-1", enableReasoningEffort: false, }) + await collectStream(provider.createMessage("System prompt", messages)) - const generator = opus48Handler.createMessage("System prompt", messages) - await generator.next() + const commandArg = mockConverseStreamCommand.mock.calls[0][0] + expect(commandArg.additionalModelRequestFields).not.toHaveProperty("thinking") + expect(commandArg.inferenceConfig?.temperature).toBeUndefined() + }) - expect(mockConverseStreamCommand).toHaveBeenCalled() - const commandArg = mockConverseStreamCommand.mock.calls[0][0] as any + it.each(["anthropic.claude-sonnet-5", "anthropic.claude-opus-5", "us.anthropic.claude-opus-5"])( + "explicitly disables thinking for %s when reasoning is disabled", + async (apiModelId) => { + const provider = new AwsBedrockHandler({ + apiModelId, + enableReasoningEffort: false, + modelMaxTokens: 32_000, + }) + await collectStream(provider.createMessage("System prompt", messages)) - // Without reasoning enabled, no adaptive thinking payload is sent. - expect(commandArg.additionalModelRequestFields?.thinking).toBeUndefined() - // Temperature is still omitted for 4.8 because the API rejects sampling params. + const commandArg = mockConverseStreamCommand.mock.calls[0][0] + expect(commandArg.additionalModelRequestFields).toEqual( + expect.objectContaining({ thinking: { type: "disabled" } }), + ) + expect(commandArg.inferenceConfig?.temperature).toBeUndefined() + }, + ) + + it.each([ + "anthropic.claude-fable-5", + "anthropic.claude-fable-5-1", + "anthropic.claude-opus-5-5", + "global.anthropic.claude-opus-5-5", + ])("omits thinking for adaptive-only %s when reasoning is disabled", async (apiModelId) => { + // These models reject thinking.type "disabled" with a 400. + const provider = new AwsBedrockHandler({ + apiModelId, + enableReasoningEffort: false, + modelMaxTokens: 32_000, + }) + await collectStream(provider.createMessage("System prompt", messages)) + + const commandArg = mockConverseStreamCommand.mock.calls[0][0] + expect(commandArg.additionalModelRequestFields ?? {}).not.toHaveProperty("thinking") expect(commandArg.inferenceConfig?.temperature).toBeUndefined() }) diff --git a/src/api/providers/bedrock.ts b/src/api/providers/bedrock.ts index 9c42005545..2e71ce0e12 100644 --- a/src/api/providers/bedrock.ts +++ b/src/api/providers/bedrock.ts @@ -30,6 +30,7 @@ import { BEDROCK_DEFAULT_CONTEXT, AWS_INFERENCE_PROFILE_MAPPING, BEDROCK_1M_CONTEXT_MODEL_IDS, + BEDROCK_THINKING_DISABLE_MODEL_IDS, BEDROCK_GLOBAL_INFERENCE_MODEL_IDS, BEDROCK_SERVICE_TIER_MODEL_IDS, BEDROCK_SERVICE_TIER_PRICING, @@ -51,6 +52,7 @@ import { normalizeToolSchema } from "../../utils/json-schema" import { getSystemProxyUrl } from "../../utils/networkProxy" import type { SingleCompletionHandler, ApiHandlerCreateMessageMetadata, CompletePromptOptions } from "../index" import { mergeAbortSignalAndTimeout } from "./utils/abort-signal" +import { OutputTokenLimitError } from "./utils/output-token-limit-error" /************************************************************************************ * @@ -78,6 +80,7 @@ interface BedrockAdditionalModelFields { // "summarized" shows thinking content in UI; omit to keep thinking internal only display?: "summarized" | "none" } + | { type: "disabled" } output_config?: { // Claude 4.7+ effort levels: "low" | "medium" | "high" | "xhigh" | "max" effort: string @@ -487,6 +490,10 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH modelId: modelConfig.id, thinking: additionalModelRequestFields?.thinking, }) + } else if ((BEDROCK_THINKING_DISABLE_MODEL_IDS as readonly string[]).includes(baseModelId)) { + // Omitting thinking enables it by default on these models. Adaptive-only + // models (Fable 5/5.1, Opus 5.5) reject "disabled", so they keep the omit behavior. + additionalModelRequestFields = { thinking: { type: "disabled" } } } const inferenceConfig: BedrockInferenceConfig = { @@ -601,6 +608,7 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH throw new Error("No stream available in the response") } + let outputLimitReached = false for await (const chunk of response.stream) { // Parse the chunk as JSON if it's a string (for tests) let streamEvent: StreamEvent @@ -784,9 +792,14 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH } // Handle message stop if (streamEvent.messageStop) { + outputLimitReached = streamEvent.messageStop.stopReason === "max_tokens" continue } } + // Bedrock sends usage metadata after messageStop. Preserve it before reporting truncation. + if (outputLimitReached) { + throw new OutputTokenLimitError() + } // Clear timeout after stream completes clearTimeout(timeoutId) } catch (error: unknown) { @@ -801,6 +814,12 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH // Check if this is a throttling error that should trigger retry logic const errorType = this.getErrorType(error) + // Truncation is deterministic: rethrow as-is so the task loop can tell it apart + // from transient stream failures and skip the automatic retry. + if (error instanceof OutputTokenLimitError) { + throw error + } + // For throttling errors, throw immediately without yielding chunks // This allows the retry mechanism in attemptApiRequest() to catch and handle it // The retry logic in Task.ts (around line 1817) expects errors to be thrown diff --git a/src/api/providers/utils/output-token-limit-error.ts b/src/api/providers/utils/output-token-limit-error.ts new file mode 100644 index 0000000000..8fcfbd3831 --- /dev/null +++ b/src/api/providers/utils/output-token-limit-error.ts @@ -0,0 +1,15 @@ +/** + * Error thrown when a provider stops generating because the response hit the + * configured output token limit. + * + * Re-sending the same request with the same limit truncates again, so the task + * loop must not auto-retry it; the user has to raise the limit or change course. + */ +export class OutputTokenLimitError extends Error { + constructor(message = "Output token limit reached. Consider increasing Max Output Tokens in the model settings.") { + super(message) + this.name = "OutputTokenLimitError" + // Maintains proper prototype chain for instanceof checks + Object.setPrototypeOf(this, OutputTokenLimitError.prototype) + } +} diff --git a/src/core/task/Task.ts b/src/core/task/Task.ts index 55798437c3..6a3ce62012 100644 --- a/src/core/task/Task.ts +++ b/src/core/task/Task.ts @@ -64,6 +64,7 @@ import { CloudService } from "@roo-code/cloud" import { ApiHandler, ApiHandlerCreateMessageMetadata, buildApiHandler } from "../../api" import { ApiStream, GroundingSource } from "../../api/transform/stream" import { maybeRemoveImageBlocks } from "../../api/transform/image-cleaning" +import { OutputTokenLimitError } from "../../api/providers/utils/output-token-limit-error" // shared import { findLastIndex } from "../../shared/array" @@ -3717,6 +3718,22 @@ export class Task extends EventEmitter implements TaskLike { // User cancelled - abort the entire task this.abortReason = cancelReason await this.abortTask() + } else if (error instanceof OutputTokenLimitError) { + // Truncation repeats on an identical request, so never auto-retry it + // (even with auto-approval); let the user decide once. + const { response } = await this.ask("api_req_failed", rawErrorMessage) + + if (response !== "yesButtonClicked") { + throw new Error("API request failed") + } + + await this.say("api_req_retried") + stack.push({ + userContent: currentUserContent, + includeFileDetails: false, + retryAttempt: 0, + }) + continue } else { // Stream failed - log the error and retry with the same content // The existing rate limiting will prevent rapid retries diff --git a/src/core/task/__tests__/Task.spec.ts b/src/core/task/__tests__/Task.spec.ts index c35acf864d..99fe9aba19 100644 --- a/src/core/task/__tests__/Task.spec.ts +++ b/src/core/task/__tests__/Task.spec.ts @@ -25,6 +25,7 @@ import { summarizeConversation } from "../../condense" import { getEnvironmentDetails } from "../../environment/getEnvironmentDetails" import { ClineProvider } from "../../webview/ClineProvider" import { ApiStreamChunk } from "../../../api/transform/stream" +import { OutputTokenLimitError } from "../../../api/providers/utils/output-token-limit-error" import { ContextProxy } from "../../config/ContextProxy" import { processUserContentMentions } from "../../mentions/processUserContentMentions" import { MultiSearchReplaceDiffStrategy } from "../../diff/strategies/multi-search-replace" @@ -45,6 +46,7 @@ type TaskTestAccess = { updateClineMessage: (message: import("@roo-code/types").ClineMessage) => Promise saveClineMessages: () => Promise safeEnsureModelFetched: () => Promise + backoffAndAnnounce: (retryAttempt: number, error: unknown) => Promise getFilesReadByRooSafely: (context: string) => Promise addToApiConversationHistory: (message: unknown, reasoning?: string) => Promise resetAssistantMessagePersistence: () => void @@ -517,6 +519,60 @@ describe("Cline", () => { }) }) + describe("output token limit mid-stream", () => { + async function* truncatedStream(): AsyncGenerator { + yield { type: "text", text: "partial answer" } + throw new OutputTokenLimitError() + } + + async function createAutoApprovedTask() { + vi.spyOn(mockProvider, "getState").mockResolvedValue( + providerStateWith({ autoApprovalEnabled: true, requestDelaySeconds: 0 }), + ) + const task = new Task({ + provider: mockProvider, + apiConfiguration: mockApiConfig, + task: "test task", + startTask: false, + }) + vi.spyOn(task.diffViewProvider, "reset").mockResolvedValue(undefined) + vi.spyOn(getTaskTestAccess(task), "safeEnsureModelFetched").mockResolvedValue(stubModelInfo) + vi.spyOn(getTaskTestAccess(task), "presentAssistantMessageSafe").mockImplementation(() => {}) + return task + } + + it("asks once instead of auto-retrying, even with auto-approval", async () => { + const task = await createAutoApprovedTask() + const askSpy = vi + .spyOn(task, "ask") + .mockResolvedValue({ response: "noButtonClicked" } satisfies TaskAskResult) + const backoffSpy = vi.spyOn(getTaskTestAccess(task), "backoffAndAnnounce") + const attemptApiRequestSpy = vi.spyOn(task, "attemptApiRequest").mockImplementation(() => truncatedStream()) + + await task.recursivelyMakeClineRequests([{ type: "text", text: "long request" }]) + + expect(attemptApiRequestSpy).toHaveBeenCalledOnce() + expect(backoffSpy).not.toHaveBeenCalled() + expect(askSpy).toHaveBeenCalledWith("api_req_failed", expect.stringContaining("Output token limit reached")) + }) + + it("retries from a fresh attempt count when the user confirms", async () => { + const task = await createAutoApprovedTask() + vi.spyOn(task, "ask").mockResolvedValue({ response: "yesButtonClicked" } satisfies TaskAskResult) + const attemptApiRequestSpy = vi + .spyOn(task, "attemptApiRequest") + .mockImplementationOnce(() => truncatedStream()) + .mockImplementationOnce(() => asyncStreamFrom([{ type: "text", text: "done" }])) + .mockImplementation(() => { + throw new Error("stop after retry response") + }) + + await task.recursivelyMakeClineRequests([{ type: "text", text: "long request" }]) + + expect(attemptApiRequestSpy.mock.calls.slice(0, 2).map(([retryAttempt]) => retryAttempt)).toEqual([0, 0]) + }) + }) + describe("native tool-call request isolation", () => { it("keeps overlapping Task parser state scoped to each request", async () => { const firstTask = new Task({ diff --git a/src/eslint-suppressions.json b/src/eslint-suppressions.json index 3f71416a12..938af957f8 100644 --- a/src/eslint-suppressions.json +++ b/src/eslint-suppressions.json @@ -136,7 +136,7 @@ }, "api/providers/__tests__/bedrock.spec.ts": { "@typescript-eslint/no-explicit-any": { - "count": 38 + "count": 37 } }, "api/providers/__tests__/deepseek.spec.ts": { diff --git a/src/shared/__tests__/api.spec.ts b/src/shared/__tests__/api.spec.ts index 0f8b16f6cf..8f405a38e6 100644 --- a/src/shared/__tests__/api.spec.ts +++ b/src/shared/__tests__/api.spec.ts @@ -81,6 +81,30 @@ describe("getModelMaxOutputTokens", () => { expect(result).toBe(ANTHROPIC_DEFAULT_MAX_TOKENS) // Should be 8192, not 64_000 }) + test.each([ + [32_000, 32_000], + [160_000, 128_000], + [undefined, ANTHROPIC_DEFAULT_MAX_TOKENS], + [0, ANTHROPIC_DEFAULT_MAX_TOKENS], + [-1, ANTHROPIC_DEFAULT_MAX_TOKENS], + ])("handles hybrid output override %s without reasoning", (modelMaxTokens, expected) => { + const model: ModelInfo = { + contextWindow: 1_000_000, + maxTokens: 128_000, + supportsPromptCache: true, + supportsReasoningBudget: true, + supportsMaxTokens: true, + } + + expect( + getModelMaxOutputTokens({ + modelId: "anthropic.claude-sonnet-5", + model, + settings: { enableReasoningEffort: false, modelMaxTokens }, + }), + ).toBe(expected) + }) + test("should preserve Anthropic hybrid token handling when a model also supports binary reasoning", () => { const model: ModelInfo = { contextWindow: 1_000_000, diff --git a/src/shared/api.ts b/src/shared/api.ts index d301ee68b9..a48844dff6 100644 --- a/src/shared/api.ts +++ b/src/shared/api.ts @@ -125,6 +125,9 @@ export const getModelMaxOutputTokens = ({ // For "Hybrid" reasoning models, discard the model's actual maxTokens for Anthropic contexts if (model.supportsReasoningBudget && isAnthropicContext) { + if (model.supportsMaxTokens && settings?.modelMaxTokens != null && settings.modelMaxTokens > 0) { + return model.maxTokens ? Math.min(settings.modelMaxTokens, model.maxTokens) : settings.modelMaxTokens + } return ANTHROPIC_DEFAULT_MAX_TOKENS } diff --git a/webview-ui/playwright/gallery/stories.tsx b/webview-ui/playwright/gallery/stories.tsx index 04ca36b2c6..7b42e9780d 100644 --- a/webview-ui/playwright/gallery/stories.tsx +++ b/webview-ui/playwright/gallery/stories.tsx @@ -12,6 +12,38 @@ const mermaidGantt = `gantt Ship release :active, release, after scope, 3d` export const stories: Record = { + "bedrock-output-budget": async ({ model = "anthropic.claude-opus-5" }) => { + const [{ AppProviders }, { ThinkingBudget }, { bedrockModels, providerIdentifiers }] = await Promise.all([ + import("../AppProviders"), + import("@/components/settings/ThinkingBudget"), + import("@roo-code/types"), + ]) + const apiModelId = model === "anthropic.claude-opus-4-8" ? model : "anthropic.claude-opus-5" + function Budget() { + const [config, setConfig] = useState({ + apiProvider: providerIdentifiers.bedrock, + apiModelId, + enableReasoningEffort: true, + }) + return ( +
+

{apiModelId}

+ + setConfig((previous) => ({ ...previous, [field]: value })) + } + /> +
+ ) + } + return ( + + + + ) + }, "accessibility-contrast": async () => { const { AccessibilityContrastGallery } = await import("@/components/ui/__tests__/AccessibilityContrast.visual.fixture") diff --git a/webview-ui/src/components/settings/ThinkingBudget.tsx b/webview-ui/src/components/settings/ThinkingBudget.tsx index eb1cbbb86a..302b449870 100644 --- a/webview-ui/src/components/settings/ThinkingBudget.tsx +++ b/webview-ui/src/components/settings/ThinkingBudget.tsx @@ -74,7 +74,8 @@ export const ThinkingBudget = ({ apiConfiguration, setApiConfigurationField, mod // Models that advertise a user-configurable max output budget (e.g. Z.ai GLM) but do not // use the reasoning-budget slider. The reasoning-budget branch already renders its own // max-tokens control, so only surface this standalone slider when that branch is inactive. - const isMaxTokensConfigurable = !!modelInfo && modelInfo.supportsMaxTokens && !isReasoningBudgetSupported + const isMaxTokensConfigurable = + !!modelInfo && modelInfo.supportsMaxTokens && (isReasoningSupported || !isReasoningBudgetSupported) // "disable" turns off reasoning entirely; "none" is a valid reasoning level. // Both display as "None" in the UI but behave differently. diff --git a/webview-ui/src/components/settings/__tests__/ThinkingBudget.spec.tsx b/webview-ui/src/components/settings/__tests__/ThinkingBudget.spec.tsx index 0fc8f9e123..30a7927468 100644 --- a/webview-ui/src/components/settings/__tests__/ThinkingBudget.spec.tsx +++ b/webview-ui/src/components/settings/__tests__/ThinkingBudget.spec.tsx @@ -1,4 +1,4 @@ -import { providerIdentifiers } from "@roo-code/types" +import { bedrockModels, providerIdentifiers } from "@roo-code/types" // npx vitest src/components/settings/__tests__/ThinkingBudget.spec.tsx import React from "react" @@ -79,6 +79,26 @@ describe("ThinkingBudget", () => { vi.clearAllMocks() }) + it.each([ + ["anthropic.claude-sonnet-4-5-20250929-v1:0", 64_000], + ["anthropic.claude-opus-4-8", 128_000], + ["anthropic.claude-sonnet-5", 128_000], + ["anthropic.claude-opus-5", 128_000], + ] as const)("allows selecting the documented Bedrock output ceiling for %s", (apiModelId, ceiling) => { + render( + , + ) + const outputSlider = screen.getAllByTestId("slider")[0] + expect(outputSlider).toHaveAttribute("max", String(ceiling)) + expect(outputSlider).toHaveValue("16384") + fireEvent.change(outputSlider, { target: { value: String(ceiling) } }) + expect(defaultProps.setApiConfigurationField).toHaveBeenCalledWith("modelMaxTokens", ceiling) + }) + it("should render nothing when model information is unavailable", () => { const { container } = render() diff --git a/webview-ui/src/components/settings/__tests__/ThinkingBudget.visual.tsx b/webview-ui/src/components/settings/__tests__/ThinkingBudget.visual.tsx new file mode 100644 index 0000000000..f9719aa55a --- /dev/null +++ b/webview-ui/src/components/settings/__tests__/ThinkingBudget.visual.tsx @@ -0,0 +1,8 @@ +import { expect, test } from "../../../../playwright/coverage-fixture" + +test("renders the Bedrock binary-reasoning output budget control", async ({ page }) => { + await page.goto("/") + await page.waitForFunction(() => typeof window.mount === "function") + await page.evaluate(() => window.mount({ story: "bedrock-output-budget" })) + await expect(page.locator("[data-playwright-mounted]")).toHaveScreenshot("bedrock-output-budget.png") +}) diff --git a/webview-ui/src/components/settings/__tests__/__screenshots__/bedrock-output-budget.png b/webview-ui/src/components/settings/__tests__/__screenshots__/bedrock-output-budget.png new file mode 100644 index 0000000000..701bacb215 Binary files /dev/null and b/webview-ui/src/components/settings/__tests__/__screenshots__/bedrock-output-budget.png differ