Skip to content

refactor(moa): unify slot provider-identity on the single call_llm chokepoint - #89

Merged
hashbender merged 1 commit into
mainfrom
mirror/pr-55991
Jul 1, 2026
Merged

refactor(moa): unify slot provider-identity on the single call_llm chokepoint#89
hashbender merged 1 commit into
mainfrom
mirror/pr-55991

Conversation

@hashbender

Copy link
Copy Markdown
Owner

Summary

MoA slot provider-identity is now decided in one place. _slot_runtime forwards the resolved endpoint for every slot; _resolve_task_provider_model is the single chokepoint that keeps a first-class provider's identity instead of collapsing an explicit base_url to the generic custom route.

This retires the hand-maintained name-preservation whitelist in agent/moa_loop.py that had to be extended by hand for every provider with custom auth/signing — the exact drift that produced the recent anthropic (NousResearch#54609) and bedrock (NousResearch#54912) breakages.

Root cause of the duplication

Two guards were enforcing the same invariant:

  • moa_loop.py::_slot_runtime — a fixed set {nous, anthropic, openai-codex, xai-oauth, bedrock} that returned bare provider+model so call_llm never saw a base_url to collapse.
  • auxiliary_client.py::_resolve_task_provider_model_preserve_provider_with_base_url(provider), a provider-catalog capability check that keeps identity for any first-class provider even when a base_url is present.

The second is strictly more general (auto-tracks the catalog); the first was a manual denylist of the collapse that drifted out of sync.

Change

  • _slot_runtime forwards base_url/api_key/api_mode unconditionally; whitelist removed.
  • Tests updated to assert the pipeline invariant (_slot_runtime_resolve_task_provider_model preserves identity) against the real resolver, instead of the whitelist's bare-return shape.

Why it's behaviorally safe

The five providers' resolve_provider_client branches re-resolve their own credentials by name and ignore a forwarded base_url/api_key:

  • openai-codex_read_codex_access_token() (Responses wrap + Cloudflare headers)
  • xai-oauth_build_xai_oauth_aux_client()
  • bedrock (aws_sdk) → boto3 credential chain + SigV4 signing; forwarded placeholder "aws-sdk" key is ignored
  • anthropic_try_anthropic() (OAuth-token detection → Bearer + anthropic-beta)
  • nous → catalog api_key provider, re-resolves the same endpoint

Validation

Result
Real-import E2E: _slot_runtime_resolve_task_provider_model for openai-codex / xai-oauth / bedrock / anthropic / nous (+openrouter control) 6/6 preserve identity, 0 collapse to custom
tests/run_agent/test_moa_loop_mode.py 20/20 pass
tests/agent/test_auxiliary_client.py 274/274 pass

Infographic

MoA slot identity — one chokepoint


Mirror-of: NousResearch#55991
NousResearch#55991

@tenki-reviewer

tenki-reviewer Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review Complete

Risk: 🟡 Medium (35/100) — 1 medium finding · 99 LOC across 2 files

Files Reviewed: 2
Findings: 1

By Severity:

  • 🟡 Medium: 1

The PR refactors MoA loop slot resolution, removing a duplicate provider whitelist from moa_loop.py and delegating all identity preservation to _preserve_provider_with_base_url. One defense-in-depth gap noted: the hardcoded fallback set in auxiliary_client.py omits 'bedrock', which was previously covered by the removed whitelist.

Files Reviewed (2 files)
agent/moa_loop.py
tests/run_agent/test_moa_loop_mode.py

@hashbender
hashbender merged commit 5710b6c into main Jul 1, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant