fix: Prevent cross-family model matching in resolveModelPreference#731
Open
LucaDiba wants to merge 2 commits into
Open
fix: Prevent cross-family model matching in resolveModelPreference#731LucaDiba wants to merge 2 commits into
LucaDiba wants to merge 2 commits into
Conversation
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>
42480b2 to
4e8de46
Compare
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Partially addresses #639. Builds on #702 which added version-aware matching.
When the SDK's
opusalias resolves to a newer version than what's inavailableModels(e.g. the SDK was bumped to Opus 4.8 butavailableModelsstill containsclaude-opus-4-6[1m]), the version check from #702 correctly rejects theopusentry (4.8 ≠ 4.6). However, the tokenized matcher then falls through tosonnet[1m]because the1mcontext hint token alone scores 3 points — enough to win. This causesclaude-opus-4-6[1m]to display as "Sonnet (1M context)".Fix:
scoreModelMatchnow 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
does not inherit display info across mismatched model families— verifiesclaude-opus-4-6[1m]does not resolve toSonnet (1M context)acp-agent-settings.test.ts)mainand pass with the fix