Home / Function/ test_middleware_end_behavior_with_unrelated_parallel_tool_calls() — langchain Function Reference

test_middleware_end_behavior_with_unrelated_parallel_tool_calls() — langchain Function Reference

Architecture documentation for the test_middleware_end_behavior_with_unrelated_parallel_tool_calls() function in test_tool_call_limit.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  53531447_d9eb_53d4_6b76_e88fd9587a30["test_middleware_end_behavior_with_unrelated_parallel_tool_calls()"]
  a75b8390_08d3_7137_c8a7_9d78fc0c4517["test_tool_call_limit.py"]
  53531447_d9eb_53d4_6b76_e88fd9587a30 -->|defined in| a75b8390_08d3_7137_c8a7_9d78fc0c4517
  style 53531447_d9eb_53d4_6b76_e88fd9587a30 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_tool_call_limit.py lines 161–193

def test_middleware_end_behavior_with_unrelated_parallel_tool_calls() -> None:
    """Test middleware 'end' behavior with unrelated parallel tool calls.

    Test that 'end' behavior raises NotImplementedError when there are parallel calls
    to unrelated tools.

    When limiting a specific tool with "end" behavior and the model proposes parallel calls
    to BOTH the limited tool AND other tools, we can't handle this scenario (we'd be stopping
    execution while other tools should run).
    """
    # Limit search tool specifically
    middleware = ToolCallLimitMiddleware(tool_name="search", thread_limit=1, exit_behavior="end")
    runtime = None

    # Test with search + calculator calls when search exceeds limit
    state = ToolCallLimitState(
        messages=[
            AIMessage(
                "Response",
                tool_calls=[
                    {"name": "search", "args": {}, "id": "1"},
                    {"name": "calculator", "args": {}, "id": "2"},
                ],
            ),
        ],
        thread_tool_call_count={"search": 1},
        run_tool_call_count={"search": 1},
    )

    with pytest.raises(
        NotImplementedError, match="Cannot end execution with other tool calls pending"
    ):
        middleware.after_model(state, runtime)  # type: ignore[arg-type]

Domain

Subdomains

Frequently Asked Questions

What does test_middleware_end_behavior_with_unrelated_parallel_tool_calls() do?
test_middleware_end_behavior_with_unrelated_parallel_tool_calls() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_tool_call_limit.py.
Where is test_middleware_end_behavior_with_unrelated_parallel_tool_calls() defined?
test_middleware_end_behavior_with_unrelated_parallel_tool_calls() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_tool_call_limit.py at line 161.

Analyze Your Own Codebase

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

Try Supermodel Free