Home / Function/ test_shell_tool_error_handling() — langchain Function Reference

test_shell_tool_error_handling() — langchain Function Reference

Architecture documentation for the test_shell_tool_error_handling() function in test_shell_tool_integration.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  ed54f626_5872_6778_c934_444495cb286b["test_shell_tool_error_handling()"]
  16cf511f_16f7_4874_8879_68a3622bd4eb["test_shell_tool_integration.py"]
  ed54f626_5872_6778_c934_444495cb286b -->|defined in| 16cf511f_16f7_4874_8879_68a3622bd4eb
  354734fe_d7c4_f60e_5bb6_2113b3e8d6ed["_get_model()"]
  ed54f626_5872_6778_c934_444495cb286b -->|calls| 354734fe_d7c4_f60e_5bb6_2113b3e8d6ed
  style ed54f626_5872_6778_c934_444495cb286b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain_v1/tests/integration_tests/agents/middleware/test_shell_tool_integration.py lines 84–111

def test_shell_tool_error_handling(tmp_path: Path) -> None:
    """Test shell tool captures command errors."""
    workspace = tmp_path / "workspace"
    agent: CompiledStateGraph[Any, Any, _InputAgentState, Any] = create_agent(
        model=_get_model("anthropic"),
        middleware=[ShellToolMiddleware(workspace_root=workspace)],
    )

    result = agent.invoke(
        {
            "messages": [
                HumanMessage(
                    "Run the command 'ls /nonexistent_directory_12345' and show me the result"
                )
            ]
        }
    )

    tool_messages = [msg for msg in result["messages"] if msg.type == "tool"]
    assert len(tool_messages) > 0, "Shell tool should have been called"

    tool_outputs = " ".join(msg.content for msg in tool_messages)
    assert (
        "no such file" in tool_outputs.lower()
        or "cannot access" in tool_outputs.lower()
        or "not found" in tool_outputs.lower()
        or "exit code" in tool_outputs.lower()
    ), "Error should be captured in tool output"

Domain

Subdomains

Calls

Frequently Asked Questions

What does test_shell_tool_error_handling() do?
test_shell_tool_error_handling() is a function in the langchain codebase, defined in libs/langchain_v1/tests/integration_tests/agents/middleware/test_shell_tool_integration.py.
Where is test_shell_tool_error_handling() defined?
test_shell_tool_error_handling() is defined in libs/langchain_v1/tests/integration_tests/agents/middleware/test_shell_tool_integration.py at line 84.
What does test_shell_tool_error_handling() call?
test_shell_tool_error_handling() calls 1 function(s): _get_model.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free