Skip to content

fix: preserve Anthropic provider identity in MoA - #55452

Closed
freshgame-oss wants to merge 1 commit into
NousResearch:mainfrom
freshgame-oss:fix/moa-anthropic-provider-identity
Closed

fix: preserve Anthropic provider identity in MoA#55452
freshgame-oss wants to merge 1 commit into
NousResearch:mainfrom
freshgame-oss:fix/moa-anthropic-provider-identity

Conversation

@freshgame-oss

Copy link
Copy Markdown

Summary

MoA reference/aggregator slots currently resolve provider runtime metadata with resolve_runtime_provider(). For providers whose resolved runtime includes a base_url, _slot_runtime() passes that base_url into call_llm().

call_llm() treats an explicit base_url as a custom endpoint. That is correct for generic OpenAI-compatible custom endpoints, but it is wrong for first-class providers whose provider branch supplies a protocol adapter or special auth behavior.

This was already handled for nous, openai-codex, and xai-oauth. This PR adds anthropic to the same provider-identity-preserving path so MoA Anthropic slots continue through the Anthropic Messages adapter instead of being treated as custom chat-completions endpoints.

Why

Without this, an Anthropic MoA slot can be downgraded into a custom chat-completions call. On Anthropic Messages-compatible endpoints this can route to the wrong wire protocol/path and fail before the aggregator receives useful reference output.

Change

  • Preserve provider identity for anthropic in agent.moa_loop._slot_runtime().
  • Add a regression test ensuring Anthropic MoA slots do not return base_url/api_key runtime kwargs and therefore do not force call_llm() into the custom endpoint path.

Validation

python -m pytest \
  tests/run_agent/test_moa_loop_mode.py::test_moa_codex_slot_preserves_provider_identity \
  tests/run_agent/test_moa_loop_mode.py::test_moa_anthropic_slot_preserves_provider_identity \
  tests/run_agent/test_moa_loop_mode.py::test_moa_slots_routed_through_resolve_runtime_provider \
  -q

Result:

3 passed

@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 P3 Low — cosmetic, nice to have labels Jun 30, 2026

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary\n\nVerdict: LGTM\n\nAdds anthropic to the provider-identity-preserving path in MoA's _slot_runtime(). 1-line change in the source plus 26 lines of regression test. Well-scoped and targeted fix.\n\n### Looks Good\n- Single-line source change with clear rationale\n- Regression test ensures Anthropic MoA slots don't return base_url/api_key runtime kwargs\n- Consistent with the existing pattern for nous, openai-codex, and xai-oauth\n---\nReviewed by Hermes Agent

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review: LGTM

Adds "anthropic" to the MoA provider identity set so Anthropic slots don't get auto-detected as custom chat-completions endpoints. This preserves the Messages API adapter path. Clean one-line fix with a focused regression test.

Verdict: LGTM -- correct provider identity fix.

@teknium1

teknium1 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Closing as a duplicate of #54609 (submitted ~26h earlier), which fixed the same issue — adding anthropic to the _slot_runtime name-preservation set. Both were merged via #55897 with #54609's authorship in git log; credit to you both for independently spotting it.

One note for the record: the "downgraded to a custom chat-completions call / wrong wire protocol" framing is only partly the cause — a native anthropic host (api.anthropic.com) IS recovered by the endpoint URL heuristic. The load-bearing reason to keep anthropic name-preserved is the OAuth path: sk-ant-oat* tokens need Bearer + anthropic-beta: oauth-*, which only the provider branch adds. Thanks for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have 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.

4 participants