Agent always calling tool even if not needed #164

Closed
opened 2026-02-20 17:30:01 -05:00 by yindo · 2 comments
Owner

Originally created by @tomaszbk on GitHub (Aug 1, 2024).

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangGraph/LangChain 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 LangGraph/LangChain rather than my code.
  • I am sure this is better as an issue rather than a GitHub discussion, since this is a LangGraph bug and not a design question.

Example Code

result =app.invoke(
   {"messages": [HumanMessage(content="what is your name?")]}, stream_mode=False)

Error Message and Stack Trace (if applicable)

No response

Description

The following prompt that the model receives: "Given the following functions, please respond with a JSON for a function call with its proper arguments that best answers the given prompt.\n\nRespond in the format {"name": function name, "parameters": dictionary of argument name and its value}. Do not use variables." forces the agent to use a tool, even if I just send hello to the agent. It should say "if you require to use a tool" or something to make it optional

System Info

langchain==0.2.11
langchain-community==0.2.10
langchain-core==0.2.24
langchain-experimental==0.0.63
langchain-ollama==0.1.0
langchain-text-splitters==0.2.2
langchainhub==0.1.20
Windows
python 3.11.7

Originally created by @tomaszbk on GitHub (Aug 1, 2024). ### Checked other resources - [X] I added a very descriptive title to this issue. - [X] I searched the [LangGraph](https://langchain-ai.github.io/langgraph/)/LangChain documentation with the integrated search. - [X] I used the GitHub search to find a similar question and didn't find it. - [X] I am sure that this is a bug in LangGraph/LangChain rather than my code. - [X] I am sure this is better as an issue [rather than a GitHub discussion](https://github.com/langchain-ai/langgraph/discussions/new/choose), since this is a LangGraph bug and not a design question. ### Example Code ```python result =app.invoke( {"messages": [HumanMessage(content="what is your name?")]}, stream_mode=False) ``` ### Error Message and Stack Trace (if applicable) _No response_ ### Description The following prompt that the model receives: "Given the following functions, please respond with a JSON for a function call with its proper arguments that best answers the given prompt.\n\nRespond in the format {\"name\": function name, \"parameters\": dictionary of argument name and its value}. Do not use variables." forces the agent to use a tool, even if I just send hello to the agent. It should say "if you require to use a tool" or something to make it optional ### System Info langchain==0.2.11 langchain-community==0.2.10 langchain-core==0.2.24 langchain-experimental==0.0.63 langchain-ollama==0.1.0 langchain-text-splitters==0.2.2 langchainhub==0.1.20 Windows python 3.11.7
yindo closed this issue 2026-02-20 17:30:01 -05:00
Author
Owner

@hwchase17 commented on GitHub (Aug 1, 2024):

this seems like a prompting issue and not anything related to langgraph? where are you getting that prompt from? we dont have any built in prompts

@hwchase17 commented on GitHub (Aug 1, 2024): this seems like a prompting issue and not anything related to langgraph? where are you getting that prompt from? we dont have any built in prompts
Author
Owner

@tomaszbk commented on GitHub (Aug 1, 2024):

I checked the internals and you were right, I htink it is ollama that adds that so you could use tools with it

@tomaszbk commented on GitHub (Aug 1, 2024): I checked the internals and you were right, I htink it is ollama that adds that so you could use tools with it
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#164