test_executes_command_and_persists_state() — langchain Function Reference
Architecture documentation for the test_executes_command_and_persists_state() function in test_shell_tool.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD b59c26d0_28af_7afe_c898_0027616440fd["test_executes_command_and_persists_state()"] f21fd460_1d0c_cb92_cfa1_eae0890e2f58["test_shell_tool.py"] b59c26d0_28af_7afe_c898_0027616440fd -->|defined in| f21fd460_1d0c_cb92_cfa1_eae0890e2f58 1bc202d6_8b54_02e9_fadd_ff3171c38a75["_empty_state()"] b59c26d0_28af_7afe_c898_0027616440fd -->|calls| 1bc202d6_8b54_02e9_fadd_ff3171c38a75 style b59c26d0_28af_7afe_c898_0027616440fd fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_shell_tool.py lines 28–48
def test_executes_command_and_persists_state(tmp_path: Path) -> None:
workspace = tmp_path / "workspace"
middleware = ShellToolMiddleware(workspace_root=workspace)
runtime = Runtime()
state = _empty_state()
try:
updates = middleware.before_agent(state, runtime)
if updates:
state.update(cast("ShellToolState", updates))
resources = middleware._get_or_create_resources(state)
middleware._run_shell_tool(resources, {"command": "cd /"}, tool_call_id=None)
result = middleware._run_shell_tool(resources, {"command": "pwd"}, tool_call_id=None)
assert isinstance(result, str)
assert result.strip() == "/"
echo_result = middleware._run_shell_tool(
resources, {"command": "echo ready"}, tool_call_id=None
)
assert "ready" in echo_result
finally:
middleware.after_agent(state, runtime)
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does test_executes_command_and_persists_state() do?
test_executes_command_and_persists_state() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_shell_tool.py.
Where is test_executes_command_and_persists_state() defined?
test_executes_command_and_persists_state() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_shell_tool.py at line 28.
What does test_executes_command_and_persists_state() call?
test_executes_command_and_persists_state() calls 1 function(s): _empty_state.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free