test_wrap_tool_call_access_runtime() — langchain Function Reference
Architecture documentation for the test_wrap_tool_call_access_runtime() function in test_wrap_tool_call.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD c97b6377_fb34_b44b_ff18_dac767a8cb1f["test_wrap_tool_call_access_runtime()"] e783c6bd_e3d7_7d3b_e64d_d062c5c12013["test_wrap_tool_call.py"] c97b6377_fb34_b44b_ff18_dac767a8cb1f -->|defined in| e783c6bd_e3d7_7d3b_e64d_d062c5c12013 style c97b6377_fb34_b44b_ff18_dac767a8cb1f fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_wrap_tool_call.py lines 190–225
def test_wrap_tool_call_access_runtime() -> None:
"""Test accessing runtime from wrap_tool_call decorator."""
runtime_data = []
@wrap_tool_call
def access_runtime(
request: ToolCallRequest, handler: Callable[[ToolCallRequest], ToolMessage | Command[Any]]
) -> ToolMessage | Command[Any]:
# Access runtime from request
if request.runtime is not None:
# Runtime object is available (has context, store, stream_writer, previous)
runtime_data.append(type(request.runtime).__name__)
return handler(request)
model = FakeToolCallingModel(
tool_calls=[
[ToolCall(name="search", args={"query": "test"}, id="1")],
[],
]
)
agent = create_agent(
model=model,
tools=[search],
middleware=[access_runtime],
checkpointer=InMemorySaver(),
)
agent.invoke(
{"messages": [HumanMessage("Search")]},
{"configurable": {"thread_id": "test_thread"}},
)
# Middleware should have accessed runtime
assert len(runtime_data) >= 1
assert runtime_data[0] == "ToolRuntime"
Domain
Subdomains
Source
Frequently Asked Questions
What does test_wrap_tool_call_access_runtime() do?
test_wrap_tool_call_access_runtime() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_wrap_tool_call.py.
Where is test_wrap_tool_call_access_runtime() defined?
test_wrap_tool_call_access_runtime() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_wrap_tool_call.py at line 190.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free