Skip to content

fix(moa): propagate api_mode from slot runtime to call_llm (#54379) - #54384

Closed
liuhao1024 wants to merge 9 commits into
NousResearch:mainfrom
liuhao1024:liuhao/cron-bugfix-54379-moa-api-mode
Closed

fix(moa): propagate api_mode from slot runtime to call_llm (#54379)#54384
liuhao1024 wants to merge 9 commits into
NousResearch:mainfrom
liuhao1024:liuhao/cron-bugfix-54379-moa-api-mode

Conversation

@liuhao1024

Copy link
Copy Markdown
Contributor

What does this PR do?

MoA (Mixture-of-Agents) reference-model calls drop the resolved api_mode when constructing the call kwargs for a slot. A copilot reference slot running a GPT-5.x model (which Copilot only serves on the Responses API) gets called on /chat/completions and 400s with unsupported_api_for_model.

This is a two-layer fix:

  1. _slot_runtime now propagates api_mode alongside base_url/api_key from resolve_runtime_provider.
  2. call_llm now accepts an explicit api_mode parameter that takes precedence over the task-config-derived value, so the slot's resolved API surface is honored.

Related Issue

Fixes #54379

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

  • agent/moa_loop.py_slot_runtime: forward api_mode from resolve_runtime_provider into the output dict (2 lines added)
  • agent/auxiliary_client.pycall_llm: accept api_mode keyword argument and override the resolved value before passing to _get_cached_client (5 lines added: 1 param, 2 docstring, 2 logic)
  • tests/agent/test_moa_slot_api_mode.py — 4 regression tests covering api_mode propagation, omission when absent, omission when empty, and call_llm signature

How to Test

  1. Run pytest tests/agent/test_moa_slot_api_mode.py -v — all 4 tests should pass
  2. Run pytest tests/gateway/test_moa_one_shot_restore.py -v — no regressions
  3. With a Copilot GPT-5.x model configured as a MoA reference slot, trigger a MoA turn — the reference should use the Responses API instead of failing with unsupported_api_for_model

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.4.1

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

Slot_runtime resolved the provider's real API surface (including api_mode)
but only forwarded base_url and api_key to call_llm, dropping api_mode.
This caused Copilot GPT-5.x reference slots to hit /chat/completions
instead of the Responses API, returning 400 unsupported_api_for_model.

- _slot_runtime: forward api_mode from resolve_runtime_provider
- call_llm: accept explicit api_mode param, override task config
- 4 regression tests for propagation, omission, and signature
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint provider/copilot GitHub Copilot (ACP + Chat) labels Jun 28, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Merged via #55579. Your commit was cherry-picked onto current main with your authorship preserved in git log (d76ca3a). The fix also covers the anthropic_messages-on-unrecognized-host case from #55268, and #55579 adds a companion fix pinning chat_completions on live MoA preset switches (#54259/#54669). Thanks!

@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 P2 Medium — degraded but workaround exists provider/copilot GitHub Copilot (ACP + Chat) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MoA reference slots drop resolved api_mode → Copilot GPT-5.x references 400 with unsupported_api_for_model

3 participants