test_tool_runtime_parallel_execution() — langchain Function Reference
Architecture documentation for the test_tool_runtime_parallel_execution() function in test_injected_runtime_create_agent.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 9bfec252_0022_2873_d174_df7361ff5dea["test_tool_runtime_parallel_execution()"] a4d83fe9_0a39_5761_b1a5_de54f81974c9["test_injected_runtime_create_agent.py"] 9bfec252_0022_2873_d174_df7361ff5dea -->|defined in| a4d83fe9_0a39_5761_b1a5_de54f81974c9 style 9bfec252_0022_2873_d174_df7361ff5dea fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain_v1/tests/unit_tests/agents/test_injected_runtime_create_agent.py lines 366–411
async def test_tool_runtime_parallel_execution() -> None:
"""Test ToolRuntime injection works with parallel tool execution."""
execution_log = []
@tool
async def parallel_tool_1(x: int, runtime: ToolRuntime) -> str:
"""First parallel tool."""
execution_log.append(("tool_1", runtime.tool_call_id, x))
return f"Tool1: {x}"
@tool
async def parallel_tool_2(y: int, runtime: ToolRuntime) -> str:
"""Second parallel tool."""
execution_log.append(("tool_2", runtime.tool_call_id, y))
return f"Tool2: {y}"
agent = create_agent(
model=FakeToolCallingModel(
tool_calls=[
[
{"args": {"x": 10}, "id": "parallel_1", "name": "parallel_tool_1"},
{"args": {"y": 20}, "id": "parallel_2", "name": "parallel_tool_2"},
],
[],
]
),
tools=[parallel_tool_1, parallel_tool_2],
system_prompt="You are a helpful assistant.",
)
result = await agent.ainvoke({"messages": [HumanMessage("Run parallel")]})
# Verify both tools executed
assert len(execution_log) == 2
# Find the tool messages (order may vary due to parallel execution)
tool_messages = [msg for msg in result["messages"] if isinstance(msg, ToolMessage)]
assert len(tool_messages) == 2
contents = {msg.content for msg in tool_messages}
assert "Tool1: 10" in contents
assert "Tool2: 20" in contents
call_ids = {msg.tool_call_id for msg in tool_messages}
assert "parallel_1" in call_ids
assert "parallel_2" in call_ids
Domain
Subdomains
Source
Frequently Asked Questions
What does test_tool_runtime_parallel_execution() do?
test_tool_runtime_parallel_execution() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/test_injected_runtime_create_agent.py.
Where is test_tool_runtime_parallel_execution() defined?
test_tool_runtime_parallel_execution() is defined in libs/langchain_v1/tests/unit_tests/agents/test_injected_runtime_create_agent.py at line 366.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free