test_with_agent() — langchain Function Reference
Architecture documentation for the test_with_agent() function in test_pii.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 5203b000_daf4_f837_b642_40dff2749f89["test_with_agent()"] 74acad26_e3cd_8385_fcb7_9bf787fa3f4a["TestPIIMiddlewareIntegration"] 5203b000_daf4_f837_b642_40dff2749f89 -->|defined in| 74acad26_e3cd_8385_fcb7_9bf787fa3f4a style 5203b000_daf4_f837_b642_40dff2749f89 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_pii.py lines 497–512
def test_with_agent(self) -> None:
"""Test PIIMiddleware integrated with create_agent."""
model = FakeToolCallingModel()
agent = create_agent(
model=model,
middleware=[PIIMiddleware("email", strategy="redact")],
)
# Invoke (agent is already compiled)
result = agent.invoke({"messages": [HumanMessage("Email: test@example.com")]})
# Check that email was redacted in the stored messages
# The first message should have been processed
messages = result["messages"]
assert any("[REDACTED_EMAIL]" in str(msg.content) for msg in messages)
Domain
Subdomains
Source
Frequently Asked Questions
What does test_with_agent() do?
test_with_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_with_agent() defined?
test_with_agent() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_pii.py at line 497.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free