Skip to content

Fix provider_for for full Claude model IDs#143

Open
askhatsoltanov1984-lang wants to merge 1 commit into
PleasePrompto:mainfrom
askhatsoltanov1984-lang:fix/claude-full-model-provider
Open

Fix provider_for for full Claude model IDs#143
askhatsoltanov1984-lang wants to merge 1 commit into
PleasePrompto:mainfrom
askhatsoltanov1984-lang:fix/claude-full-model-provider

Conversation

@askhatsoltanov1984-lang
Copy link
Copy Markdown

Problem

ModelRegistry.provider_for(...) previously matched only the short Claude
aliases (opus / sonnet / haiku). Clients that pass canonical Claude
model IDs such as:

  • claude-opus-4-7
  • claude-sonnet-4-6
  • claude-haiku-4-5-20251001

fell through the Claude branch, then the Gemini branch (no prefix match),
and ended up classified as codex. Downstream this caused Claude-bound
sessions to be routed to the Codex CLI, which silently broke session
continuity for clients that pass the full model name.

Fix

Also match a claude- prefix in provider_for. Short aliases continue
to work unchanged; non-Claude IDs (gpt-*, gemini-*, o3, etc.) are
untouched.

if model_id in CLAUDE_MODELS or model_id.startswith("claude-"):
    return "claude"

Tests

Added tests/test_provider_for_claude_full_ids.py covering:

  • Full Claude IDs (claude-opus-4-7, claude-sonnet-4-6, claude-haiku-4-5-20251001) -> claude
  • Existing short aliases (opus, sonnet, haiku) -> still claude
  • Non-Claude IDs (gpt-5.2-codex, gemini-2.5-pro) -> unchanged

Pure unit test — no network, no API calls. Runs in the existing pytest
suite.

Why merge

The patch is logic-only, additive, and matches the existing pattern
already used for Gemini (prefix check alongside a known-set check). The
short-alias path is unchanged so no in-tree behaviour regresses.

ModelRegistry.provider_for previously matched only the short Claude
aliases (opus / sonnet / haiku). Clients that pass canonical Claude
model IDs such as claude-opus-4-7, claude-sonnet-4-6 or
claude-haiku-4-5-20251001 fell through to the codex branch, breaking
Claude routing.

Match the claude- prefix in addition to the short aliases, and add a
unit test covering both old aliases and the new full IDs.
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.

1 participant