fix(provider): route api.anthropic.com to anthropic_messages (#32243) - #233
Closed
hashbender wants to merge 1 commit into
Closed
fix(provider): route api.anthropic.com to anthropic_messages (#32243)#233hashbender wants to merge 1 commit into
hashbender wants to merge 1 commit into
Conversation
|
Review Complete Risk: 🟢 Low (5/100) — no findings · 4 LOC across 1 file Single-file change adding entries to the AUTHOR_MAP dictionary in scripts/release.py — pure data, no logic changes. Files Reviewed (1 files) |
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.
Summary
_detect_api_mode_for_urlnow returnsanthropic_messagesfor the nativeapi.anthropic.comhost, realigning it with its siblingproviders.determine_api_mode— which already maps that host. Previously the two helpers disagreed, so any URL-fallback path resolving a base_url ofapi.anthropic.comdefaulted tochat_completions→POST /v1/chat/completions, the OpenAI-compat shim that bills OAuth Pro/Max against a separate "extra usage" pool (surfacing as the misleading400 "out of extra usage").Root cause:
_detect_api_mode_for_urlonly matched the third-party/anthropicpath suffix (MiniMax, Zhipu GLM, LiteLLM proxies) andapi.kimi.com/coding; the direct Anthropic host fell through toNone.Salvage of NousResearch#32318 (@xxxigm), widened to also cover the
try_activate_fallbacksibling call site (NousResearch#49247, @x9x9x9x9x9x91) so the whole bug class is fixed, not just one path. Both bug sites confirmed live on currentmain.Changes
hermes_cli/runtime_provider.py:_detect_api_mode_for_urlmapshostname == "api.anthropic.com"→anthropic_messages. Exact-hostname match (base_url_hostname) rejects lookalike subdomains and path-segment spoofing.agent/chat_completion_helpers.py:try_activate_fallbackmatches the same native host, so a custom fallback provider onapi.anthropic.comno longer 404s on/v1/chat/completions.test_detect_api_mode_for_url.py(host shapes + spoof rejection),test_anthropic_oauth_routes_to_messages_api.py(pins all runtime branches +api_mode_overrideprecedence),test_provider_fallback.py(fallback path).scripts/release.py: AUTHOR_MAP entries for both contributors.Scope note
The canonical OAuth pool path (
provider: anthropic) already setsanthropic_messagesin_resolve_runtime_from_pool_entry. This bug only bit custom-provider / direct-alias / api-key-fallback configs pointing atapi.anthropic.com. Complementary to NousResearch#56128 (which classifies the "out of extra usage" 400 as billing) — that's error classification, this is routing.Validation
_detect_api_mode_for_url("https://api.anthropic.com")None→chat_completionsanthropic_messagesapi.anthropic.com.attacker.testproxy.test/api.anthropic.com/v1Supersedes stale-based NousResearch#56214. Cherry-picked onto current
main, contributor authorship preserved per-commit.Infographic
Mirror-of: NousResearch#56226
NousResearch#56226