test_parallel_mixed_tool_calls_with_specific_tool_limit() — langchain Function Reference
Architecture documentation for the test_parallel_mixed_tool_calls_with_specific_tool_limit() function in test_tool_call_limit.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 5c421cef_3edf_dd6a_eab7_ad8e855f9c44["test_parallel_mixed_tool_calls_with_specific_tool_limit()"] a75b8390_08d3_7137_c8a7_9d78fc0c4517["test_tool_call_limit.py"] 5c421cef_3edf_dd6a_eab7_ad8e855f9c44 -->|defined in| a75b8390_08d3_7137_c8a7_9d78fc0c4517 style 5c421cef_3edf_dd6a_eab7_ad8e855f9c44 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 754–817
def test_parallel_mixed_tool_calls_with_specific_tool_limit() -> None:
"""Test parallel calls to different tools when limiting a specific tool.
When limiting 'search' to 1 call, and model proposes 3 search + 2 calculator calls:
- First search call should execute
- Other 2 search calls should be blocked
- All calculator calls should execute (not limited)
"""
@tool
def search(query: str) -> str:
"""Search for information."""
return f"Search: {query}"
@tool
def calculator(expression: str) -> str:
"""Calculate an expression."""
return f"Calc: {expression}"
model = FakeToolCallingModel(
tool_calls=[
[
ToolCall(name="search", args={"query": "q1"}, id="1"),
ToolCall(name="calculator", args={"expression": "1+1"}, id="2"),
ToolCall(name="search", args={"query": "q2"}, id="3"),
ToolCall(name="calculator", args={"expression": "2+2"}, id="4"),
ToolCall(name="search", args={"query": "q3"}, id="5"),
],
[],
]
)
search_limiter = ToolCallLimitMiddleware(
tool_name="search", thread_limit=1, exit_behavior="continue"
)
agent = create_agent(
model=model,
tools=[search, calculator],
middleware=[search_limiter],
checkpointer=InMemorySaver(),
)
result = agent.invoke(
{"messages": [HumanMessage("Test")]}, {"configurable": {"thread_id": "test"}}
)
messages = result["messages"]
search_success = []
search_blocked = []
calc_success = []
for m in messages:
if not isinstance(m, ToolMessage):
continue
assert isinstance(m.content, str)
if "Search:" in m.content:
search_success.append(m)
if "limit" in m.content.lower() and "search" in m.content.lower():
search_blocked.append(m)
if "Calc:" in m.content:
calc_success.append(m)
assert len(search_success) == 1, "Should have 1 successful search call"
assert len(search_blocked) == 2, "Should have 2 blocked search calls"
assert len(calc_success) == 2, "All calculator calls should succeed (not limited)"
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does test_parallel_mixed_tool_calls_with_specific_tool_limit() do?
test_parallel_mixed_tool_calls_with_specific_tool_limit() 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_parallel_mixed_tool_calls_with_specific_tool_limit() defined?
test_parallel_mixed_tool_calls_with_specific_tool_limit() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_tool_call_limit.py at line 754.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free