FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: support hyphenated Claude model names for Claude Code 2.1.x compatibility by yang-builds · Pull Request #250 · ericc-ch/copilot-api · GitHub

Repository navigation

fix: support hyphenated Claude model names for Claude Code 2.1.x compatibility - #250

Open
yang-builds wants to merge 1 commit into
ericc-ch:masterfrom
yang-builds:fix/hyphenated-model-names
Open

yang-builds wants to merge 1 commit into
ericc-ch:masterfrom
yang-builds:fix/hyphenated-model-names

Conversation

Copy link
Copy Markdown

Problem

Claude Code 2.1.x uses hyphenated model names (e.g. claude-sonnet-4-6) for its internal display mapping, but the GitHub Copilot backend only accepts dot notation (e.g. claude-sonnet-4.6).

The current translateModelName truncates claude-sonnet-4-6 to claude-sonnet-4, which causes:

  1. GitHub Copilot backend rejects the request with HTTP 400
  2. Claude Code welcome screen shows "Sonnet 4" instead of "Sonnet 4.6"

Root Cause

// Before — incorrect truncation
if (model.startsWith("claude-sonnet-4-")) {
  return model.replace(/^claude-sonnet-4-.*/, "claude-sonnet-4")  // ❌ drops minor version
}

claude-sonnet-4-6 → claude-sonnet-4 → rejected by Copilot backend

Fix

Replace with a regex that correctly converts hyphenated minor version to dot notation:

// After — correct conversion
const m = model.match(/^(claude-(?:sonnet|opus|haiku))-(\d+)-(\d+)$/)
if (m) return `${m[1]}-${m[2]}.${m[3]}`
Input Output Result
claude-sonnet-4-6 claude-sonnet-4.6 ✅ HTTP 200
claude-opus-4-7 claude-opus-4.7 ✅ HTTP 200
claude-haiku-4-5 claude-haiku-4.5 ✅ HTTP 200
claude-sonnet-4.6 claude-sonnet-4.6 ✅ passthrough (unchanged)

Future models (e.g. claude-sonnet-5-0) are automatically handled without any code changes.

Copy link
Copy Markdown

Need merge...

Copy link
Copy Markdown
Author

@ericc-ch gentle ping 🙏

This branch has not been deployed

No deployments
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL