after_model() — langchain Function Reference
Architecture documentation for the after_model() function in model_call_limit.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD ddfc6181_e2bb_c9ed_5bb7_f22f928ebc4e["after_model()"] 190da0f4_c252_0e20_de0d_30a94a781fc9["ModelCallLimitMiddleware"] ddfc6181_e2bb_c9ed_5bb7_f22f928ebc4e -->|defined in| 190da0f4_c252_0e20_de0d_30a94a781fc9 4f6e7f69_11df_c850_48cf_28f311b9a508["aafter_model()"] 4f6e7f69_11df_c850_48cf_28f311b9a508 -->|calls| ddfc6181_e2bb_c9ed_5bb7_f22f928ebc4e style ddfc6181_e2bb_c9ed_5bb7_f22f928ebc4e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain_v1/langchain/agents/middleware/model_call_limit.py lines 236–251
def after_model(
self, state: ModelCallLimitState[ResponseT], runtime: Runtime[ContextT]
) -> dict[str, Any] | None:
"""Increment model call counts after a model call.
Args:
state: The current agent state.
runtime: The langgraph runtime.
Returns:
State updates with incremented call counts.
"""
return {
"thread_model_call_count": state.get("thread_model_call_count", 0) + 1,
"run_model_call_count": state.get("run_model_call_count", 0) + 1,
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does after_model() do?
after_model() is a function in the langchain codebase, defined in libs/langchain_v1/langchain/agents/middleware/model_call_limit.py.
Where is after_model() defined?
after_model() is defined in libs/langchain_v1/langchain/agents/middleware/model_call_limit.py at line 236.
What calls after_model()?
after_model() is called by 1 function(s): aafter_model.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free