Home / Function/ test_tool_error_event_tool_call_id_is_none_when_not_provided() — langchain Function Reference

test_tool_error_event_tool_call_id_is_none_when_not_provided() — langchain Function Reference

Architecture documentation for the test_tool_error_event_tool_call_id_is_none_when_not_provided() function in test_runnable_events_v2.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  e1beae2f_625c_35c0_d464_17d3b46791c3["test_tool_error_event_tool_call_id_is_none_when_not_provided()"]
  33c02978_2077_5819_7048_bc2a81e80625["test_runnable_events_v2.py"]
  e1beae2f_625c_35c0_d464_17d3b46791c3 -->|defined in| 33c02978_2077_5819_7048_bc2a81e80625
  style e1beae2f_625c_35c0_d464_17d3b46791c3 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/runnables/test_runnable_events_v2.py lines 2882–2910

async def test_tool_error_event_tool_call_id_is_none_when_not_provided() -> None:
    """Test that on_tool_error event has tool_call_id=None when not provided."""

    @tool
    def failing_tool_no_id(x: int) -> str:  # noqa: ARG001
        """A tool that always fails."""
        msg = "Tool execution failed"
        raise ValueError(msg)

    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_no_id.astream_events({"x": 42}, version="v2"):
            events.append(event)  # noqa: PERF401

    # Invoke the tool without a tool_call_id (regular dict input)
    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_no_id"
    assert "tool_call_id" in error_event["data"]
    assert error_event["data"]["tool_call_id"] is None

Domain

Subdomains

Frequently Asked Questions

What does test_tool_error_event_tool_call_id_is_none_when_not_provided() do?
test_tool_error_event_tool_call_id_is_none_when_not_provided() 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_tool_call_id_is_none_when_not_provided() defined?
test_tool_error_event_tool_call_id_is_none_when_not_provided() is defined in libs/core/tests/unit_tests/runnables/test_runnable_events_v2.py at line 2882.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free