Home / Function/ test_tool_message_formatting_with_id() — langchain Function Reference

test_tool_message_formatting_with_id() — langchain Function Reference

Architecture documentation for the test_tool_message_formatting_with_id() function in test_shell_tool.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  434b01d0_ac34_85b4_27d5_4de5878ec2d3["test_tool_message_formatting_with_id()"]
  f21fd460_1d0c_cb92_cfa1_eae0890e2f58["test_shell_tool.py"]
  434b01d0_ac34_85b4_27d5_4de5878ec2d3 -->|defined in| f21fd460_1d0c_cb92_cfa1_eae0890e2f58
  1bc202d6_8b54_02e9_fadd_ff3171c38a75["_empty_state()"]
  434b01d0_ac34_85b4_27d5_4de5878ec2d3 -->|calls| 1bc202d6_8b54_02e9_fadd_ff3171c38a75
  style 434b01d0_ac34_85b4_27d5_4de5878ec2d3 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_shell_tool.py lines 255–276

def test_tool_message_formatting_with_id(tmp_path: Path) -> None:
    """Test that tool messages are properly formatted with tool_call_id."""
    middleware = ShellToolMiddleware(workspace_root=tmp_path / "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)

        result = middleware._run_shell_tool(
            resources, {"command": "echo test"}, tool_call_id="test-id-123"
        )

        assert isinstance(result, ToolMessage)
        assert result.tool_call_id == "test-id-123"
        assert result.name == "shell"
        assert result.status == "success"
        assert "test" in result.content
    finally:
        middleware.after_agent(state, runtime)

Domain

Subdomains

Frequently Asked Questions

What does test_tool_message_formatting_with_id() do?
test_tool_message_formatting_with_id() 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_tool_message_formatting_with_id() defined?
test_tool_message_formatting_with_id() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_shell_tool.py at line 255.
What does test_tool_message_formatting_with_id() call?
test_tool_message_formatting_with_id() 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