Skip to content

fix: Prevent cross-family model matching in resolveModelPreference#731

Open
LucaDiba wants to merge 2 commits into
agentclientprotocol:mainfrom
LucaDiba:fix/cross-family-model-matching
Open

fix: Prevent cross-family model matching in resolveModelPreference#731
LucaDiba wants to merge 2 commits into
agentclientprotocol:mainfrom
LucaDiba:fix/cross-family-model-matching

Conversation

@LucaDiba
Copy link
Copy Markdown

@LucaDiba LucaDiba commented May 30, 2026

Summary

Partially addresses #639. Builds on #702 which added version-aware matching.

When the SDK's opus alias resolves to a newer version than what's in availableModels (e.g. the SDK was bumped to Opus 4.8 but availableModels still contains claude-opus-4-6[1m]), the version check from #702 correctly rejects the opus entry (4.8 ≠ 4.6). However, the tokenized matcher then falls through to sonnet[1m] because the 1m context hint token alone scores 3 points — enough to win. This causes claude-opus-4-6[1m] to display as "Sonnet (1M context)".

Fix: scoreModelMatch now returns 0 when the only matching token is the context hint. This prevents cross-family matches without hardcoding model family names.

Note: Claude initially recommended hardcoding model families to be 100% sure we avoid cross-family matching. While it would be a stronger signal, I didn't find references to model families in the codebase (except for opusplan --> opus) so I'm assuming the family list is transparent to claude-agent-acp.

Test plan

  • Added test: does not inherit display info across mismatched model families — verifies claude-opus-4-6[1m] does not resolve to Sonnet (1M context)
  • Existing tests pass (20/20 in acp-agent-settings.test.ts)
  • New test confirmed to fail on unmodified main and pass with the fix

Partially addresses agentclientprotocol#639. Builds on agentclientprotocol#702 which added version-aware matching.

When the SDK's `opus` alias resolves to a different version than what's
in `availableModels` (e.g. Opus 4.8 via ANTHROPIC_CUSTOM_MODEL_OPTION),
`claude-opus-4-6[1m]` incorrectly inherits display info from
`sonnet[1m]`. The version check from agentclientprotocol#702 rejects the real `opus` entry
(4.8 ≠ 4.6), then the tokenized matcher falls through to `sonnet[1m]`
because the `1m` context hint token alone scores 3 points.

Fix: scoreModelMatch now returns 0 when the only matching token is the
context hint. This prevents cross-family matches without hardcoding
model family names.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@LucaDiba LucaDiba force-pushed the fix/cross-family-model-matching branch from 42480b2 to 4e8de46 Compare May 30, 2026 02:16
@LucaDiba LucaDiba changed the title fix: Prevent cross-family model matching and prefer [1m] context variants fix: Prevent cross-family model matching in resolveModelPreference May 30, 2026
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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