Skip to content

Commit 390932e

Browse files
authored
Merge pull request RooCodeInc#1262 from RooVetGit/cte/lower-default-max-tokens
Fix maxTokens defaults for Claude 3.7 Sonnet models
2 parents 7d60cc6 + 31d2d17 commit 390932e

File tree

7 files changed

+15
-40
lines changed

7 files changed

+15
-40
lines changed

.changeset/tasty-grapes-suffer.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"roo-cline": patch
3+
---
4+
5+
Fix maxTokens defaults for Claude 3.7 Sonnet models

src/api/providers/openrouter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ export async function getOpenRouterModels() {
278278
modelInfo.supportsPromptCache = true
279279
modelInfo.cacheWritesPrice = 3.75
280280
modelInfo.cacheReadsPrice = 0.3
281-
modelInfo.maxTokens = 64_000
281+
modelInfo.maxTokens = rawModel.id === "anthropic/claude-3.7-sonnet:thinking" ? 64_000 : 16_384
282282
break
283283
case rawModel.id.startsWith("anthropic/claude-3.5-sonnet-20240620"):
284284
modelInfo.supportsPromptCache = true

src/shared/api.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export const anthropicModels = {
111111
thinking: true,
112112
},
113113
"claude-3-7-sonnet-20250219": {
114-
maxTokens: 64_000,
114+
maxTokens: 16_384,
115115
contextWindow: 200_000,
116116
supportsImages: true,
117117
supportsComputerUse: true,
@@ -437,7 +437,7 @@ export type VertexModelId = keyof typeof vertexModels
437437
export const vertexDefaultModelId: VertexModelId = "claude-3-7-sonnet@20250219"
438438
export const vertexModels = {
439439
"claude-3-7-sonnet@20250219:thinking": {
440-
maxTokens: 64000,
440+
maxTokens: 64_000,
441441
contextWindow: 200_000,
442442
supportsImages: true,
443443
supportsComputerUse: true,
@@ -449,7 +449,7 @@ export const vertexModels = {
449449
thinking: true,
450450
},
451451
"claude-3-7-sonnet@20250219": {
452-
maxTokens: 8192,
452+
maxTokens: 16_384,
453453
contextWindow: 200_000,
454454
supportsImages: true,
455455
supportsComputerUse: true,

webview-ui/src/components/settings/ApiOptions.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import * as vscodemodels from "vscode"
77
import {
88
ApiConfiguration,
99
ModelInfo,
10-
ApiProvider,
1110
anthropicDefaultModelId,
1211
anthropicModels,
1312
azureOpenAiDefaultApiVersion,
@@ -1385,7 +1384,6 @@ const ApiOptions = ({
13851384
apiConfiguration={apiConfiguration}
13861385
setApiConfigurationField={setApiConfigurationField}
13871386
modelInfo={selectedModelInfo}
1388-
provider={selectedProvider as ApiProvider}
13891387
/>
13901388
<ModelInfoView
13911389
selectedModelId={selectedModelId}

webview-ui/src/components/settings/ThinkingBudget.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useEffect, useMemo } from "react"
2-
import { ApiProvider } from "../../../../src/shared/api"
2+
33
import { Slider } from "@/components/ui"
44

55
import { ApiConfiguration, ModelInfo } from "../../../../src/shared/api"
@@ -8,16 +8,10 @@ interface ThinkingBudgetProps {
88
apiConfiguration: ApiConfiguration
99
setApiConfigurationField: <K extends keyof ApiConfiguration>(field: K, value: ApiConfiguration[K]) => void
1010
modelInfo?: ModelInfo
11-
provider?: ApiProvider
1211
}
1312

14-
export const ThinkingBudget = ({
15-
apiConfiguration,
16-
setApiConfigurationField,
17-
modelInfo,
18-
provider,
19-
}: ThinkingBudgetProps) => {
20-
const tokens = apiConfiguration?.modelMaxTokens || modelInfo?.maxTokens || 64_000
13+
export const ThinkingBudget = ({ apiConfiguration, setApiConfigurationField, modelInfo }: ThinkingBudgetProps) => {
14+
const tokens = apiConfiguration?.modelMaxTokens || 16_384
2115
const tokensMin = 8192
2216
const tokensMax = modelInfo?.maxTokens || 64_000
2317

webview-ui/src/components/settings/__tests__/ApiOptions.test.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ describe("ApiOptions", () => {
9292
})
9393

9494
expect(screen.getByTestId("thinking-budget")).toBeInTheDocument()
95-
expect(screen.getByTestId("thinking-budget")).toHaveAttribute("data-provider", "anthropic")
9695
})
9796

9897
it("should show ThinkingBudget for Vertex models that support thinking", () => {
@@ -104,7 +103,6 @@ describe("ApiOptions", () => {
104103
})
105104

106105
expect(screen.getByTestId("thinking-budget")).toBeInTheDocument()
107-
expect(screen.getByTestId("thinking-budget")).toHaveAttribute("data-provider", "vertex")
108106
})
109107

110108
it("should not show ThinkingBudget for models that don't support thinking", () => {

webview-ui/src/components/settings/__tests__/ThinkingBudget.test.tsx

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import React from "react"
21
import { render, screen, fireEvent } from "@testing-library/react"
32
import { ThinkingBudget } from "../ThinkingBudget"
4-
import { ApiProvider, ModelInfo } from "../../../../../src/shared/api"
3+
import { ModelInfo } from "../../../../../src/shared/api"
54

65
// Mock Slider component
76
jest.mock("@/components/ui", () => ({
@@ -25,11 +24,11 @@ describe("ThinkingBudget", () => {
2524
supportsPromptCache: true,
2625
supportsImages: true,
2726
}
27+
2828
const defaultProps = {
2929
apiConfiguration: {},
3030
setApiConfigurationField: jest.fn(),
3131
modelInfo: mockModelInfo,
32-
provider: "anthropic" as ApiProvider,
3332
}
3433

3534
beforeEach(() => {
@@ -60,33 +59,14 @@ describe("ThinkingBudget", () => {
6059
expect(screen.getAllByTestId("slider")).toHaveLength(2)
6160
})
6261

63-
it("should use modelMaxThinkingTokens field for Anthropic provider", () => {
64-
const setApiConfigurationField = jest.fn()
65-
66-
render(
67-
<ThinkingBudget
68-
{...defaultProps}
69-
apiConfiguration={{ modelMaxThinkingTokens: 4096 }}
70-
setApiConfigurationField={setApiConfigurationField}
71-
provider="anthropic"
72-
/>,
73-
)
74-
75-
const sliders = screen.getAllByTestId("slider")
76-
fireEvent.change(sliders[1], { target: { value: "5000" } })
77-
78-
expect(setApiConfigurationField).toHaveBeenCalledWith("modelMaxThinkingTokens", 5000)
79-
})
80-
81-
it("should use modelMaxThinkingTokens field for Vertex provider", () => {
62+
it("should update modelMaxThinkingTokens", () => {
8263
const setApiConfigurationField = jest.fn()
8364

8465
render(
8566
<ThinkingBudget
8667
{...defaultProps}
8768
apiConfiguration={{ modelMaxThinkingTokens: 4096 }}
8869
setApiConfigurationField={setApiConfigurationField}
89-
provider="vertex"
9070
/>,
9171
)
9272

0 commit comments

Comments
 (0)