fix(agent): reset api_mode to chat_completions when switching to MoA (#54259) - #54500
Closed
Sahil-SS9 wants to merge 1 commit into
Closed
fix(agent): reset api_mode to chat_completions when switching to MoA (#54259)#54500Sahil-SS9 wants to merge 1 commit into
Sahil-SS9 wants to merge 1 commit into
Conversation
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #54259
Description
When a session is switched to a MoA preset (via
/moaor a persisted MoA-model session),switch_model()leftagent.api_modeunchanged 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 throughclient.responses.create()against the non-HTTP placeholderbase_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:724already forcesagent.api_mode = "chat_completions"when the provider is MoA. This change applies the same force inside the runtimeswitch_model()path so a session that started on a codex slot and is then switched to a MoA preset reaches a consistent state.Verification
pytest tests/run_agent/test_switch_model_moa_api_mode.py -v: 3 passedtest_switch_to_moa_from_codex_resets_api_mode— repro: codex_responses → moa must end inchat_completionstest_switch_to_moa_from_chat_completions_keeps_api_mode— regression: chat_completions → moa stayschat_completionstest_switch_to_moa_invalidates_transport_cache— transport cache is cleared on the switchfix(agent): ...agent/agent_runtime_helpers.pyand a new test fileast.parsepasses for both files