Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

Commit 020cd61

Browse files
committed
feat(vertex): add 1M context window beta support for Claude Sonnet 4
1 parent 3c05cae commit 020cd61

21 files changed

Lines changed: 65 additions & 1 deletion

File tree

packages/types/src/provider-settings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ const vertexSchema = apiModelIdProviderModelSchema.extend({
237237
vertexRegion: z.string().optional(),
238238
enableUrlContext: z.boolean().optional(),
239239
enableGrounding: z.boolean().optional(),
240+
vertex1MContext: z.boolean().optional(), // Enable 'context-1m-2025-08-07' beta for 1M context window.
240241
})
241242

242243
const openAiSchema = baseProviderSettingsSchema.extend({

packages/types/src/providers/vertex.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,10 @@ export const vertexModels = {
517517
},
518518
} as const satisfies Record<string, ModelInfo>
519519

520+
// Vertex AI models that support 1M context window beta
521+
// Uses the same beta header 'context-1m-2025-08-07' as Anthropic and Bedrock
522+
export const VERTEX_1M_CONTEXT_MODEL_IDS = ["claude-sonnet-4@20250514", "claude-sonnet-4-5@20250929"] as const
523+
520524
export const VERTEX_REGIONS = [
521525
{ value: "global", label: "global" },
522526
{ value: "us-central1", label: "us-central1" },

webview-ui/src/components/settings/providers/Vertex.tsx

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useCallback } from "react"
22
import { Checkbox } from "vscrui"
33
import { VSCodeLink, VSCodeTextField } from "@vscode/webview-ui-toolkit/react"
44

5-
import { type ProviderSettings, VERTEX_REGIONS } from "@roo-code/types"
5+
import { type ProviderSettings, VERTEX_REGIONS, VERTEX_1M_CONTEXT_MODEL_IDS } from "@roo-code/types"
66

77
import { useAppTranslation } from "@src/i18n/TranslationContext"
88
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@src/components/ui"
@@ -18,6 +18,13 @@ type VertexProps = {
1818
export const Vertex = ({ apiConfiguration, setApiConfigurationField, simplifySettings }: VertexProps) => {
1919
const { t } = useAppTranslation()
2020

21+
// Check if the selected model supports 1M context (Claude Sonnet 4 / 4.5)
22+
const supports1MContextBeta =
23+
!!apiConfiguration?.apiModelId &&
24+
VERTEX_1M_CONTEXT_MODEL_IDS.includes(
25+
apiConfiguration.apiModelId as (typeof VERTEX_1M_CONTEXT_MODEL_IDS)[number],
26+
)
27+
2128
const handleInputChange = useCallback(
2229
<K extends keyof ProviderSettings, E>(
2330
field: K,
@@ -94,6 +101,22 @@ export const Vertex = ({ apiConfiguration, setApiConfigurationField, simplifySet
94101
</Select>
95102
</div>
96103

104+
{supports1MContextBeta && (
105+
<div>
106+
<Checkbox
107+
data-testid="checkbox-vertex-1m-context"
108+
checked={apiConfiguration?.vertex1MContext ?? false}
109+
onChange={(checked: boolean) => {
110+
setApiConfigurationField("vertex1MContext", checked)
111+
}}>
112+
{t("settings:providers.vertex1MContextBetaLabel")}
113+
</Checkbox>
114+
<div className="text-sm text-vscode-descriptionForeground mt-1 ml-6">
115+
{t("settings:providers.vertex1MContextBetaDescription")}
116+
</div>
117+
</div>
118+
)}
119+
97120
{!simplifySettings && apiConfiguration.apiModelId?.startsWith("gemini") && (
98121
<div className="mt-6">
99122
<Checkbox

webview-ui/src/i18n/locales/ca/settings.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/de/settings.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/en/settings.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,8 @@
310310
"anthropic1MContextBetaDescription": "Extends context window to 1 million tokens for Claude Sonnet 4",
311311
"awsBedrock1MContextBetaLabel": "Enable 1M context window (Beta)",
312312
"awsBedrock1MContextBetaDescription": "Extends context window to 1 million tokens for Claude Sonnet 4",
313+
"vertex1MContextBetaLabel": "Enable 1M context window (Beta)",
314+
"vertex1MContextBetaDescription": "Extends context window to 1 million tokens for Claude Sonnet 4",
313315
"basetenApiKey": "Baseten API Key",
314316
"getBasetenApiKey": "Get Baseten API Key",
315317
"cerebrasApiKey": "Cerebras API Key",

webview-ui/src/i18n/locales/es/settings.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/fr/settings.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/hi/settings.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/id/settings.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)