Home / Function/ test_apply_to_tool_results_mask_strategy() — langchain Function Reference

test_apply_to_tool_results_mask_strategy() — langchain Function Reference

Architecture documentation for the test_apply_to_tool_results_mask_strategy() function in test_pii.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  472fa60a_3e95_c195_f4fa_551561690f94["test_apply_to_tool_results_mask_strategy()"]
  74acad26_e3cd_8385_fcb7_9bf787fa3f4a["TestPIIMiddlewareIntegration"]
  472fa60a_3e95_c195_f4fa_551561690f94 -->|defined in| 74acad26_e3cd_8385_fcb7_9bf787fa3f4a
  style 472fa60a_3e95_c195_f4fa_551561690f94 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_pii.py lines 450–472

    def test_apply_to_tool_results_mask_strategy(self) -> None:
        """Test that mask strategy works for tool results."""
        middleware = PIIMiddleware(
            "ip", strategy="mask", apply_to_input=False, apply_to_tool_results=True
        )

        state = AgentState[Any](
            messages=[
                HumanMessage("Get server IP"),
                AIMessage(
                    content="",
                    tool_calls=[ToolCall(name="get_ip", args={}, id="call_456", type="tool_call")],
                ),
                ToolMessage(content="Server IP: 192.168.1.100", tool_call_id="call_456"),
            ]
        )

        result = middleware.before_model(state, Runtime())

        assert result is not None
        tool_msg = result["messages"][2]
        assert "*.*.*.100" in tool_msg.content
        assert "192.168.1.100" not in tool_msg.content

Domain

Subdomains

Frequently Asked Questions

What does test_apply_to_tool_results_mask_strategy() do?
test_apply_to_tool_results_mask_strategy() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_pii.py.
Where is test_apply_to_tool_results_mask_strategy() defined?
test_apply_to_tool_results_mask_strategy() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_pii.py at line 450.

Analyze Your Own Codebase

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

Try Supermodel Free