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 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
importasynciofromlangchain_core.toolsimporttoolfromlangchain_openaiimportChatOpenAIfromlanggraph.prebuiltimportcreate_react_agent# Create an intentionally error-prone tool@tooldeferror_prone_tool(input: str) ->str:
"""A tool that always raises an error for demonstration purposes."""return1/0# Set up the agentmodel=ChatOpenAI(model="gpt-4o-mini")
tools= [error_prone_tool]
agent=create_react_agent(model, tools)
asyncdefdemonstrate_issue():
# Stream events to show missing tool_error eventasyncforeventinagent.astream_events(
{"messages": "Please demonstrate a tool error"},
version="v2",
):
print(f"Event type: {event['event']}, Event name: {event['name']} Event data: {event['data']}")
# Notice there's no 'tool_error' event type in the output# This is the issue - when a tool fails, we should get a 'tool_error' event# but currently we don't, making error handling difficultif__name__=="__main__":
asyncio.run(demonstrate_issue())
Error Message and Stack Trace (if applicable)
Description
I am using the create_react_agent method to get all output events through astream_events. I want to get the error event to process and display the error information to the user.
If an error occurs in tool, there will be no on_tool_end event !!!!!
And, I see that the documentation of this method does not mention the error type of event (such as on_tool_error).
Is there any way to do this? If you do not use a custom callback.
OS: Linux
OS Version: langchain-ai/langgraph#1 SMP PREEMPT_DYNAMIC Fri Mar 8 11:32:16 CST 2024
Python Version: 3.11.5 (main, Sep 11 2023, 13:54:46) [GCC 11.2.0]
Package Information
langchain_core: 0.3.46
langsmith: 0.3.18
langchain_mcp_adapters: 0.0.5
langgraph_test: Installed. No version info available.
Optional packages not installed
langserve
Other Dependencies
httpx: 0.28.1
jsonpatch<2.0,>=1.33: Installed. No version info available.
langchain-core<0.4,>=0.3.36: Installed. No version info available.
langsmith-pyo3: Installed. No version info available.
langsmith<0.4,>=0.1.125: Installed. No version info available.
mcp<1.5,>=1.4.1: Installed. No version info available.
openai-agents: Installed. No version info available.
opentelemetry-api: Installed. No version info available.
opentelemetry-exporter-otlp-proto-http: Installed. No version info available.
opentelemetry-sdk: Installed. No version info available.
orjson: 3.10.15
packaging: 24.2
packaging<25,>=23.2: Installed. No version info available.
pydantic: 2.10.6
pydantic<3.0.0,>=2.5.2;: Installed. No version info available.
pydantic<3.0.0,>=2.7.4;: Installed. No version info available.
pytest: 8.3.4
PyYAML>=5.3: Installed. No version info available.
requests: 2.31.0
requests-toolbelt: 1.0.0
rich: Installed. No version info available.
tenacity!=8.4.0,<10.0.0,>=8.1.0: Installed. No version info available.
typing-extensions>=4.7: Installed. No version info available.
zstandard: 0.23.0
The text was updated successfully, but these errors were encountered:
Checked other resources
Example Code
Error Message and Stack Trace (if applicable)
Description
I am using the
create_react_agent
method to get all output events throughastream_events
. I want to get the error event to process and display the error information to the user.If an error occurs in tool, there will be no
on_tool_end
event !!!!!And, I see that the documentation of this method does not mention the
error
type of event (such ason_tool_error
).Is there any way to do this? If you do not use a custom callback.
Here is the output of running:
System Info
System Information
Package Information
Optional packages not installed
Other Dependencies
The text was updated successfully, but these errors were encountered: