Skip to content

fix(moa): route auxiliary calls through concrete providers - #53801

Closed
ildunari wants to merge 1 commit into
NousResearch:mainfrom
ildunari:fix/moa-auxiliary-routing-upstream
Closed

fix(moa): route auxiliary calls through concrete providers#53801
ildunari wants to merge 1 commit into
NousResearch:mainfrom
ildunari:fix/moa-auxiliary-routing-upstream

Conversation

@ildunari

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes two MoA auxiliary-routing edge cases:

  1. Auxiliary calls made while the main runtime is provider: moa now resolve to the active preset's concrete aggregator provider/model instead of trying to construct a client for the virtual moa provider.
  2. openai-codex MoA reference slots no longer receive raw runtime base_url/api_key values from resolve_runtime_provider(). That bypasses the Codex auxiliary wrapper and can hit ChatGPT/Cloudflare HTML even though the normal Codex auxiliary route works. The slot now stays as provider=openai-codex, model=..., so call_llm() uses the existing Codex auxiliary client path.

This keeps MoA's provider-aware slot resolution for normal API/custom providers, while preserving specialized adapter behavior for Codex.

Related Issue

No linked issue. Found while testing a MoA preset with:

  • references: openai-codex:gpt-5.5, zai:glm-5.2
  • aggregator: custom:vibe-proxy:claude-opus-4-8

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • Tests (adding or improving test coverage)

Changes Made

  • agent/auxiliary_client.py
    • Resolves provider="moa" auxiliary calls through the active MoA preset aggregator.
    • Prevents virtual MoA runtime values (moa://..., virtual API key, MoA api mode) from leaking into concrete aggregator resolution.
    • Makes auto auxiliary resolution return the concrete aggregator model when the main runtime is MoA.
  • agent/moa_loop.py
    • Skips raw runtime credential injection for openai-codex slots so Codex uses its existing auxiliary wrapper.
  • tests/agent/test_auxiliary_client.py
    • Adds direct and auto-mode MoA auxiliary regression coverage.
  • tests/run_agent/test_moa_loop_mode.py
    • Adds regression coverage for openai-codex MoA slots using the auxiliary wrapper path.

How to Test

  1. python -m py_compile agent/auxiliary_client.py agent/moa_loop.py
  2. pytest -q tests/run_agent/test_moa_loop_mode.py tests/agent/test_auxiliary_client.py::TestResolveProviderClientMoA tests/gateway/test_moa_one_shot_restore.py tests/cli/test_moa_command.py
  3. pytest -q tests/agent/test_auxiliary_client.py tests/run_agent/test_moa_loop_mode.py

Results locally:

  • py_compile: passed
  • Focused MoA/auxiliary set: 19 passed
  • Full affected test files: 259 passed

I also tried scripts/run_tests.sh per the contributing guide, but this worktree's repo venv does not have pytest installed, so the wrapper failed before exercising this patch with repeated No module named pytest errors. Direct pytest in the active development environment passed the affected suites above.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS 26.5

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

Screenshots / Logs

Observed local smoke before the fix: MoA with an openai-codex:gpt-5.5 reference could produce:

WARNING agent.moa_loop: MoA reference model openai-codex:gpt-5.5 failed: <html>

After the fix, the same MoA preset completed without that warning.

@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/openai OpenAI / Codex Responses API P3 Low — cosmetic, nice to have labels Jun 27, 2026
@andyoliver-cloud

Copy link
Copy Markdown

Confirming this on Hermes 0.17.0. MoA preset with Codex as the aggregator (Grok + DeepSeek references) reliably fails... references return fine but the Codex aggregator hits HTTP 403 / Cloudflare HTML, so the whole MoA response either breaks or stalls to the 600s timeout. Workaround for now is keeping Codex OAuth as main only and using API-style providers in MoA slots. Looks like this PR addresses exactly that routing path.

@teknium1

Copy link
Copy Markdown
Contributor

Already on main_resolve_auto resolves a MoA preset to its aggregator for auxiliary tasks and stops forwarding the virtual moa://local base_url / placeholder key (shipped in #53827). Same intent landed in parallel.

@teknium1 teknium1 closed this Jun 30, 2026
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/openai OpenAI / Codex Responses API type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants