test_tool_runtime_with_multiple_tools() — langchain Function Reference
Architecture documentation for the test_tool_runtime_with_multiple_tools() function in test_injected_runtime_create_agent.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 8c4b3cb1_b1f0_7804_f3e1_2a7fc46328d0["test_tool_runtime_with_multiple_tools()"] a4d83fe9_0a39_5761_b1a5_de54f81974c9["test_injected_runtime_create_agent.py"] 8c4b3cb1_b1f0_7804_f3e1_2a7fc46328d0 -->|defined in| a4d83fe9_0a39_5761_b1a5_de54f81974c9 style 8c4b3cb1_b1f0_7804_f3e1_2a7fc46328d0 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain_v1/tests/unit_tests/agents/test_injected_runtime_create_agent.py lines 199–243
def test_tool_runtime_with_multiple_tools() -> None:
"""Test multiple tools can all access ToolRuntime."""
call_log: list[tuple[str, str | None, int | str]] = []
@tool
def tool_a(x: int, runtime: ToolRuntime) -> str:
"""First tool."""
call_log.append(("tool_a", runtime.tool_call_id, x))
return f"A: {x}"
@tool
def tool_b(y: str, runtime: ToolRuntime) -> str:
"""Second tool."""
call_log.append(("tool_b", runtime.tool_call_id, y))
return f"B: {y}"
agent = create_agent(
model=FakeToolCallingModel(
tool_calls=[
[
{"args": {"x": 1}, "id": "call_a", "name": "tool_a"},
{"args": {"y": "test"}, "id": "call_b", "name": "tool_b"},
],
[],
]
),
tools=[tool_a, tool_b],
system_prompt="You are a helpful assistant.",
)
result = agent.invoke({"messages": [HumanMessage("Use both tools")]})
# Verify both tools were called with correct runtime
assert len(call_log) == 2
# Tools may execute in parallel, so check both calls are present
call_ids = {(name, call_id) for name, call_id, _ in call_log}
assert ("tool_a", "call_a") in call_ids
assert ("tool_b", "call_b") in call_ids
# Verify tool messages
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 "A: 1" in contents
assert "B: test" in contents
Domain
Subdomains
Source
Frequently Asked Questions
What does test_tool_runtime_with_multiple_tools() do?
test_tool_runtime_with_multiple_tools() 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_with_multiple_tools() defined?
test_tool_runtime_with_multiple_tools() is defined in libs/langchain_v1/tests/unit_tests/agents/test_injected_runtime_create_agent.py at line 199.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free