test_apply_to_output_only() — langchain Function Reference
Architecture documentation for the test_apply_to_output_only() function in test_pii.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD ab248ac4_fcae_aca0_054b_7c971a1219a2["test_apply_to_output_only()"] 74acad26_e3cd_8385_fcb7_9bf787fa3f4a["TestPIIMiddlewareIntegration"] ab248ac4_fcae_aca0_054b_7c971a1219a2 -->|defined in| 74acad26_e3cd_8385_fcb7_9bf787fa3f4a style ab248ac4_fcae_aca0_054b_7c971a1219a2 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_pii.py lines 374–389
def test_apply_to_output_only(self) -> None:
"""Test that middleware only processes output when configured."""
middleware = PIIMiddleware(
"email", strategy="redact", apply_to_input=False, apply_to_output=True
)
# Should not process HumanMessage
state = AgentState[Any](messages=[HumanMessage("Email: test@example.com")])
result = middleware.before_model(state, Runtime())
assert result is None
# Should process AIMessage
state = AgentState[Any](messages=[AIMessage("My email is ai@example.com")])
result = middleware.after_model(state, Runtime())
assert result is not None
assert "[REDACTED_EMAIL]" in result["messages"][0].content
Domain
Subdomains
Source
Frequently Asked Questions
What does test_apply_to_output_only() do?
test_apply_to_output_only() 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_output_only() defined?
test_apply_to_output_only() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_pii.py at line 374.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free