React agent returns empty response #999

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

Originally created by @ndhuy4 on GitHub (Oct 3, 2025).

Checked other resources

  • This is a bug, not a usage question. For questions, please use the LangChain Forum (https://forum.langchain.com/).
  • 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 langgraph.prebuilt import create_react_agent
from datetime import datetime
from zoneinfo import ZoneInfo
from enum import StrEnum
from typing import Annotated, Literal
import httpx
from langchain_openai import ChatOpenAI
from langchain_google_genai import ChatGoogleGenerativeAI
from langchain_openai import ChatOpenAI



class StatusCategory(StrEnum):
    DONE = "Done"
    TODO = "To Do"
    IN_PROGRESS = "In Progress"
    IN_REVIEW = "In Review"

class Priority(StrEnum):
    LOW = "Low"
    MEDIUM = "Medium"
    HIGH = "High"
    URGENT = "Urgent"


model = ChatGoogleGenerativeAI(
      model="gemini-2.5-flash-lite",
      api_key=google_api_key,
      temperature=0.9,
      max_retries=2,
  )

# model =ChatOpenAI(
#      model="gpt-4o-mini",
#      api_key=openai_api_key,
#      temperature=0.9,
#      max_retries=2,
# )

async def update_task_status(
    task_key: str,
    status: Literal[StatusCategory.TODO, StatusCategory.IN_PROGRESS, StatusCategory.IN_REVIEW, StatusCategory.DONE],
):
    """
    Update the status of a specific task.

    Args:
        task_key (str): The name of the task to update.
        status (str): The new status to set for the task.
    """
    return "successful"

async def update_task_priority(
  task_key: str,
  priority: Literal[Priority.LOW, Priority.MEDIUM, Priority.HIGH, Priority.URGENT],                           
):
    """
    Update the priority of a specific task.

    Args:
        task_key (str): The name of the task to update.
        priority (str): The new priority level to set for the task.
    """
    return "successful"

AGENT_CRUD_PROMPT = """
# Identity

You are a CRUD Assistant, designed to help the Project Manager create, update, or delete tasks based on their requests.
Current time is: {current_time}

# CRITICAL INSTRUCTION 
* You must always reply in {last_user_message_language}"""


tz = ZoneInfo("Asia/Ho_Chi_Minh")
prompt = AGENT_CRUD_PROMPT.format(
            current_time=datetime.now(tz).strftime("%A, %Y-%m-%d %H:%M:%S"),
            last_user_message_language="vietnamese",
        )

agent = create_react_agent(
    model=model,  
    tools=[update_task_status, update_task_priority],  
    prompt=prompt
)
response = await agent.ainvoke(
    {"messages": [{"role": "user", "content": "update status of task P1-10 in project1-1 to In Progress and priority to Urgent"}]},
)

Error Message and Stack Trace (if applicable)

AIMessage(content='', additional_kwargs={}, response_metadata={'prompt_feedback': {'block_reason': 0, 'safety_ratings': []}, 'finish_reason': 'STOP', 'model_name': 'gemini-2.5-flash-lite', 'safety_ratings': []}, id='run--f2380282-040d-4acd-b5ef-449b8bc7c159-0', usage_metadata={'input_tokens': 402, 'output_tokens': 0, 'total_tokens': 402, 'input_token_details': {'cache_read': 0}})

Description

I tried running the same code with both Gemini and OpenAI (GPT-4o family). In most cases, the agent returns an empty response instead of the expected output. This makes it difficult to determine whether the issue is in the code, the agent setup, or the model integration.

langgraph=0.6.8
langchain-google-genai=2.1.12
langchain-openai=0.3.34

System Info

Run in a .ipynb file

Originally created by @ndhuy4 on GitHub (Oct 3, 2025). ### Checked other resources - [x] This is a bug, not a usage question. For questions, please use the LangChain Forum (https://forum.langchain.com/). - [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 langgraph.prebuilt import create_react_agent from datetime import datetime from zoneinfo import ZoneInfo from enum import StrEnum from typing import Annotated, Literal import httpx from langchain_openai import ChatOpenAI from langchain_google_genai import ChatGoogleGenerativeAI from langchain_openai import ChatOpenAI class StatusCategory(StrEnum): DONE = "Done" TODO = "To Do" IN_PROGRESS = "In Progress" IN_REVIEW = "In Review" class Priority(StrEnum): LOW = "Low" MEDIUM = "Medium" HIGH = "High" URGENT = "Urgent" model = ChatGoogleGenerativeAI( model="gemini-2.5-flash-lite", api_key=google_api_key, temperature=0.9, max_retries=2, ) # model =ChatOpenAI( # model="gpt-4o-mini", # api_key=openai_api_key, # temperature=0.9, # max_retries=2, # ) async def update_task_status( task_key: str, status: Literal[StatusCategory.TODO, StatusCategory.IN_PROGRESS, StatusCategory.IN_REVIEW, StatusCategory.DONE], ): """ Update the status of a specific task. Args: task_key (str): The name of the task to update. status (str): The new status to set for the task. """ return "successful" async def update_task_priority( task_key: str, priority: Literal[Priority.LOW, Priority.MEDIUM, Priority.HIGH, Priority.URGENT], ): """ Update the priority of a specific task. Args: task_key (str): The name of the task to update. priority (str): The new priority level to set for the task. """ return "successful" AGENT_CRUD_PROMPT = """ # Identity You are a CRUD Assistant, designed to help the Project Manager create, update, or delete tasks based on their requests. Current time is: {current_time} # CRITICAL INSTRUCTION * You must always reply in {last_user_message_language}""" tz = ZoneInfo("Asia/Ho_Chi_Minh") prompt = AGENT_CRUD_PROMPT.format( current_time=datetime.now(tz).strftime("%A, %Y-%m-%d %H:%M:%S"), last_user_message_language="vietnamese", ) agent = create_react_agent( model=model, tools=[update_task_status, update_task_priority], prompt=prompt ) response = await agent.ainvoke( {"messages": [{"role": "user", "content": "update status of task P1-10 in project1-1 to In Progress and priority to Urgent"}]}, ) ``` ### Error Message and Stack Trace (if applicable) ```shell AIMessage(content='', additional_kwargs={}, response_metadata={'prompt_feedback': {'block_reason': 0, 'safety_ratings': []}, 'finish_reason': 'STOP', 'model_name': 'gemini-2.5-flash-lite', 'safety_ratings': []}, id='run--f2380282-040d-4acd-b5ef-449b8bc7c159-0', usage_metadata={'input_tokens': 402, 'output_tokens': 0, 'total_tokens': 402, 'input_token_details': {'cache_read': 0}}) ``` ### Description I tried running the same code with both Gemini and OpenAI (GPT-4o family). In most cases, the agent returns an empty response instead of the expected output. This makes it difficult to determine whether the issue is in the code, the agent setup, or the model integration. langgraph=0.6.8 langchain-google-genai=2.1.12 langchain-openai=0.3.34 ### System Info Run in a .ipynb file
yindo added the bugpending labels 2026-02-20 17:42:40 -05:00
yindo closed this issue 2026-02-20 17:42:40 -05:00
Author
Owner

@keenborder786 commented on GitHub (Oct 4, 2025):


from langgraph.prebuilt import create_react_agent
from datetime import datetime
from zoneinfo import ZoneInfo
from enum import StrEnum
from typing import Annotated, Literal
import httpx
from langchain_openai import ChatOpenAI



class StatusCategory(StrEnum):
    DONE = "Done"
    TODO = "To Do"
    IN_PROGRESS = "In Progress"
    IN_REVIEW = "In Review"

class Priority(StrEnum):
    LOW = "Low"
    MEDIUM = "Medium"
    HIGH = "High"
    URGENT = "Urgent"



model =ChatOpenAI(
     model="gpt-4o-mini",
     temperature=0.9,
     max_retries=2,
)

def update_task_status(
    task_key: str,
    status: Literal[StatusCategory.TODO, StatusCategory.IN_PROGRESS, StatusCategory.IN_REVIEW, StatusCategory.DONE],
):
    """
    Update the status of a specific task.

    Args:
        task_key (str): The name of the task to update.
        status (str): The new status to set for the task.
    """
    return "successful"

def update_task_priority(
  task_key: str,
  priority: Literal[Priority.LOW, Priority.MEDIUM, Priority.HIGH, Priority.URGENT],                           
):
    """
    Update the priority of a specific task.

    Args:
        task_key (str): The name of the task to update.
        priority (str): The new priority level to set for the task.
    """
    return "successful"

AGENT_CRUD_PROMPT = """
# Identity

You are a CRUD Assistant, designed to help the Project Manager create, update, or delete tasks based on their requests.
Current time is: {current_time}

# CRITICAL INSTRUCTION 
* You must always reply in {last_user_message_language}"""


tz = ZoneInfo("Asia/Ho_Chi_Minh")
prompt = AGENT_CRUD_PROMPT.format(
            current_time=datetime.now(tz).strftime("%A, %Y-%m-%d %H:%M:%S"),
            last_user_message_language="vietnamese",
        )

agent = create_react_agent(
    model=model,  
    tools=[update_task_status, update_task_priority],  
    prompt=prompt
)
response = agent.invoke(
    {"messages": [{"role": "user", "content": "update status of task P1-10 in project1-1 to In Progress and priority to Urgent"}]},
)
print(response["messages"][-1])

Please see the last message and you will be able to see the response.

@keenborder786 commented on GitHub (Oct 4, 2025): ```python from langgraph.prebuilt import create_react_agent from datetime import datetime from zoneinfo import ZoneInfo from enum import StrEnum from typing import Annotated, Literal import httpx from langchain_openai import ChatOpenAI class StatusCategory(StrEnum): DONE = "Done" TODO = "To Do" IN_PROGRESS = "In Progress" IN_REVIEW = "In Review" class Priority(StrEnum): LOW = "Low" MEDIUM = "Medium" HIGH = "High" URGENT = "Urgent" model =ChatOpenAI( model="gpt-4o-mini", temperature=0.9, max_retries=2, ) def update_task_status( task_key: str, status: Literal[StatusCategory.TODO, StatusCategory.IN_PROGRESS, StatusCategory.IN_REVIEW, StatusCategory.DONE], ): """ Update the status of a specific task. Args: task_key (str): The name of the task to update. status (str): The new status to set for the task. """ return "successful" def update_task_priority( task_key: str, priority: Literal[Priority.LOW, Priority.MEDIUM, Priority.HIGH, Priority.URGENT], ): """ Update the priority of a specific task. Args: task_key (str): The name of the task to update. priority (str): The new priority level to set for the task. """ return "successful" AGENT_CRUD_PROMPT = """ # Identity You are a CRUD Assistant, designed to help the Project Manager create, update, or delete tasks based on their requests. Current time is: {current_time} # CRITICAL INSTRUCTION * You must always reply in {last_user_message_language}""" tz = ZoneInfo("Asia/Ho_Chi_Minh") prompt = AGENT_CRUD_PROMPT.format( current_time=datetime.now(tz).strftime("%A, %Y-%m-%d %H:%M:%S"), last_user_message_language="vietnamese", ) agent = create_react_agent( model=model, tools=[update_task_status, update_task_priority], prompt=prompt ) response = agent.invoke( {"messages": [{"role": "user", "content": "update status of task P1-10 in project1-1 to In Progress and priority to Urgent"}]}, ) print(response["messages"][-1]) ``` Please see the last message and you will be able to see the response.
Author
Owner

@ndhuy4 commented on GitHub (Oct 6, 2025):

This is the full message log:

{'messages': [HumanMessage(content='update status of task P1-10 in project1-1 to In Progress and priority to Urgent', additional_kwargs={}, response_metadata={}, id='eb3a9165-0870-4d69-a3c2-f7f3a765dc1b'),
AIMessage(content='', additional_kwargs={'function_call': {'name': 'update_task_priority', 'arguments': '{"priority": "Urgent", "task_key": "P1-10"}'}}, response_metadata={'prompt_feedback': {'block_reason': 0, 'safety_ratings': []}, 'finish_reason': 'STOP', 'model_name': 'gemini-2.5-flash-lite', 'safety_ratings': []}, id='run--84369068-3c24-40be-8966-6a16eb326ded-0', tool_calls=[{'name': 'update_task_status', 'args': {'status': 'In Progress', 'task_key': 'P1-10'}, 'id': '2cec417f-aa7f-484b-8550-09dd30d0fc1c', 'type': 'tool_call'}, {'name': 'update_task_priority', 'args': {'priority': 'Urgent', 'task_key': 'P1-10'}, 'id': '4a91f022-c32b-4c83-ac7a-c8e921d5e988', 'type': 'tool_call'}], usage_metadata={'input_tokens': 304, 'output_tokens': 58, 'total_tokens': 362, 'input_token_details': {'cache_read': 0}}),
ToolMessage(content='successful', name='update_task_status', id='2330b952-3194-439c-ba24-b238f17560ce', tool_call_id='2cec417f-aa7f-484b-8550-09dd30d0fc1c'),
ToolMessage(content='successful', name='update_task_priority', id='3f3b366d-01ae-4651-841e-0babc5187b8c', tool_call_id='4a91f022-c32b-4c83-ac7a-c8e921d5e988'),
AIMessage(content='', additional_kwargs={}, response_metadata={'prompt_feedback': {'block_reason': 0, 'safety_ratings': []}, 'finish_reason': 'STOP', 'model_name': 'gemini-2.5-flash-lite', 'safety_ratings': []}, id='run--6f5dafac-3b2b-424e-95f1-467e409cf4f9-0', usage_metadata={'input_tokens': 394, 'output_tokens': 0, 'total_tokens': 394, 'input_token_details': {'cache_read': 0}})]}

Now, it only happens with Gemini-2.5-flash-lite when running the code 3–5 times, while the same code works fine with GPT-4o. (Although a few weeks ago, GPT-4o also occasionally returned empty responses.)

I think the issue is related to the model provider. Thank you @keenborder786

@ndhuy4 commented on GitHub (Oct 6, 2025): This is the full message log: > {'messages': [HumanMessage(content='update status of task P1-10 in project1-1 to In Progress and priority to Urgent', additional_kwargs={}, response_metadata={}, id='eb3a9165-0870-4d69-a3c2-f7f3a765dc1b'), AIMessage(content='', additional_kwargs={'function_call': {'name': 'update_task_priority', 'arguments': '{"priority": "Urgent", "task_key": "P1-10"}'}}, response_metadata={'prompt_feedback': {'block_reason': 0, 'safety_ratings': []}, 'finish_reason': 'STOP', 'model_name': 'gemini-2.5-flash-lite', 'safety_ratings': []}, id='run--84369068-3c24-40be-8966-6a16eb326ded-0', tool_calls=[{'name': 'update_task_status', 'args': {'status': 'In Progress', 'task_key': 'P1-10'}, 'id': '2cec417f-aa7f-484b-8550-09dd30d0fc1c', 'type': 'tool_call'}, {'name': 'update_task_priority', 'args': {'priority': 'Urgent', 'task_key': 'P1-10'}, 'id': '4a91f022-c32b-4c83-ac7a-c8e921d5e988', 'type': 'tool_call'}], usage_metadata={'input_tokens': 304, 'output_tokens': 58, 'total_tokens': 362, 'input_token_details': {'cache_read': 0}}), ToolMessage(content='successful', name='update_task_status', id='2330b952-3194-439c-ba24-b238f17560ce', tool_call_id='2cec417f-aa7f-484b-8550-09dd30d0fc1c'), ToolMessage(content='successful', name='update_task_priority', id='3f3b366d-01ae-4651-841e-0babc5187b8c', tool_call_id='4a91f022-c32b-4c83-ac7a-c8e921d5e988'), AIMessage(content='', additional_kwargs={}, response_metadata={'prompt_feedback': {'block_reason': 0, 'safety_ratings': []}, 'finish_reason': 'STOP', 'model_name': 'gemini-2.5-flash-lite', 'safety_ratings': []}, id='run--6f5dafac-3b2b-424e-95f1-467e409cf4f9-0', usage_metadata={'input_tokens': 394, 'output_tokens': 0, 'total_tokens': 394, 'input_token_details': {'cache_read': 0}})]} Now, it only happens with Gemini-2.5-flash-lite when running the code 3–5 times, while the same code works fine with GPT-4o. (Although a few weeks ago, GPT-4o also occasionally returned empty responses.) I think the issue is related to the model provider. Thank you @keenborder786
Author
Owner

@langchain-infra commented on GitHub (Oct 29, 2025):

@ndhuy4 It looks like you may have leaked a google API key starting with AIzaSyBCAP. Please make sure to revoke this key as it still remains in git history.

@langchain-infra commented on GitHub (Oct 29, 2025): @ndhuy4 It looks like you may have leaked a google API key starting with `AIzaSyBCAP`. Please make sure to revoke this key as it still remains in git history.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#999