Skip to content

fix(agent): reset api_mode to chat_completions when switching to MoA (#54259) - #54500

Closed
Sahil-SS9 wants to merge 1 commit into
NousResearch:mainfrom
Sahil-SS9:fix/issue-54259-moa-switch-api-mode-v2
Closed

fix(agent): reset api_mode to chat_completions when switching to MoA (#54259)#54500
Sahil-SS9 wants to merge 1 commit into
NousResearch:mainfrom
Sahil-SS9:fix/issue-54259-moa-switch-api-mode-v2

Conversation

@Sahil-SS9

Copy link
Copy Markdown
Contributor

Fixes #54259

Description

When a session is switched to a MoA preset (via /moa or a persisted MoA-model session), switch_model() left agent.api_mode unchanged from whatever the previous provider used. If the previous provider was a codex slot (api_mode = "codex_responses"), the conversation loop's primary/acting call was routed through client.responses.create() against the non-HTTP placeholder base_url = "moa://local", returning HTTP 404 and falling back to a reference model — the final answer was never the aggregator's.

The init path in agent_init.py:724 already forces agent.api_mode = "chat_completions" when the provider is MoA. This change applies the same force inside the runtime switch_model() path so a session that started on a codex slot and is then switched to a MoA preset reaches a consistent state.

Verification

  • Targeted testspytest tests/run_agent/test_switch_model_moa_api_mode.py -v: 3 passed
    • test_switch_to_moa_from_codex_resets_api_mode — repro: codex_responses → moa must end in chat_completions
    • test_switch_to_moa_from_chat_completions_keeps_api_mode — regression: chat_completions → moa stays chat_completions
    • test_switch_to_moa_invalidates_transport_cache — transport cache is cleared on the switch
  • S1 (Secrets) — clean
  • S2 (Personal refs) — clean
  • C1 (Conventional commit)fix(agent): ...
  • F1 (Focused) — only agent/agent_runtime_helpers.py and a new test file
  • Compile checkast.parse passes for both files

@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint labels Jun 28, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Already on mainswitch_model pins agent.api_mode = "chat_completions" in the provider == "moa" branch as of #55579, matching agent_init.py. Same fix landed in parallel. Closing #54259 is covered.

@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 type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MoA gateway: primary/acting call resolves to base_url=moa://local -> 404 -> fallback (references + aggregator OK)

3 participants