diff --git a/.changeset/tasty-grapes-suffer.md b/.changeset/tasty-grapes-suffer.md new file mode 100644 index 0000000000..7382b38c77 --- /dev/null +++ b/.changeset/tasty-grapes-suffer.md @@ -0,0 +1,5 @@ +--- +"roo-cline": patch +--- + +Fix maxTokens defaults for Claude 3.7 Sonnet models diff --git a/src/api/providers/openrouter.ts b/src/api/providers/openrouter.ts index 82c02e20a7..70c40c2c27 100644 --- a/src/api/providers/openrouter.ts +++ b/src/api/providers/openrouter.ts @@ -278,7 +278,7 @@ export async function getOpenRouterModels() { modelInfo.supportsPromptCache = true modelInfo.cacheWritesPrice = 3.75 modelInfo.cacheReadsPrice = 0.3 - modelInfo.maxTokens = 64_000 + modelInfo.maxTokens = rawModel.id === "anthropic/claude-3.7-sonnet:thinking" ? 64_000 : 16_384 break case rawModel.id.startsWith("anthropic/claude-3.5-sonnet-20240620"): modelInfo.supportsPromptCache = true diff --git a/src/shared/api.ts b/src/shared/api.ts index f88bb5e8b5..99e2986e88 100644 --- a/src/shared/api.ts +++ b/src/shared/api.ts @@ -111,7 +111,7 @@ export const anthropicModels = { thinking: true, }, "claude-3-7-sonnet-20250219": { - maxTokens: 64_000, + maxTokens: 16_384, contextWindow: 200_000, supportsImages: true, supportsComputerUse: true, @@ -437,7 +437,7 @@ export type VertexModelId = keyof typeof vertexModels export const vertexDefaultModelId: VertexModelId = "claude-3-7-sonnet@20250219" export const vertexModels = { "claude-3-7-sonnet@20250219:thinking": { - maxTokens: 64000, + maxTokens: 64_000, contextWindow: 200_000, supportsImages: true, supportsComputerUse: true, @@ -449,7 +449,7 @@ export const vertexModels = { thinking: true, }, "claude-3-7-sonnet@20250219": { - maxTokens: 8192, + maxTokens: 16_384, contextWindow: 200_000, supportsImages: true, supportsComputerUse: true, diff --git a/webview-ui/src/components/settings/ApiOptions.tsx b/webview-ui/src/components/settings/ApiOptions.tsx index 42ac5cdcb3..6f0dba9f00 100644 --- a/webview-ui/src/components/settings/ApiOptions.tsx +++ b/webview-ui/src/components/settings/ApiOptions.tsx @@ -7,7 +7,6 @@ import * as vscodemodels from "vscode" import { ApiConfiguration, ModelInfo, - ApiProvider, anthropicDefaultModelId, anthropicModels, azureOpenAiDefaultApiVersion, @@ -1385,7 +1384,6 @@ const ApiOptions = ({ apiConfiguration={apiConfiguration} setApiConfigurationField={setApiConfigurationField} modelInfo={selectedModelInfo} - provider={selectedProvider as ApiProvider} /> (field: K, value: ApiConfiguration[K]) => void modelInfo?: ModelInfo - provider?: ApiProvider } -export const ThinkingBudget = ({ - apiConfiguration, - setApiConfigurationField, - modelInfo, - provider, -}: ThinkingBudgetProps) => { - const tokens = apiConfiguration?.modelMaxTokens || modelInfo?.maxTokens || 64_000 +export const ThinkingBudget = ({ apiConfiguration, setApiConfigurationField, modelInfo }: ThinkingBudgetProps) => { + const tokens = apiConfiguration?.modelMaxTokens || 16_384 const tokensMin = 8192 const tokensMax = modelInfo?.maxTokens || 64_000 diff --git a/webview-ui/src/components/settings/__tests__/ApiOptions.test.tsx b/webview-ui/src/components/settings/__tests__/ApiOptions.test.tsx index 06ed95585a..0b1fb28498 100644 --- a/webview-ui/src/components/settings/__tests__/ApiOptions.test.tsx +++ b/webview-ui/src/components/settings/__tests__/ApiOptions.test.tsx @@ -92,7 +92,6 @@ describe("ApiOptions", () => { }) expect(screen.getByTestId("thinking-budget")).toBeInTheDocument() - expect(screen.getByTestId("thinking-budget")).toHaveAttribute("data-provider", "anthropic") }) it("should show ThinkingBudget for Vertex models that support thinking", () => { @@ -104,7 +103,6 @@ describe("ApiOptions", () => { }) expect(screen.getByTestId("thinking-budget")).toBeInTheDocument() - expect(screen.getByTestId("thinking-budget")).toHaveAttribute("data-provider", "vertex") }) it("should not show ThinkingBudget for models that don't support thinking", () => { diff --git a/webview-ui/src/components/settings/__tests__/ThinkingBudget.test.tsx b/webview-ui/src/components/settings/__tests__/ThinkingBudget.test.tsx index 212316ea9a..1e14e94524 100644 --- a/webview-ui/src/components/settings/__tests__/ThinkingBudget.test.tsx +++ b/webview-ui/src/components/settings/__tests__/ThinkingBudget.test.tsx @@ -1,7 +1,6 @@ -import React from "react" import { render, screen, fireEvent } from "@testing-library/react" import { ThinkingBudget } from "../ThinkingBudget" -import { ApiProvider, ModelInfo } from "../../../../../src/shared/api" +import { ModelInfo } from "../../../../../src/shared/api" // Mock Slider component jest.mock("@/components/ui", () => ({ @@ -25,11 +24,11 @@ describe("ThinkingBudget", () => { supportsPromptCache: true, supportsImages: true, } + const defaultProps = { apiConfiguration: {}, setApiConfigurationField: jest.fn(), modelInfo: mockModelInfo, - provider: "anthropic" as ApiProvider, } beforeEach(() => { @@ -60,7 +59,7 @@ describe("ThinkingBudget", () => { expect(screen.getAllByTestId("slider")).toHaveLength(2) }) - it("should use modelMaxThinkingTokens field for Anthropic provider", () => { + it("should update modelMaxThinkingTokens", () => { const setApiConfigurationField = jest.fn() render( @@ -68,25 +67,6 @@ describe("ThinkingBudget", () => { {...defaultProps} apiConfiguration={{ modelMaxThinkingTokens: 4096 }} setApiConfigurationField={setApiConfigurationField} - provider="anthropic" - />, - ) - - const sliders = screen.getAllByTestId("slider") - fireEvent.change(sliders[1], { target: { value: "5000" } }) - - expect(setApiConfigurationField).toHaveBeenCalledWith("modelMaxThinkingTokens", 5000) - }) - - it("should use modelMaxThinkingTokens field for Vertex provider", () => { - const setApiConfigurationField = jest.fn() - - render( - , )