Repository navigation
fix(AIC-3506): strip tools from LangChain model constructor kwargs - #110
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.
jeffdupont
left a comment
There was a problem hiding this comment.
I think this can be closed. js #73 already fixed it on main.
At 993225f, both LangChain handlers and the native graph build their constructor options with modelConstructorParameters (model-parameters.ts:129-145). That keeps only the per-model-class *_FORWARDED_KEYS, and tools is not on any of them. I probed it on main. With { temperature: 0.2, tools: [...] }, tools is dropped for openai, anthropic and bedrock in both langchain-messages and langchain-agents, and temperature comes through. Flipping the assertion fails all six cases, so the probe is testing the real behaviour.
main also has a regression test for this: model-parameters.test.ts:15 in both packages puts tools in the smuggled bag. This PR now conflicts with main in those same files, and the delete parameters.tools lines have nothing left to change.
The Python twin, py #133, is still needed. Python main still forwards tools to ChatOpenAI and ChatAnthropic, and I've approved it there.
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
Stops
toolsinmodel.parametersfrom being passed into LangChain chat model constructors (ChatOpenAI,ChatAnthropic,ChatBedrockConverse), which was causing provider APIs to reject requests. Tooling stays on the existingconfig.toolspath (bindTools, agentcreateAgent, graphToolNode).modelConstructorArgsin bothlangchain-agentsandlangchain-messageshandlers now always stripsparameters.tools(previously only Bedrock). The defaultChatOpenAIfactory innative-graphapplies the same rule when spreading nodemodel.parameters. Docs/comments note thatmodel.parameters.toolsmay still exist for backwards compatibility but must not be forwarded as constructor kwargs.Tests assert OpenAI/Bedrock constructors receive temperature and model name only—not a
toolskey—even whenmodel.parameters.toolsis set.Reviewed by Cursor Bugbot for commit 220b40b. Bugbot is set up for automated code reviews on this repo. Configure here.