fix(vertex): normalize Claude Opus 4.6 legacy model-id aliases#5969
Conversation
🦋 Changeset detectedLatest commit: e688abc The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Pull request overview
Normalizes the Vertex AI model id used for Claude Opus 4.6 so legacy saved aliases don’t produce invalid Vertex model names (avoiding 404s) while keeping backward compatibility across runtime and UI selection.
Changes:
- Switch Vertex catalog entry for Opus 4.6 to the canonical
claude-opus-4-6. - Add
normalizeVertexModelId()in@roo-code/typesand apply it in Vertex runtime handlers and webview model selection. - Add regression tests across
packages/types, extension provider handlers, and the webview UI hook.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| webview-ui/src/components/ui/hooks/useSelectedModel.ts | Normalizes Vertex model ids before lookup/selection. |
| webview-ui/src/components/ui/hooks/tests/useSelectedModel.spec.ts | Adds UI regression test for legacy Vertex alias normalization. |
| src/api/providers/vertex.ts | Normalizes Vertex model id in handler model resolution. |
| src/api/providers/anthropic-vertex.ts | Normalizes Vertex model id in Anthropic-on-Vertex handler model resolution. |
| src/api/providers/tests/vertex.spec.ts | Adds regression test for VertexHandler legacy alias normalization. |
| src/api/providers/tests/anthropic-vertex.spec.ts | Adds regression test for AnthropicVertexHandler legacy alias normalization. |
| packages/types/src/providers/vertex.ts | Updates canonical model key and adds normalizeVertexModelId() helper. |
| packages/types/src/providers/tests/vertex.spec.ts | Adds unit tests for normalizeVertexModelId(). |
| getModel() { | ||
| const modelId = this.options.apiModelId | ||
| let id = modelId && modelId in vertexModels ? (modelId as VertexModelId) : vertexDefaultModelId | ||
| let id: VertexModelId = modelId ? normalizeVertexModelId(modelId) : normalizeVertexModelId("") | ||
| let info: ModelInfo = vertexModels[id] |
There was a problem hiding this comment.
The changes in getModel() (using normalizeVertexModelId) aren’t marked with kilocode_change comments. Please annotate the modified lines so this fork-specific behavior is easy to identify/merge against upstream later.
| @@ -0,0 +1,16 @@ | |||
| import { normalizeVertexModelId } from "../vertex.js" | |||
There was a problem hiding this comment.
New file is missing the required // kilocode_change - new file header comment. Please add it at the top so the fork’s changes remain easy to track during upstream merges.
| /** | ||
| * Normalize legacy Vertex model IDs to canonical IDs. | ||
| * | ||
| * Legacy aliases are kept here to support existing saved settings while ensuring | ||
| * API requests use valid Vertex model names. | ||
| */ | ||
| export function normalizeVertexModelId(modelId: string): VertexModelId { | ||
| const normalized = modelId.trim() | ||
|
|
||
| // Use Object.hasOwn() instead of 'in' to avoid inherited properties. | ||
| if (Object.hasOwn(vertexModels, normalized)) { | ||
| return normalized as VertexModelId | ||
| } | ||
|
|
||
| switch (normalized.toLowerCase()) { | ||
| case "claude-opus-4-6@default": | ||
| case "claude-opus-4-6@vertex": | ||
| return "claude-opus-4-6" | ||
| default: | ||
| return vertexDefaultModelId | ||
| } | ||
| } |
There was a problem hiding this comment.
The newly added normalizeVertexModelId block isn’t marked with kilocode_change comments. Please wrap this new block with // kilocode_change start / // kilocode_change end (or annotate the modified lines) to follow the repo’s merge-tracking convention.
| openAiModelInfoSaneDefaults, | ||
| openAiNativeModels, | ||
| vertexModels, | ||
| normalizeVertexModelId, |
There was a problem hiding this comment.
The added normalizeVertexModelId import isn’t annotated with kilocode_change, even though this file uses that convention elsewhere. Please add the appropriate kilocode_change marker for this added import to keep merge tracking consistent.
| normalizeVertexModelId, | |
| normalizeVertexModelId, // kilocode_change |
| case "vertex": { | ||
| const id = apiConfiguration.apiModelId ?? defaultModelId | ||
| const rawId = apiConfiguration.apiModelId ?? defaultModelId | ||
| const id = normalizeVertexModelId(rawId) | ||
| const info = vertexModels[id as keyof typeof vertexModels] | ||
| return { id, info } |
There was a problem hiding this comment.
The Vertex model-id normalization logic added in this vertex provider case isn’t marked with a kilocode_change comment. Please annotate the changed lines (or wrap the case block) to match the established change-marking convention used throughout this file.
| override getModel() { | ||
| const modelId = this.options.apiModelId | ||
| let id = modelId && modelId in vertexModels ? (modelId as VertexModelId) : vertexDefaultModelId | ||
| let id: VertexModelId = modelId ? normalizeVertexModelId(modelId) : normalizeVertexModelId("") | ||
| const info: ModelInfo = vertexModels[id] | ||
| const params = getModelParams({ format: "gemini", modelId: id, model: info, settings: this.options }) |
There was a problem hiding this comment.
The changes in getModel() (using normalizeVertexModelId) aren’t marked with kilocode_change comments. Please annotate the modified lines so this fork-specific behavior is easy to identify/merge against upstream later.
|
Rebased onto latest
This PR should now be conflict-free and ready for review. |
| apiModelId: "gemini-3.1-pro-preview", | ||
| vertexProjectId: "test-project", | ||
| vertexRegion: "us-central1", | ||
| it("should normalize legacy claude-opus-4-6 aliases", () => { |
There was a problem hiding this comment.
WARNING: Indentation inconsistency — this test and the block below (lines 153–178) are indented with 3 tabs, but the sibling test "should return correct model info for Gemini" at line 137 uses 2 tabs. The extra indentation level makes the nesting appear deeper than it actually is.
Please re-indent lines 153–178 to use 2-tab indentation to match the surrounding describe("getModel") block.
| expect(modelInfo.info.contextWindow).toBe(200_000) | ||
| }) | ||
|
|
||
| it("should normalize legacy claude-opus-4-6 aliases", () => { |
There was a problem hiding this comment.
WARNING: Missing kilocode_change marker — this new test is a Kilo Code-specific addition to a shared upstream file in src/. Per AGENTS.md, it should be wrapped with // kilocode_change start / // kilocode_change end markers to minimize merge conflicts during upstream syncs.
Code Review SummaryStatus: 11 Issues Found | Recommendation: Address before merge Fix these issues in Kilo Cloud Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (8 files)
|
|
Addressed the latest kiloconnect review items in commit
Please re-run review/CI. |
| expect(modelInfo.info.contextWindow).toBe(1048576) | ||
| }) | ||
|
|
||
| it("should normalize legacy claude-opus-4-6 aliases", () => { |
There was a problem hiding this comment.
WARNING: Missing kilocode_change marker — this new test modifies a file that exists in upstream Roo Code (src/), so it needs kilocode_change markers to minimize merge conflicts during upstream syncs. The equivalent test in anthropic-vertex.spec.ts correctly includes the markers.
| it("should normalize legacy claude-opus-4-6 aliases", () => { | |
| // kilocode_change start | |
| it("should normalize legacy claude-opus-4-6 aliases", () => { |
| }) | ||
| }) | ||
|
|
||
| describe("vertex provider", () => { |
There was a problem hiding this comment.
WARNING: Missing kilocode_change marker — this new test block modifies a file in webview-ui/, which requires kilocode_change markers per project conventions.
| describe("vertex provider", () => { | |
| // kilocode_change start | |
| describe("vertex provider", () => { |
Also add a // kilocode_change end comment after the closing }) of this describe block (after line 830).
|
Addressed the latest kiloconnect marker/style warnings in commit
Please re-run review. |
| return normalized as VertexModelId | ||
| } | ||
|
|
||
| switch (normalized.toLowerCase()) { |
There was a problem hiding this comment.
SUGGESTION: Inconsistent case handling — Object.hasOwn() on line 609 is case-sensitive, but the switch here uses .toLowerCase(). If a canonical model ID were ever passed with unexpected casing (e.g. "Claude-Opus-4-6"), it would skip the Object.hasOwn check, miss all switch cases (since "claude-opus-4-6" isn't listed as a legacy alias), and silently fall through to vertexDefaultModelId.
In practice this is unlikely since model IDs are always lowercase, but for defensive consistency consider also lowercasing the Object.hasOwn lookup, or adding a comment explaining the intentional asymmetry.
Summary
ormalizeVertexModelId in types to map legacy aliases (claude-opus-4-6@default, claude-opus-4-6@vertex) to the canonical ID
Why
Some saved Vertex configurations use a legacy alias for Opus 4.6, which can lead to invalid API model names and request failures. This keeps backward compatibility while always sending valid model IDs.
Fixes #5772