Langgraph did not call tools #507

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

Originally created by @swarnitwayal on GitHub (Mar 12, 2025).

Checked other resources

  • This is a bug, not a usage question. For questions, please use GitHub Discussions.
  • I added a clear and detailed title that summarizes the issue.
  • I read what a minimal reproducible example is (https://stackoverflow.com/help/minimal-reproducible-example).
  • I included a self-contained, minimal example that demonstrates the issue INCLUDING all the relevant imports. The code run AS IS to reproduce the issue.

Example Code

from datetime import datetime
from langchain_openai import ChatOpenAI
from langgraph.prebuilt import create_react_agent
from config import BASE_URL, API_TOKEN, APPLICATION_TYPE_HEADER

class CustomLLM(ChatOpenAI):
    def __init__(self, api_token: str, base_url: str, application_type: str, **kwargs):
        default_headers = {
            "applicationType": application_type,  # This is the header you want to include
        }
        super().__init__( model='gpt-4o', openai_api_base=base_url, openai_api_key=api_token, default_headers=default_headers, **kwargs)

def check_weather(location: str, at_time: datetime | None = None) -> str:
	'''Return the weather forecast for the specified location.'''
	return f"It's always sunny in {location}"

tools = [check_weather]
model = CustomLLM(base_url=BASE_URL, api_token=API_TOKEN, application_type=APPLICATION_TYPE_HEADER)

graph = create_react_agent(model, tools)
inputs = {"messages": [("user", "what is the weather in sf")]}

for s in graph.stream(inputs, stream_mode="values"):
	message = s["messages"][-1]
	if isinstance(message, tuple):
		print(message)
	else:
		message.pretty_print()

Error Message and Stack Trace (if applicable)

(.venv) PS C:\Repositories\Langgraph-latest> & c:/Repositories/Langgraph-latest/.venv/Scripts/python.exe c:/Repositories/Langgraph-latest/weather_botv3.py
================================ Human Message =================================

what is the weather in sf
================================== Ai Message ==================================

I'm sorry, I do not have real-time information on current weather conditions. I recommend checking a weather website or app for the most up-to-date weather forecast for San Francisco.

Description

I see that LLM doesn't make any tool calls with above code example.

System Info

System Windows:

langchain==0.3.20
langchain-core==0.3.44
langchain-openai==0.3.8
langchain-text-splitters==0.3.6
langgraph==0.3.7
langgraph-checkpoint==2.0.18
langgraph-prebuilt==0.1.2
langgraph-sdk==0.1.55
langsmith==0.3.13

Python 3.12.9

Originally created by @swarnitwayal on GitHub (Mar 12, 2025). ### Checked other resources - [x] This is a bug, not a usage question. For questions, please use GitHub Discussions. - [x] I added a clear and detailed title that summarizes the issue. - [x] I read what a minimal reproducible example is (https://stackoverflow.com/help/minimal-reproducible-example). - [x] I included a self-contained, minimal example that demonstrates the issue INCLUDING all the relevant imports. The code run AS IS to reproduce the issue. ### Example Code ```python from datetime import datetime from langchain_openai import ChatOpenAI from langgraph.prebuilt import create_react_agent from config import BASE_URL, API_TOKEN, APPLICATION_TYPE_HEADER class CustomLLM(ChatOpenAI): def __init__(self, api_token: str, base_url: str, application_type: str, **kwargs): default_headers = { "applicationType": application_type, # This is the header you want to include } super().__init__( model='gpt-4o', openai_api_base=base_url, openai_api_key=api_token, default_headers=default_headers, **kwargs) def check_weather(location: str, at_time: datetime | None = None) -> str: '''Return the weather forecast for the specified location.''' return f"It's always sunny in {location}" tools = [check_weather] model = CustomLLM(base_url=BASE_URL, api_token=API_TOKEN, application_type=APPLICATION_TYPE_HEADER) graph = create_react_agent(model, tools) inputs = {"messages": [("user", "what is the weather in sf")]} for s in graph.stream(inputs, stream_mode="values"): message = s["messages"][-1] if isinstance(message, tuple): print(message) else: message.pretty_print() ``` ### Error Message and Stack Trace (if applicable) ```shell (.venv) PS C:\Repositories\Langgraph-latest> & c:/Repositories/Langgraph-latest/.venv/Scripts/python.exe c:/Repositories/Langgraph-latest/weather_botv3.py ================================ Human Message ================================= what is the weather in sf ================================== Ai Message ================================== I'm sorry, I do not have real-time information on current weather conditions. I recommend checking a weather website or app for the most up-to-date weather forecast for San Francisco. ``` ### Description I see that LLM doesn't make any tool calls with above code example. ### System Info System Windows: langchain==0.3.20 langchain-core==0.3.44 langchain-openai==0.3.8 langchain-text-splitters==0.3.6 langgraph==0.3.7 langgraph-checkpoint==2.0.18 langgraph-prebuilt==0.1.2 langgraph-sdk==0.1.55 langsmith==0.3.13 Python 3.12.9
yindo closed this issue 2026-02-20 17:40:28 -05:00
Author
Owner

@hinthornw commented on GitHub (Mar 12, 2025):

Hiya - your model isn't using its tools effectively. If i replace with a regular openai, gemini, or anthropic model here it works as expected.

Does your model gateway (or whatever you're connecting to there) support the tools arguments in the API?

(In other words, this doesn't appear to be an issue with langgraph)

@hinthornw commented on GitHub (Mar 12, 2025): Hiya - your model isn't using its tools effectively. If i replace with a regular openai, gemini, or anthropic model here it works as expected. Does your model gateway (or whatever you're connecting to there) support the `tools` arguments in the API? (In other words, this doesn't appear to be an issue with langgraph)
Author
Owner

@hinthornw commented on GitHub (Mar 12, 2025):

Will convert this to a discussion, as this is not a langgraph bug.

@hinthornw commented on GitHub (Mar 12, 2025): Will convert this to a discussion, as this is not a langgraph bug.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#507