fix(messages): preserve Claude 4.x version suffix so vision routes to the right model#254
Open
dsgn93-creator wants to merge 1 commit intoericc-ch:masterfrom
Open
Conversation
…form Copilot exposes models as claude-opus-4.7 / claude-opus-4.6 / claude-sonnet-4.6 (dot-versioned), but Claude Code sends dash-versioned IDs with date suffixes like claude-opus-4-7-20251030. The previous translateModelName regex stripped the entire suffix and rewrote everything to claude-opus-4 / claude-sonnet-4, which (a) loses the 4.5/4.6/4.7 capability tier and (b) routes vision requests to a fallback model that may not have vision enabled — producing an internal server error when image_url parts are present even though copilot-vision-request: true is sent. Convert dash-versioned 4.x families to their dot form (claude-opus-4-7-20251030 -> claude-opus-4.7) so vision-capable variants route correctly. Falls back to the previous behavior for unknown shapes.
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
Vision requests through
--claude-codemode fail with an internal server error on Copilot Enterprise even though:copilot-vision-request: trueis correctly added bycreate-chat-completions.tswhen animage_urlpart is detectedimageblock is correctly translated to OpenAIimage_urlwith a base64 data URI inmapContentThe failure is in
translateModelName. Copilot lists its Claude models as dot-versioned:…but Claude Code sends dash-versioned IDs with a date suffix, e.g.
claude-opus-4-7-20251030. The current regex:…rewrites that to plain
claude-opus-4, which (a) loses the 4.5/4.6/4.7 capability tier and (b) routes vision-bearing requests to a fallback model that does not have vision enabled — producing the internal server error.Repro: send any image via Claude Code → 500 from Copilot. Text-only requests succeed because Copilot is forgiving about unknown model aliases for non-vision payloads.
Fix
Match
claude-(opus|sonnet|haiku)-N-M(-YYYYMMDD)?and convert dash → dot, producing the actual model ID Copilot exposes (claude-opus-4.7). Legacy fallbacks remain unchanged for any shape that doesn't match.Verification
After patching locally and reinstalling, vision requests through
--claude-codenow succeed because Copilot routes them to the actual Opus 4.7 endpoint instead of the unknown-alias fallback.Related: #16, #36, #60 (all touched the vision pipeline but none addressed the model-name rewriting).