Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw an error when both bindTools and withStructuredOutput are used, getting tools attached to an agent #7753

Open
5 tasks done
anilgulecha opened this issue Feb 25, 2025 · 1 comment
Labels
auto:bug Related to a bug, vulnerability, unexpected error with an existing feature

Comments

@anilgulecha
Copy link

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain.js documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain.js rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

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"

@dosubot dosubot bot added the auto:bug Related to a bug, vulnerability, unexpected error with an existing feature label Feb 25, 2025
@benjamincburns
Copy link
Collaborator

Closing in favour of #7757

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:bug Related to a bug, vulnerability, unexpected error with an existing feature
Projects
None yet
Development

No branches or pull requests

2 participants