fix: route api.anthropic.com custom providers through anthropic_messages on fallback - #49247
Closed
x9x9x9x9x9x91 wants to merge 1 commit into
Closed
Conversation
…ges on fallback The fallback activation path re-derived api_mode from the provider name and a "/anthropic" URL-suffix check, missing custom providers (e.g. cron-anthropic) that point at the native api.anthropic.com host with no path suffix. They defaulted to chat_completions, so failover POSTed /v1/chat/completions and 404'd on every attempt — the configured Anthropic fallback never actually worked. Match the host the same way the primary path's determine_api_mode() already does. Adds a regression test asserting an api.anthropic.com custom-provider fallback entry resolves to anthropic_messages.
teknium1
added a commit
that referenced
this pull request
Jul 1, 2026
…ction 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.
teknium1
pushed a commit
that referenced
this pull request
Jul 1, 2026
Pins that a custom provider on the native api.anthropic.com host resolves to anthropic_messages on the try_activate_fallback path. From #49247.
teknium1
added a commit
that referenced
this pull request
Jul 1, 2026
Contributor
waefrebeorn
pushed a commit
to waefrebeorn/slermes
that referenced
this pull request
Jul 2, 2026
…ction Widen the salvaged NousResearch#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 NousResearch#49247.
waefrebeorn
pushed a commit
to waefrebeorn/slermes
that referenced
this pull request
Jul 2, 2026
Pins that a custom provider on the native api.anthropic.com host resolves to anthropic_messages on the try_activate_fallback path. From NousResearch#49247.
waefrebeorn
pushed a commit
to waefrebeorn/slermes
that referenced
this pull request
Jul 2, 2026
Jasper6439
pushed a commit
to Jasper6439/hermes-agent
that referenced
this pull request
Jul 5, 2026
…ction Widen the salvaged NousResearch#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 NousResearch#49247.
Jasper6439
pushed a commit
to Jasper6439/hermes-agent
that referenced
this pull request
Jul 5, 2026
Pins that a custom provider on the native api.anthropic.com host resolves to anthropic_messages on the try_activate_fallback path. From NousResearch#49247.
Jasper6439
pushed a commit
to Jasper6439/hermes-agent
that referenced
this pull request
Jul 5, 2026
habarmc1223-sudo
pushed a commit
to habarmc1223-sudo/hermes-agent-fluxmem
that referenced
this pull request
Jul 8, 2026
…ction Widen the salvaged NousResearch#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 NousResearch#49247.
habarmc1223-sudo
pushed a commit
to habarmc1223-sudo/hermes-agent-fluxmem
that referenced
this pull request
Jul 8, 2026
Pins that a custom provider on the native api.anthropic.com host resolves to anthropic_messages on the try_activate_fallback path. From NousResearch#49247.
habarmc1223-sudo
pushed a commit
to habarmc1223-sudo/hermes-agent-fluxmem
that referenced
this pull request
Jul 8, 2026
santhreal
pushed a commit
to santhreal/hermes-agent
that referenced
this pull request
Jul 13, 2026
…ction Widen the salvaged NousResearch#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 NousResearch#49247.
santhreal
pushed a commit
to santhreal/hermes-agent
that referenced
this pull request
Jul 13, 2026
Pins that a custom provider on the native api.anthropic.com host resolves to anthropic_messages on the try_activate_fallback path. From NousResearch#49247.
santhreal
pushed a commit
to santhreal/hermes-agent
that referenced
this pull request
Jul 13, 2026
1 task
Gravezzz
pushed a commit
to Gravezzz/hermes-agent
that referenced
this pull request
Jul 21, 2026
…ction Widen the salvaged NousResearch#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 NousResearch#49247.
Gravezzz
pushed a commit
to Gravezzz/hermes-agent
that referenced
this pull request
Jul 21, 2026
Pins that a custom provider on the native api.anthropic.com host resolves to anthropic_messages on the try_activate_fallback path. From NousResearch#49247.
Gravezzz
pushed a commit
to Gravezzz/hermes-agent
that referenced
this pull request
Jul 21, 2026
23 tasks
leewenjie
pushed a commit
to leewenjie/hermes-agent
that referenced
this pull request
Aug 7, 2026
…ction Widen the salvaged NousResearch#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 NousResearch#49247.
leewenjie
pushed a commit
to leewenjie/hermes-agent
that referenced
this pull request
Aug 7, 2026
Pins that a custom provider on the native api.anthropic.com host resolves to anthropic_messages on the try_activate_fallback path. From NousResearch#49247.
leewenjie
pushed a commit
to leewenjie/hermes-agent
that referenced
this pull request
Aug 7, 2026
teknium1
added a commit
that referenced
this pull request
Aug 13, 2026
Maintainer fixup on the #79787 salvage: - An explicit fb.api_mode of "chat_completions" was silently overridden by the codex_responses / bedrock re-detection pass (which only skipped re-detection when the pre-computed mode was non-default). Track explicitness in fb_api_mode_explicit and gate the whole re-detection block on it. - Replace the locals().get('fb_api_mode') dead-code hack with clean code (fb_api_mode is always bound at that point). - Restore the post-resolve /anthropic + api.anthropic.com host check for named custom providers whose base_url comes from config rather than the fallback entry (#32243, #49247), which the PR's restructure dropped. - Add regression tests: explicit api_mode honored (incl. explicit chat_completions not overridden), /anthropic-hint fallback detected pre-rewrite, api_mode forwarded to resolve_provider_client, plain fallback unchanged.
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On the fallback provider path,
api_modedetection misses custom providers that point at the native Anthropic host (api.anthropic.com) without a/anthropicbase-URL suffix.The fallback resolver only matches:
A custom provider (e.g. one named
cron-anthropic) whosebase_urlishttps://api.anthropic.comhas neitherprovider == "anthropic"nor a/anthropicsuffix, so it falls through tochat_completions→POST /v1/chat/completions→ 404 against the Anthropic host on every fallback.The primary path already handles this correctly in
determine_api_mode()by matching the host. The fallback path just doesn't mirror it.Fix
Mirror the primary path's host check in the fallback resolver: also route to
anthropic_messageswhenbase_url_hostname(fb_base_url) == "api.anthropic.com".Test
Adds
tests/run_agent/test_provider_fallback.pycovering a custom provider pointed atapi.anthropic.comwith no/anthropicsuffix, asserting it resolves toanthropic_messageson fallback (notchat_completions). Full file: 23 passed.Fixes the whole class — name match, suffix match, and host match — not just the one site.