fix(proxy): improve GitHub Copilot compatibility with modern Claude Code (#5832)

* 修复 Copilot 与新版 Claude Code 的兼容问题

* docs(proxy): correct Copilot placeholder rationale to the real mechanism

Claude Code (verified on 2.1.220) does not format-validate ANTHROPIC_API_KEY
against sk-ant-*: in headless mode the placeholder is sent upstream as-is.
The actual failure mode is the interactive custom-API-key approval prompt,
which defaults to "No (recommended)" — following the default ignores the
key and lands users in "Not logged in". Also drop the #3289 citation,
which describes a missing-placeholder scenario, not key validation.

---------

Co-authored-by: Jason <farion1231@gmail.com>
This commit is contained in:
Xu Lei
2026-08-03 10:26:22 +08:00
committed by GitHub
parent 8383076791
commit 13ea497ab0
3 changed files with 84 additions and 10 deletions
+11
View File
@@ -87,6 +87,17 @@ impl Provider {
|| self.claude_base_url_contains("chatgpt.com/backend-api/codex")
}
/// Whether the provider form's "auth field" was explicitly set to
/// ANTHROPIC_API_KEY. The form only persists `meta.apiKeyField` for the
/// non-default choice, so `None` means the default ANTHROPIC_AUTH_TOKEN.
pub fn claude_uses_api_key_field(&self) -> bool {
self.meta
.as_ref()
.and_then(|m| m.api_key_field.as_deref())
.map(|field| field.eq_ignore_ascii_case("ANTHROPIC_API_KEY"))
.unwrap_or(false)
}
fn provider_type(&self) -> Option<&str> {
self.meta.as_ref().and_then(|m| m.provider_type.as_deref())
}