fix(auxiliary): gate Anthropic base_url override on Anthropic-compatible host (#52608) - #52623
Closed
Tranquil-Flow wants to merge 1 commit into
Closed
Conversation
…ble host (NousResearch#52608) When operator config has provider=anthropic with model.base_url pointing at a non-Anthropic host (e.g. https://openrouter.ai/api/v1 with provider=anthropic), the auxiliary Anthropic path was unconditionally applying that override. Main-session traffic routed correctly because the main path attaches the right credential for the actual destination, but every side-channel call (memory extractors, reflection, vision, title generation, janus extractor/promise) sent ANTHROPIC_API_KEY to the foreign host and 401'd. Gate the override on hostname == api.anthropic.com. Operators routing main through a non-Anthropic provider must use that provider's own auxiliary client; the Anthropic aux path now stays pointed at api.anthropic.com. Regression tests cover openrouter, openai, anthropic-with-path, empty, and anthropic-default-base_url cases.
This was referenced Jun 26, 2026
Collaborator
|
Salvaged into #52891 (rebased onto current main, 101 commits ahead — cherry-pick applied cleanly). All credit to @Tranquil-Flow for the original fix. Thanks for the contribution! Note: PR #52888 (AUTHOR_MAP chore) must merge first — it adds the Tranquil-Flow email mappings. |
kshitijk4poor
added a commit
that referenced
this pull request
Jun 26, 2026
pai-scaffolde
pushed a commit
to pai-scaffolde/hermes-agent
that referenced
this pull request
Jun 28, 2026
waefrebeorn
pushed a commit
to waefrebeorn/slermes
that referenced
this pull request
Jul 2, 2026
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
Gravezzz
pushed a commit
to Gravezzz/hermes-agent
that referenced
this pull request
Jul 21, 2026
leewenjie
pushed a commit
to leewenjie/hermes-agent
that referenced
this pull request
Aug 7, 2026
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
agent/auxiliary_client.py::_try_anthropic()unconditionally appliescfg["model"]["base_url"]as the auxiliary Anthropic base_url whenevercfg["model"]["provider"] == "anthropic"— even when that URL points at a different provider's endpoint (e.g. OpenRouter, OpenAI).When operators run with:
…the main session works (main code path attaches the right key), but every auxiliary call (memory-provider extractors, reflection extractors, title-generation, vision passes, session-search) hits the override path and sends
ANTHROPIC_API_KEYto the foreign host, which rejects it with401 Missing Authentication header.Fix
Add a hostname validation gate (
_is_anthropic_compatible_host()) before applying the config override. Onlyapi.anthropic.com(and its path variants) are treated as safe Anthropic-compatible endpoints. Non-Anthropic hosts fall back to_ANTHROPIC_DEFAULT_BASE_URL.Test plan
test_auxiliary_client_base_url_host_validation_52608.py— all pass with fixtest_auxiliary_client.pytests pass — no regressionspython3 -m pytest tests/agent/test_auxiliary_client_base_url_host_validation_52608.py -v -o addopts= # 5 passedFixes #52608
Auto-published by Moonsong via Path B automated pipeline.