test_summarization_middleware_many_parallel_tool_calls_safety() — langchain Function Reference
Architecture documentation for the test_summarization_middleware_many_parallel_tool_calls_safety() function in test_summarization.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 5d308ec2_3793_62ee_14a4_c657a3347eb7["test_summarization_middleware_many_parallel_tool_calls_safety()"] 1911a463_b67d_0301_5ef1_5c535dafc14a["test_summarization.py"] 5d308ec2_3793_62ee_14a4_c657a3347eb7 -->|defined in| 1911a463_b67d_0301_5ef1_5c535dafc14a style 5d308ec2_3793_62ee_14a4_c657a3347eb7 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_summarization.py lines 1005–1028
def test_summarization_middleware_many_parallel_tool_calls_safety() -> None:
"""Test cutoff safety preserves AI message with many parallel tool calls."""
middleware = SummarizationMiddleware(
model=MockChatModel(), trigger=("messages", 15), keep=("messages", 5)
)
tool_calls = [{"name": f"tool_{i}", "args": {}, "id": f"call_{i}"} for i in range(10)]
human_message = HumanMessage(content="calling 10 tools")
ai_message = AIMessage(content="calling 10 tools", tool_calls=tool_calls)
tool_messages = [
ToolMessage(content=f"result_{i}", tool_call_id=f"call_{i}") for i in range(10)
]
messages: list[AnyMessage] = [human_message, ai_message, *tool_messages]
# Cutoff at index 7 (a ToolMessage) moves back to index 1 (AIMessage)
# to preserve the AI/Tool pair together
assert middleware._find_safe_cutoff_point(messages, 7) == 1
# Any cutoff pointing at a ToolMessage (indices 2-11) moves back to index 1
for i in range(2, 12):
assert middleware._find_safe_cutoff_point(messages, i) == 1
# Cutoff at index 0, 1 (before tool messages) stays the same
assert middleware._find_safe_cutoff_point(messages, 0) == 0
assert middleware._find_safe_cutoff_point(messages, 1) == 1
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does test_summarization_middleware_many_parallel_tool_calls_safety() do?
test_summarization_middleware_many_parallel_tool_calls_safety() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_summarization.py.
Where is test_summarization_middleware_many_parallel_tool_calls_safety() defined?
test_summarization_middleware_many_parallel_tool_calls_safety() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_summarization.py at line 1005.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free