Skip to content

fix(vertex): normalize Claude Opus 4.6 legacy model-id aliases#5969

Merged
kevinvandijk merged 5 commits intoKilo-Org:mainfrom
Olusammytee:fix/5772-vertex-claude-opus-46-model-id
Feb 21, 2026
Merged

fix(vertex): normalize Claude Opus 4.6 legacy model-id aliases#5969
kevinvandijk merged 5 commits intoKilo-Org:mainfrom
Olusammytee:fix/5772-vertex-claude-opus-46-model-id

Conversation

@Olusammytee
Copy link

Summary

  • switch the Vertex Claude Opus 4.6 catalog entry to canonical claude-opus-4-6
  • add
    ormalizeVertexModelId in types to map legacy aliases (claude-opus-4-6@default, claude-opus-4-6@vertex) to the canonical ID
  • use normalization in Vertex runtime handlers and webview selected-model hook so saved legacy config is auto-corrected
  • add regression tests in packages/types, src/api/providers, and webview-ui

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

@changeset-bot
Copy link

changeset-bot bot commented Feb 18, 2026

🦋 Changeset detected

Latest commit: e688abc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
kilo-code Patch

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

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/types and 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().

Comment on lines 224 to 227
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]
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,16 @@
import { normalizeVertexModelId } from "../vertex.js"
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +567 to +588
/**
* 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
}
}
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
openAiModelInfoSaneDefaults,
openAiNativeModels,
vertexModels,
normalizeVertexModelId,
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
normalizeVertexModelId,
normalizeVertexModelId, // kilocode_change

Copilot uses AI. Check for mistakes.
Comment on lines 296 to 300
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 }
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines 15 to 19
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 })
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@Olusammytee
Copy link
Author

Rebased onto latest main and resolved merge conflicts.

  • Kept the Vertex Claude Opus 4.6 alias normalization changes
  • Preserved the existing gemini-3.1-pro-preview native-tools coverage in vertex.spec.ts

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", () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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", () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@kilo-code-bot
Copy link
Contributor

kilo-code-bot bot commented Feb 20, 2026

Code Review Summary

Status: 11 Issues Found | Recommendation: Address before merge

Fix these issues in Kilo Cloud

Overview

Severity Count
CRITICAL 0
WARNING 7
SUGGESTION 4
Issue Details (click to expand)

WARNING

File Line Issue
packages/types/src/providers/vertex.ts 620 Missing kilocode_change end marker for the normalizeVertexModelId block
src/api/providers/__tests__/anthropic-vertex.spec.ts 842 Missing kilocode_change marker on new test block
src/api/providers/__tests__/vertex.spec.ts 154 Missing kilocode_change marker on new test block
src/api/providers/__tests__/vertex.spec.ts N/A Indentation inconsistency in test file
webview-ui/src/components/ui/hooks/__tests__/useSelectedModel.spec.ts N/A Missing kilocode_change marker on new test block
webview-ui/src/components/ui/hooks/__tests__/useSelectedModel.spec.ts 795-834 Indentation regression — new vertex provider block uses extra tab, and the existing litellm provider block was shifted to 2 tabs (was 1 tab), breaking consistency with the rest of the file
webview-ui/src/components/ui/hooks/useSelectedModel.ts N/A Missing kilocode_change annotation on normalizeVertexModelId import

SUGGESTION

File Line Issue
packages/types/src/providers/vertex.ts 613 Inconsistent case handling — Object.hasOwn() check is case-sensitive but the switch uses .toLowerCase(). A mixed-case input like "Claude-Opus-4-6" would bypass Object.hasOwn and fall through to the default, silently returning the default model instead of matching
src/api/providers/anthropic-vertex.ts 227 normalizeVertexModelId("") is unnecessarily verbose — the ternary could be simplified to normalizeVertexModelId(modelId || "")
src/api/providers/vertex.ts 18 Same redundant ternary pattern as anthropic-vertex.ts
webview-ui/src/components/ui/hooks/useSelectedModel.ts 301 Vertex model-id normalization logic added without full kilocode_change block markers
Files Reviewed (8 files)
  • .changeset/silver-cups-bow.md - 0 issues
  • packages/types/src/providers/__tests__/vertex.spec.ts - 0 issues (marker present)
  • packages/types/src/providers/vertex.ts - 2 issues
  • src/api/providers/__tests__/anthropic-vertex.spec.ts - 1 issue
  • src/api/providers/__tests__/vertex.spec.ts - 2 issues
  • src/api/providers/anthropic-vertex.ts - 1 issue
  • src/api/providers/vertex.ts - 1 issue
  • webview-ui/src/components/ui/hooks/__tests__/useSelectedModel.spec.ts - 2 issues
  • webview-ui/src/components/ui/hooks/useSelectedModel.ts - 2 issues

@Olusammytee
Copy link
Author

Addressed the latest kiloconnect review items in commit b42cf82:

  • Re-indented the new getModel tests in src/api/providers/__tests__/vertex.spec.ts to match surrounding nesting.
  • Added // kilocode_change start/end markers around the new alias-normalization test in src/api/providers/__tests__/anthropic-vertex.spec.ts.

Please re-run review/CI.

expect(modelInfo.info.contextWindow).toBe(1048576)
})

it("should normalize legacy claude-opus-4-6 aliases", () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
it("should normalize legacy claude-opus-4-6 aliases", () => {
// kilocode_change start
it("should normalize legacy claude-opus-4-6 aliases", () => {

})
})

describe("vertex provider", () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Missing kilocode_change marker — this new test block modifies a file in webview-ui/, which requires kilocode_change markers per project conventions.

Suggested change
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).

@Olusammytee
Copy link
Author

Addressed the latest kiloconnect marker/style warnings in commit e90005d:

  • Added kilocode_change markers around normalizeVertexModelId usage in src/api/providers/vertex.ts and src/api/providers/anthropic-vertex.ts.
  • Wrapped normalizeVertexModelId block in packages/types/src/providers/vertex.ts with markers.
  • Added // kilocode_change - new file header to packages/types/src/providers/__tests__/vertex.spec.ts.
  • Annotated Vertex normalization import/logic in webview-ui/src/components/ui/hooks/useSelectedModel.ts.
  • Added markers around the new vertex-provider test block in webview-ui/src/components/ui/hooks/__tests__/useSelectedModel.spec.ts.
  • Added markers around the Vertex alias normalization test and cleaned the trailing indentation in src/api/providers/__tests__/vertex.spec.ts.

Please re-run review.

return normalized as VertexModelId
}

switch (normalized.toLowerCase()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug Report: 404 Error with Vertex AI Provider for claude-opus-4-6 Model

3 participants