Skip to content

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

fix: support hyphenated Claude model names for Claude Code 2.1.x compatibility#250
yang-builds wants to merge 1 commit into
ericc-ch:masterfrom
yang-builds:fix/hyphenated-model-names

Conversation

@yang-builds
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-6claude-sonnet-4rejected 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.

@LivioGama
Copy link
Copy Markdown

Need merge...

LivioGama added a commit to LivioGama/copilot-api that referenced this pull request May 20, 2026
GitHub Copilot rejects this Anthropic beta field with HTTP 400.
Keeps PR ericc-ch#250 hyphen→dot model translation.
LivioGama added a commit to LivioGama/copilot-api that referenced this pull request May 20, 2026
- Resolve hyphenated Claude model IDs to Copilot dot notation (PR ericc-ch#250)
- Map gemini-3-5-flash and related aliases to Copilot model IDs
- Strip unsupported Anthropic fields and system-reminder bloat
- Trim oversized Claude Code prompts before Copilot rejects them
- Use max_completion_tokens for GPT-5 family models
- Surface nested Copilot error messages in API responses
@yang-builds
Copy link
Copy Markdown
Author

@ericc-ch gentle ping 🙏

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