fix(AIC-3506): strip tools from LangChain model constructor kwargs - #133
Open
andrewklatzke wants to merge 1 commit into
Open
andrewklatzke wants to merge 1 commit into
andrewklatzke wants to merge 1 commit into
Conversation
Tools in model.parameters are forwarded raw and rejected by the provider API. They are already bound from the top-level tools field.
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.
Human explanation:
Strips
model.parameter.toolsoff of Langchain handlers so they don't get splatted into the kwargs.model.parameters.toolsis a copy of the existingtoolsleft in for backwards compatibility.AI explanation:
Tools in model.parameters are forwarded raw and rejected by the provider API. They are already bound from the top-level tools field.
Note
Overview
Strips
toolsfrom LangChain chat model constructor kwargs everywhere default models are built, not only on Bedrock.model.parameters.toolsis a backwards-compat mirror of top-levelconfig["tools"]. Forwarding it intoChatOpenAI/ChatAnthropic/ChatBedrockConversecaused provider errors because tools are already bound viabind_tools/ agent setup._model_constructor_kwargsin langchain-agents and langchain-messages now alwayspop("tools"); native_graph does the same for the default per-nodeChatOpenAIpath.Tests assert constructors receive temperature, max_tokens, and model name only—no
toolsin the kwargs bag.Reviewed by Cursor Bugbot for commit 2e31f0e. Bugbot is set up for automated code reviews on this repo. Configure here.