Throw an error when both bindTools and withStructuredOutput are used, getting tools attached to an agent #7753
Labels
auto:bug
Related to a bug, vulnerability, unexpected error with an existing feature
Checked other resources
Example Code
model.bindTools(tools);
model.withStructuredOutput(schema);
model.invoke([...]) // does not throw Error
Error Message and Stack Trace (if applicable)
No response
Description
I was using the gemini model, and per documentation was using tools, and then was trying to use withStructuredOutput as well.
Things didnt work as expected (and looking at the traces I saw no functions being passed to upstream calls. After much debugging landed on the documentation that called out we can't use both of these together. Discovered the issue via
langchain-ai/langchain#26573.
and
https://langchain-ai.github.io/langgraph/how-tos/react-agent-structured-output/
It would have been helpful if:
There was an error thrown on calling invoke with both bindTools and withStructuredOutput are used on the chat node. If the goal is to allow this to be used for some usecases, then a flag could be passed to invoke to allow.
There seems no way to see what tools are bound to a chat node after calling bindTools. I cannot do chatllm.tools or chatllm.getTools. Documentation also shows nothing to get tools attached to a chat node! This caused frustration when trying to debug the above issue. Can we expose such a method or attribute on a chat model so we can see what are the current tools attached to a model node.
System Info
@langchain/core": "^0.3.39"
@langchain/google-genai": "^0.1.8"
The text was updated successfully, but these errors were encountered: