Stop forwarding agent_tools to the provider in sync invoke - #89
Merged
Conversation
BaseArchytasModel.invoke passed agent_tools through to the underlying LangChain model, which forwards unrecognized kwargs into the provider request. The OpenAI client rejects it: TypeError: Completions.create() got an unexpected keyword argument 'agent_tools' It was forwarded unconditionally, including the default None, so any sync invoke against an OpenAI-compatible provider failed before a request was made. ainvoke already consumed the argument via set_tools; invoke now does the same.
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.
BaseArchytasModel.invokepassedagent_toolsthrough to the underlying LangChain model. LangChain forwards kwargs it does not recognize into the provider request, so it reaches the OpenAI client and raises before any request is made:It was forwarded unconditionally, including the default
None, so any syncinvokeagainst an OpenAI-compatible provider failed regardless of whether tools were passed.ainvokealready consumed the argument viaset_tools;invokenow does the same.Found via beaker-notebook's streamline exporter, which is the sync caller behind its AI notebook export. That export fails on 2.0.6 with the traceback above and works with this change.
Tests: three cases in
tests/test_sync_invoke_agent_tools.pyusing a chat model stub that rejects unknown kwargs the way the OpenAI client does. All three fail onmainwith the TypeError above. The 15test_mcp_tools.pyfailures in my environment are a localmcpversion mismatch and reproduce on unmodifiedmain.🤖 Generated with Claude Code
https://claude.ai/code/session_01555XSwMPRxBZFAEsvubUMz