fix(agent): strip _moa_prepared_request before dispatching to native client (#78382) - #80132
Closed
RelaxJonh wants to merge 1 commit into
Closed
fix(agent): strip _moa_prepared_request before dispatching to native client (#78382)#80132RelaxJonh wants to merge 1 commit into
RelaxJonh wants to merge 1 commit into
Conversation
…client After a client replacement (credential rotation, dead-connection cleanup, or fallback+restore), agent.client may become a native OpenAI client while agent.provider stays "moa". The _moa_prepared_request key was passed through to the native SDK, causing TypeError on every turn. Pop the key at the dispatch point (chat_completion_helpers.py:509). The MoAClient facade already handles a missing key by falling through to its normal resolution path. Closes NousResearch#78382
Collaborator
Contributor
|
Thanks! Your dispatch-point strip and regression test were cherry-picked into #83088 with your authorship preserved in git history. One note: we gated the pop on a facade-capability probe, because the unconditional pop also stripped the handshake from the live MoA facade, forcing a duplicate reference fan-out (caught by the existing aggregator-actor test). Closing as superseded by #83088. |
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.
Summary
After a client replacement (credential rotation, dead-connection cleanup, or fallback+restore via
_replace_primary_openai_client),agent.clientbecomes a native OpenAI client whileagent.providerstays"moa". The_moa_prepared_requestkey was passed through to the native SDK atchat_completion_helpers.py:509, causingTypeError: Completions.create() got an unexpected keyword argument _moa_prepared_requeston every turn.Fix
Pop
_moa_prepared_requestfromapi_kwargsat the dispatch point before callingagent.client.chat.completions.create(). TheMoAClient.create()facade already handles a missing key by falling through to its normal resolution path (moa_loop.py:1852), so the fix is safe for both the real facade and replaced native clients.Test
test_moa_key_stripped_from_native_client— verifies the key is removed before reaching a native clienttest_no_moa_key_when_absent— verifies normal non-MoA calls work without the keyRoot cause
conversation_loop.py:2326-2327injects_moa_prepared_requestintoapi_kwargswhenagent.provider == "moa". After client replacement, the provider stays "moa" but the client is native — the key leaks through.Closes #78382