fix(provider): match api.anthropic.com host on fallback api_mode detection
Widen the salvaged #32243 fix to the try_activate_fallback path: a custom provider pointed at the native api.anthropic.com host (no /anthropic path suffix, name != anthropic) fell through to chat_completions -> POST /v1/chat/completions -> 404. Match the host the same way determine_api_mode() and _detect_api_mode_for_url() now do. Absorbs #49247.
This commit is contained in:
parent
9efe01c3a0
commit
18c61bb8cf
1 changed files with 11 additions and 1 deletions
|
|
@ -1241,7 +1241,17 @@ def try_activate_fallback(agent, reason: "FailoverReason | None" = None) -> bool
|
|||
_fb_is_azure = agent._is_azure_openai_url(fb_base_url)
|
||||
if fb_provider == "openai-codex":
|
||||
fb_api_mode = "codex_responses"
|
||||
elif fb_provider == "anthropic" or fb_base_url.rstrip("/").lower().endswith("/anthropic"):
|
||||
elif (
|
||||
fb_provider == "anthropic"
|
||||
or fb_base_url.rstrip("/").lower().endswith("/anthropic")
|
||||
or base_url_hostname(fb_base_url) == "api.anthropic.com"
|
||||
):
|
||||
# Custom providers (e.g. cron-anthropic) point at the native
|
||||
# api.anthropic.com host with no "/anthropic" path suffix, so the
|
||||
# name/suffix checks above miss them and they default to
|
||||
# chat_completions → POST /v1/chat/completions → 404. Match the
|
||||
# host the same way determine_api_mode() and _detect_api_mode_for_url()
|
||||
# do on the primary path. (#32243, #49247)
|
||||
fb_api_mode = "anthropic_messages"
|
||||
elif _fb_is_azure:
|
||||
# Azure OpenAI serves gpt-5.x on /chat/completions — does NOT
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue