Fix model mapping to prefer the longest matching prefix#14
Merged
Conversation
Prefix lookups iterated the BTreeMap in sorted key order and returned the first match, so a specific entry like claude-opus-4.7-xhigh was shadowed by the shorter claude-opus-4.7 prefix and mapped to claude-opus-4.7-1m. Select the longest (most specific) matching prefix instead, and add a regression test.
…t versions - Interactive first-run setup wizard (src/setup.rs): GitHub sign-in, live model catalog, model-mapping prompts; runs on --setup or first launch in a terminal, skipped when headless - --claudecode now patches ~/.claude/settings.json (merges env.ANTHROPIC_BASE_URL, preserves existing settings via serde_json preserve_order) - Forward anthropic-beta: context-1m-2025-08-07 on /v1/messages for models whose catalog advertises a >200K context window - Update mimicked client versions to the latest Copilot Chat extension: copilot 0.48.1, vscode 1.123.0, api 2025-05-01 - Refine README: setup wizard, env token fallbacks, 1M context, updated headers and version-refresh sources
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.
Problem
With a config such as:
an incoming model
claude-opus-4.7-xhighwas rewritten toclaude-opus-4.7-1minstead of being kept asclaude-opus-4.7-xhigh.Root cause
translate()iterated theprefixBTreeMapin sorted key order and returned the firststarts_withmatch. The default mappings already containclaude-opus-4.7, which sorts before (and is a prefix of)claude-opus-4.7-xhigh, so the shorter, less-specific entry always won.Fix
Select the longest (most specific) matching prefix instead of the first one. Adds a
longest_prefix_winsregression test.