Skip to content

fix(auxiliary): gate Anthropic base_url override on Anthropic-compatible host (#52608) - #52891

Merged
kshitijk4poor merged 1 commit into
NousResearch:mainfrom
kshitijk4poor:salvage/52623-aux-host
Jun 26, 2026
Merged

fix(auxiliary): gate Anthropic base_url override on Anthropic-compatible host (#52608)#52891
kshitijk4poor merged 1 commit into
NousResearch:mainfrom
kshitijk4poor:salvage/52623-aux-host

Conversation

@kshitijk4poor

Copy link
Copy Markdown
Collaborator

Summary

Salvage of #52623 by @Tranquil-Flow (rebased onto current main, 101 commits ahead — cherry-pick applied cleanly, no conflicts).

agent/auxiliary_client.py::_try_anthropic() unconditionally applies cfg["model"]["base_url"] as the auxiliary Anthropic base_url whenever cfg["model"]["provider"] == "anthropic" — even when that URL points at a different provider's endpoint (e.g. OpenRouter, OpenAI). This causes every auxiliary side-channel call (memory extractors, reflection, vision, title generation) to 401 from the foreign host.

Fix

Add _is_anthropic_compatible_host() hostname validation gate before applying the config override. Only api.anthropic.com (and its path variants) are treated as safe Anthropic-compatible endpoints. Non-Anthropic hosts fall back to _ANTHROPIC_DEFAULT_BASE_URL.

Testing

  • pytest tests/agent/test_auxiliary_client_base_url_host_validation_52608.py -> 5 passed
  • pytest tests/agent/test_auxiliary_client.py -> 244 passed (no regressions)
  • ruff check agent/auxiliary_client.py tests/agent/test_auxiliary_client_base_url_host_validation_52608.py -> passed
  • Mutation test: reverting the host gate causes 2 regression tests to FAIL (OpenRouter leak + OpenAI leak) — confirmed non-vacuous

Depends on

PR #52888 (AUTHOR_MAP chore — adds Tranquil-Flow email mappings)

Closes #52608
Closes #52623

Co-authored-by: Tranquil-Flow 66773372+Tranquil-Flow@users.noreply.github.com

…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.
@kshitijk4poor
kshitijk4poor force-pushed the salvage/52623-aux-host branch from 0155b77 to 4e66bf1 Compare June 26, 2026 05:51
@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint provider/anthropic Anthropic native Messages API area/auth Authentication, OAuth, credential pools P2 Medium — degraded but workaround exists labels Jun 26, 2026
@kshitijk4poor
kshitijk4poor merged commit 7d56829 into NousResearch:main Jun 26, 2026
27 checks passed
waefrebeorn pushed a commit to waefrebeorn/slermes that referenced this pull request Jul 2, 2026
…3-aux-host

fix(auxiliary): gate Anthropic base_url override on Anthropic-compatible host (NousResearch#52608)
habarmc1223-sudo pushed a commit to habarmc1223-sudo/hermes-agent-fluxmem that referenced this pull request Jul 8, 2026
…3-aux-host

fix(auxiliary): gate Anthropic base_url override on Anthropic-compatible host (NousResearch#52608)
santhreal pushed a commit to santhreal/hermes-agent that referenced this pull request Jul 13, 2026
…3-aux-host

fix(auxiliary): gate Anthropic base_url override on Anthropic-compatible host (NousResearch#52608)
Gravezzz pushed a commit to Gravezzz/hermes-agent that referenced this pull request Jul 21, 2026
…3-aux-host

fix(auxiliary): gate Anthropic base_url override on Anthropic-compatible host (NousResearch#52608)
@kshitijk4poor
kshitijk4poor deleted the salvage/52623-aux-host branch August 5, 2026 07:08
leewenjie pushed a commit to leewenjie/hermes-agent that referenced this pull request Aug 7, 2026
…3-aux-host

fix(auxiliary): gate Anthropic base_url override on Anthropic-compatible host (NousResearch#52608)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/auth Authentication, OAuth, credential pools comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P2 Medium — degraded but workaround exists provider/anthropic Anthropic native Messages API type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

auxiliary_client: _try_anthropic() misroutes side-channel calls when main config has provider=anthropic with a non-Anthropic base_url

2 participants