abefore_model() — langchain Function Reference
Architecture documentation for the abefore_model() function in pii.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 9c796f5d_d259_f87b_dbac_56cc6e575e35["abefore_model()"] dc527b75_da40_4d1c_e472_82d1252ba70b["PIIMiddleware"] 9c796f5d_d259_f87b_dbac_56cc6e575e35 -->|defined in| dc527b75_da40_4d1c_e472_82d1252ba70b e81931fa_c61c_8dac_e9d4_8b63fbff471d["before_model()"] 9c796f5d_d259_f87b_dbac_56cc6e575e35 -->|calls| e81931fa_c61c_8dac_e9d4_8b63fbff471d style 9c796f5d_d259_f87b_dbac_56cc6e575e35 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain_v1/langchain/agents/middleware/pii.py lines 266–284
async def abefore_model(
self,
state: AgentState[Any],
runtime: Runtime[ContextT],
) -> dict[str, Any] | None:
"""Async check user messages and tool results for PII before model invocation.
Args:
state: The current agent state.
runtime: The langgraph runtime.
Returns:
Updated state with PII handled according to strategy, or `None` if no PII
detected.
Raises:
PIIDetectionError: If PII is detected and strategy is `'block'`.
"""
return self.before_model(state, runtime)
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does abefore_model() do?
abefore_model() is a function in the langchain codebase, defined in libs/langchain_v1/langchain/agents/middleware/pii.py.
Where is abefore_model() defined?
abefore_model() is defined in libs/langchain_v1/langchain/agents/middleware/pii.py at line 266.
What does abefore_model() call?
abefore_model() calls 1 function(s): before_model.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free