fix: GitHub Copilot fallback — remove stale API version header and fix model name mapping

Two issues prevented the GitHub Models fallback from working:

1. The X-GitHub-Api-Version: 2022-11-28 header caused '400 invalid
   apiVersion' errors. The Copilot chat completions endpoint does not
   use this header — removed from both constructor and rebuildClient.

2. The anthropicToGitHubModel mapping was incomplete: it only knew
   three models and the generic date-stripping fallback produced wrong
   names (e.g. 'claude-sonnet-4-5' instead of 'claude-sonnet-4.5').
   GitHub Copilot uses dots for sub-versions, not hyphens.

   Updated with explicit mappings for all current models (sonnet 4,
   4.5; opus 4, 4.5, 4.6; haiku 4.5) and a smarter generic fallback
   that converts digit-hyphen-digit to digit.digit at the end.

3. createClientFromConfig now auto-maps Anthropic-style model names
   when the provider is 'github', so users can copy model names from
   their Anthropic config into fallback blocks without manual renaming.
This commit is contained in:
William Valentin
2026-02-07 14:04:54 -08:00
parent e12eb3a0be
commit b322e8f29c
3 changed files with 64 additions and 10 deletions
-2
View File
@@ -59,7 +59,6 @@ export class GitHubModelsClient implements ModelClient {
apiKey: apiKey || 'placeholder',
baseURL: this.baseURL,
defaultHeaders: {
'X-GitHub-Api-Version': '2022-11-28',
'Openai-Intent': 'conversation-edits',
},
});
@@ -98,7 +97,6 @@ export class GitHubModelsClient implements ModelClient {
apiKey,
baseURL: this.baseURL,
defaultHeaders: {
'X-GitHub-Api-Version': '2022-11-28',
'Openai-Intent': 'conversation-edits',
},
});