You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using LangGraph's create_supervisor pattern with multiple worker agents created using create_react_agent. One worker agent (start_order_agent) is responsible for gathering initial order details and has access to a custom tool (search_tires) to query an inventory.
The search_tires tool is defined using the @tool decorator, has an args_schema (SearchTiresInput), and its function signature includes parameters injected by LangGraph, specifically tool_call_id: Annotated[str, InjectedToolCallId].
# Tool Definition Snippet
from typing_extensions import Annotated
from langchain_core.tools.base import InjectedToolCallId
from langchain_core.runnables import RunnableConfig
from langgraph.types import Command
from langchain_core.messages import ToolMessage
# ... other imports
class SearchTiresInput(BaseModel):
tire_size: str = Field(..., description="e.g. '215/55 R17'")
tire_type: str = Field(..., description="ESTIVO/INVERNALE/4 SEASONS")
tire_quantity: int = Field(..., description="2 or 4")
tire_brand: Optional[str] = Field(None, description="e.g. 'Pirelli'")
SEARCH_TIRES_TOOL_DESCRIPTION = """Searches the company's tire inventory stored in a Google Sheet to find available used tires based on customer requirements.
Use this tool ONLY when you have the customer's required tire size (e.g., '215/55 R17'), quantity (MUST be 2 or 4), and type (e.g., 'estive', 'invernali', 'quattro stagioni').
A preferred brand ('tire_brand') can optionally be included, but is NOT required to use the tool.
The tool returns a prioritized list of matching tire options.
Do NOT use this tool for general questions about the company or services."""
@tool(
description=SEARCH_TIRES_TOOL_DESCRIPTION,
args_schema=SearchTiresInput
)
async def search_tires(
tool_call_id: Annotated[str, InjectedToolCallId],
# config: RunnableConfig, # Assuming config might also be injected
**kwargs
) -> Command:
# ... function logic ...
# Returns Command(update={"messages": [ToolMessage(..., tool_call_id=tool_call_id)]})
pass # Simplified for issue description
Problem Description:
When the user provides all required arguments for the search_tires tool (e.g., "Mi servono 2055516 estive 4") and indicates no brand preference (e.g., replies "no" to a question about brand), the start_order_agent should consistently decide to call the search_tires tool with the gathered arguments.
Observed Behavior:
I've observed inconsistent behavior seemingly correlated with the presence of the tool_call_id: Annotated[str, InjectedToolCallId] parameter in the search_tires function definition:
Case 1:
search_tires function defined WITHOUT the tool_call_id parameter:
The start_order_agent correctly identifies the parameters and attempts to call the search_tires tool.
The tool function executes its search logic.
The function then fails at runtime with NameError: name 'tool_call_id' is not defined when trying to construct the ToolMessage (this runtime failure is expected since the variable isn't passed).
Case 2:
search_tires function defined WITH the tool_call_id parameter (as shown in the snippet above):
The start_order_agent gathers the parameters from the conversation.
However, it does not decide to call the search_tires tool.
Instead, it generates a response like "Sorry, I couldn't find matches..." and transfers back to the supervisor, without ever attempting the tool call, despite apparently having the necessary inputs.
I need the result of this tool to be into the state because there are some edge cases where another tool needs to be called in the same turn and to run it is required to have an information that is retrieved only from this search_tires tool.
I'm on LangChain 0.3.24 and LangGraph 0.3.32, Python 3.13.2 and using gpt-4.1 as a model through ChatOpenAI
Hopefully you can help me find a solution. Thanks in advance!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I am using LangGraph's create_supervisor pattern with multiple worker agents created using create_react_agent. One worker agent (start_order_agent) is responsible for gathering initial order details and has access to a custom tool (search_tires) to query an inventory.
The search_tires tool is defined using the @tool decorator, has an args_schema (SearchTiresInput), and its function signature includes parameters injected by LangGraph, specifically tool_call_id: Annotated[str, InjectedToolCallId].
Problem Description:
When the user provides all required arguments for the search_tires tool (e.g., "Mi servono 2055516 estive 4") and indicates no brand preference (e.g., replies "no" to a question about brand), the start_order_agent should consistently decide to call the search_tires tool with the gathered arguments.
Observed Behavior:
I've observed inconsistent behavior seemingly correlated with the presence of the tool_call_id: Annotated[str, InjectedToolCallId] parameter in the search_tires function definition:
Case 1:
search_tires function defined WITHOUT the tool_call_id parameter:
The start_order_agent correctly identifies the parameters and attempts to call the search_tires tool.
The tool function executes its search logic.
The function then fails at runtime with NameError: name 'tool_call_id' is not defined when trying to construct the ToolMessage (this runtime failure is expected since the variable isn't passed).
Case 2:
search_tires function defined WITH the tool_call_id parameter (as shown in the snippet above):
The start_order_agent gathers the parameters from the conversation.
However, it does not decide to call the search_tires tool.
Instead, it generates a response like "Sorry, I couldn't find matches..." and transfers back to the supervisor, without ever attempting the tool call, despite apparently having the necessary inputs.
I need the result of this tool to be into the state because there are some edge cases where another tool needs to be called in the same turn and to run it is required to have an information that is retrieved only from this search_tires tool.
I'm on LangChain 0.3.24 and LangGraph 0.3.32, Python 3.13.2 and using gpt-4.1 as a model through ChatOpenAI
Hopefully you can help me find a solution. Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions