test_state_schema_with_tool_runtime() — langchain Function Reference
Architecture documentation for the test_state_schema_with_tool_runtime() function in test_state_schema.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 9704a3ae_0657_0b9c_a197_5f5649570b40["test_state_schema_with_tool_runtime()"] 3d4a3f09_0839_f785_dcfd_f1e7b13e3204["test_state_schema.py"] 9704a3ae_0657_0b9c_a197_5f5649570b40 -->|defined in| 3d4a3f09_0839_f785_dcfd_f1e7b13e3204 style 9704a3ae_0657_0b9c_a197_5f5649570b40 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain_v1/tests/unit_tests/agents/test_state_schema.py lines 87–112
def test_state_schema_with_tool_runtime() -> None:
"""Test that custom state fields are accessible via ToolRuntime."""
class ExtendedState(AgentState[Any]):
counter: int
runtime_data = {}
@tool
def counter_tool(x: int, runtime: ToolRuntime) -> str:
"""Tool that accesses custom state field."""
runtime_data["counter"] = runtime.state["counter"]
return f"Counter is {runtime_data['counter']}, x is {x}"
agent = create_agent(
model=FakeToolCallingModel(
tool_calls=[[{"args": {"x": 10}, "id": "call_1", "name": "counter_tool"}], []]
),
tools=[counter_tool],
state_schema=ExtendedState,
)
result = agent.invoke({"messages": [HumanMessage("Test")], "counter": 5})
assert runtime_data["counter"] == 5
assert "Counter is 5" in result["messages"][2].content
Domain
Subdomains
Source
Frequently Asked Questions
What does test_state_schema_with_tool_runtime() do?
test_state_schema_with_tool_runtime() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/test_state_schema.py.
Where is test_state_schema_with_tool_runtime() defined?
test_state_schema_with_tool_runtime() is defined in libs/langchain_v1/tests/unit_tests/agents/test_state_schema.py at line 87.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free