Skip to content

agentHost: keep minor version for Claude Code \[1m]\ model ids - #338279

Open
Kysluss wants to merge 2 commits into
microsoft:mainfrom
Kysluss:claude/model-version-translation-4cd011
Open

Kysluss wants to merge 2 commits into
microsoft:mainfrom
Kysluss:claude/model-version-translation-4cd011

Conversation

@Kysluss

@Kysluss Kysluss commented Sep 28, 2026 •

Copy link
Copy Markdown

Fixes #334750

Problem

When the Claude CLI is configured with a model id that has both a minor version and Claude Code's [1m] context tag, toSdkModelId truncated the minor version. This affects both current flagship models: Fable 5.1 (claude-fable-5-1[1m], the id from the issue) became claude-fable-5, and Opus 5.5 (claude-opus-5-5, whose [1m] form follows the same shape) became claude-opus-5. Sonnet 5.5 and Haiku 5.5 would hit the same path once released.

Input Before After
claude-fable-5-1[1m] claude-fable-5 claude-fable-5-1[1m]
claude-opus-5-5[1m] claude-opus-5 claude-opus-5-5[1m]
claude-opus-4-8[1m] claude-opus-4 claude-opus-4-8[1m]

The [1m] directly after the minor version stopped Pattern 1 (name-major-minor) from matching, so Pattern 4 (name-major[-mod]) matched instead, took 1[1m] (or 5[1m]) as a modifier, and dropped it. As a result, the native Anthropic "Fable" row ran Fable 5 instead of Fable 5.1, and an Opus 5.5 selection ran Opus 5.

Fix

  • Split a trailing [1m]/[2m] tag off before the version patterns run. The pattern matches the Claude Code CLI's own model-id regex ((?:\[[12]m\])?$), where the tag always comes after any date suffix.
  • SDK id keeps the tag. The CLI checks for [1m] in the model id to enable the context-1m-2025-08-07 beta, so removing it would silently lose the 1M context window. Native ids from supportedModels() now round-trip unchanged.
  • Endpoint id drops the tag. The CLI strips the bracketed tag from model when building Messages API requests and sends the beta header instead, so the Copilot proxy never receives the bracket form. Dropping it in toEndpointModelId matches what reaches CAPI.
  • Bare names with a tag are not parsed. CLI aliases such as opus[1m] and fable[1m] (returned by supportedModels()) still pass through toSdkModelId unchanged rather than losing the tag.
  • Stricter modifiers. Modifiers are now limited to dash-separated alphanumerics, and the five version patterns share one modifier definition. Malformed ids ([1m][1m], [foo], [1m]-<date>) and Vertex-style claude-opus-4-1@20250805 now pass through unchanged instead of being cut down to the major version. The CLI doesn't produce these forms, so this is defence in depth.

Validation

  • claudeModelId.test.ts: added a snapshot test covering the ids from the issue plus Opus/Sonnet/Haiku 5.5, and a test that malformed or non-Claude bracketed ids return undefined. Added claude-fable-5-1[1m] to the existing toSdkModelId pass-through test.
  • npm run test-node -- --run src/vs/platform/agentHost/test/node/<suite>.test.ts:
    • claudeModelId: 43 passing
    • claudeModelSelection: 13 passing
    • claudeProxyService: 46 passing
    • claudeAgent: 296 passing
  • Manual tests in agents window, native Anthropic transport:
    • Selected the native "Fable" row; the session transcript shows claude-fable-5-1 (was claude-fable-5 before this change)
    • Repeated with claude-opus-5-5[1m] → claude-opus-5-5.

`toSdkModelId('claude-fable-5-1[1m]')` returned `claude-fable-5`: the
bracketed context tag blocked the major-minor pattern, so the major-only
pattern swallowed `1[1m]` as a modifier and dropped it. The native Fable
row ran Fable 5 instead of 5.1, and `claude-opus-5-5[1m]` became
`claude-opus-5`.

Split a trailing `[1m]`/`[2m]` tag off before pattern matching. Keep it in
the SDK id, where the CLI uses it to enable the 1M context beta, and drop
it from the endpoint id, since the CLI strips it before calling the
Messages API. Restrict modifiers to dash-separated alphanumerics so
malformed ids pass through unchanged instead of being truncated.

Fixes microsoft#334750
Copilot AI balanced review requested due to automatic review settings September 28, 2026 00:59
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

TylerLeonhardt

Matched files:

  • src/vs/platform/agentHost/node/claude/claudeModelId.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The focused parser change resolves the truncation while preserving existing endpoint normalization behavior.

Review effort: Balanced
Findings: None

What changed in this PR

Fixes Claude model normalization for bracketed context suffixes without truncating minor versions.

Changes:

  • Separates [1m]/[2m] suffixes before parsing.
  • Preserves context tags for SDK IDs while removing them from endpoint IDs.
  • Adds regression and malformed-input tests.
File Description
src/​vs/​platform/​agentHost/​node/​claude/​claudeModelId.ts Updates model-ID parsing and formatting.
src/​vs/​platform/​agentHost/​test/​node/​claudeModelId.test.ts Covers context suffixes and invalid forms.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

This branch has not been deployed

No deployments
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.

Agent host Claude harness: toSdkModelId turns claude-fable-5-1[1m] into claude-fable-5 (native "Fable" row runs Fable 5 instead of 5.1)

3 participants