test_tool_error_event_includes_tool_call_id() — langchain Function Reference
Architecture documentation for the test_tool_error_event_includes_tool_call_id() function in test_runnable_events_v2.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 692ab9f3_e02f_4a2f_7964_2bbddafc17e5["test_tool_error_event_includes_tool_call_id()"] 33c02978_2077_5819_7048_bc2a81e80625["test_runnable_events_v2.py"] 692ab9f3_e02f_4a2f_7964_2bbddafc17e5 -->|defined in| 33c02978_2077_5819_7048_bc2a81e80625 style 692ab9f3_e02f_4a2f_7964_2bbddafc17e5 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/tests/unit_tests/runnables/test_runnable_events_v2.py lines 2842–2879
async def test_tool_error_event_includes_tool_call_id() -> None:
"""Test that on_tool_error event includes tool_call_id when provided."""
@tool
def failing_tool(x: int) -> str: # noqa: ARG001
"""A tool that always fails."""
msg = "Tool execution failed"
raise ValueError(msg)
tool_call_id = "test-tool-call-id-123"
# Invoke the tool with a tool call dict that includes the tool_call_id
tool_call = {
"name": "failing_tool",
"args": {"x": 42},
"id": tool_call_id,
"type": "tool_call",
}
events: list[StreamEvent] = []
# Need to use async for loop to collect events before exception is raised.
# List comprehension would fail entirely when exception occurs.
async def collect_events() -> None:
async for event in failing_tool.astream_events(tool_call, version="v2"):
events.append(event) # noqa: PERF401
with pytest.raises(ValueError, match="Tool execution failed"):
await collect_events()
# Find the on_tool_error event
error_events = [e for e in events if e["event"] == "on_tool_error"]
assert len(error_events) == 1
error_event = error_events[0]
assert error_event["name"] == "failing_tool"
assert "tool_call_id" in error_event["data"]
assert error_event["data"]["tool_call_id"] == tool_call_id
Domain
Subdomains
Source
Frequently Asked Questions
What does test_tool_error_event_includes_tool_call_id() do?
test_tool_error_event_includes_tool_call_id() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/runnables/test_runnable_events_v2.py.
Where is test_tool_error_event_includes_tool_call_id() defined?
test_tool_error_event_includes_tool_call_id() is defined in libs/core/tests/unit_tests/runnables/test_runnable_events_v2.py at line 2842.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free