Home / Function/ test_multiple_pii_middleware_with_create_agent() — langchain Function Reference

test_multiple_pii_middleware_with_create_agent() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  7b18fe6c_1ede_dd0b_df34_08eac92137fe["test_multiple_pii_middleware_with_create_agent()"]
  7e31f02f_d85d_39af_fd29_e624f564a8b9["TestMultipleMiddleware"]
  7b18fe6c_1ede_dd0b_df34_08eac92137fe -->|defined in| 7e31f02f_d85d_39af_fd29_e624f564a8b9
  style 7b18fe6c_1ede_dd0b_df34_08eac92137fe fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_pii.py lines 596–621

    def test_multiple_pii_middleware_with_create_agent(self) -> None:
        """Test that multiple PIIMiddleware instances work together in create_agent."""
        model = FakeToolCallingModel()

        # Multiple PIIMiddleware instances should work because each has a unique name
        agent = create_agent(
            model=model,
            middleware=[
                PIIMiddleware("email", strategy="redact"),
                PIIMiddleware("ip", strategy="mask"),
                PIIMiddleware("url", strategy="block", apply_to_input=True),
            ],
        )

        # Test with email and IP (url would block, so we omit it)
        result = agent.invoke(
            {"messages": [HumanMessage("Contact: test@example.com, IP: 192.168.1.100")]}
        )

        messages = result["messages"]
        content = " ".join(str(msg.content) for msg in messages)

        # Email should be redacted
        assert "test@example.com" not in content
        # IP should be masked
        assert "192.168.1.100" not in content

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free