Home / Function/ aafter_model() — langchain Function Reference

aafter_model() — langchain Function Reference

Architecture documentation for the aafter_model() function in tool_call_limit.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  b3442318_f785_696a_62ca_a4ede582e8fd["aafter_model()"]
  68f7858b_b207_3223_e360_e5e5b35adf21["ToolCallLimitMiddleware"]
  b3442318_f785_696a_62ca_a4ede582e8fd -->|defined in| 68f7858b_b207_3223_e360_e5e5b35adf21
  2d4474df_60a6_0dd0_a7de_afbe664f4896["after_model()"]
  b3442318_f785_696a_62ca_a4ede582e8fd -->|calls| 2d4474df_60a6_0dd0_a7de_afbe664f4896
  style b3442318_f785_696a_62ca_a4ede582e8fd fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain_v1/langchain/agents/middleware/tool_call_limit.py lines 466–488

    async def aafter_model(
        self,
        state: ToolCallLimitState[ResponseT],
        runtime: Runtime[ContextT],
    ) -> dict[str, Any] | None:
        """Async increment tool call counts after a model call and check limits.

        Args:
            state: The current agent state.
            runtime: The langgraph runtime.

        Returns:
            State updates with incremented tool call counts. If limits are exceeded
                and exit_behavior is `'end'`, also includes a jump to end with a
                `ToolMessage` and AI message for the single exceeded tool call.

        Raises:
            ToolCallLimitExceededError: If limits are exceeded and `exit_behavior`
                is `'error'`.
            NotImplementedError: If limits are exceeded, `exit_behavior` is `'end'`,
                and there are multiple tool calls.
        """
        return self.after_model(state, runtime)

Domain

Subdomains

Frequently Asked Questions

What does aafter_model() do?
aafter_model() is a function in the langchain codebase, defined in libs/langchain_v1/langchain/agents/middleware/tool_call_limit.py.
Where is aafter_model() defined?
aafter_model() is defined in libs/langchain_v1/langchain/agents/middleware/tool_call_limit.py at line 466.
What does aafter_model() call?
aafter_model() calls 1 function(s): after_model.

Analyze Your Own Codebase

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

Try Supermodel Free