Skip to content

Fix provider_for for full Claude model IDs#143

Merged
PleasePrompto merged 3 commits into
PleasePrompto:mainfrom
askhatsoltanov1984-lang:fix/claude-full-model-provider
Jun 12, 2026
Merged

Fix provider_for for full Claude model IDs#143
PleasePrompto merged 3 commits into
PleasePrompto:mainfrom
askhatsoltanov1984-lang:fix/claude-full-model-provider

Conversation

@askhatsoltanov1984-lang

Copy link
Copy Markdown
Contributor

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.
PleasePrompto and others added 2 commits June 12, 2026 06:59
Move the full-Claude-ID regression test into the existing ModelRegistry
test section and drop the duplicate alias/codex/gemini asserts. Trim the
change-history narration from the provider_for docstring.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@PleasePrompto PleasePrompto merged commit bc77c40 into PleasePrompto:main Jun 12, 2026
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.

2 participants