Home / Function/ aafter_model() — langchain Function Reference

aafter_model() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  76ba8848_1b95_5006_0db6_dc2692e6deda["aafter_model()"]
  60552546_6c10_6b0f_fd5d_93ed6530c806["TodoListMiddleware"]
  76ba8848_1b95_5006_0db6_dc2692e6deda -->|defined in| 60552546_6c10_6b0f_fd5d_93ed6530c806
  73f986fb_c908_2f34_a4a9_57bb8e22cdaa["after_model()"]
  76ba8848_1b95_5006_0db6_dc2692e6deda -->|calls| 73f986fb_c908_2f34_a4a9_57bb8e22cdaa
  style 76ba8848_1b95_5006_0db6_dc2692e6deda fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain_v1/langchain/agents/middleware/todo.py lines 308–327

    async def aafter_model(
        self, state: PlanningState[ResponseT], runtime: Runtime[ContextT]
    ) -> dict[str, Any] | None:
        """Check for parallel write_todos tool calls and return errors if detected.

        Async version of `after_model`. The todo list is designed to be updated at
        most once per model turn. Since the `write_todos` tool replaces the entire
        todo list with each call, making multiple parallel calls would create ambiguity
        about which update should take precedence. This method prevents such conflicts
        by rejecting any response that contains multiple write_todos tool calls.

        Args:
            state: The current agent state containing messages.
            runtime: The LangGraph runtime instance.

        Returns:
            A dict containing error ToolMessages for each write_todos call if multiple
            parallel calls are detected, otherwise None to allow normal execution.
        """
        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/todo.py.
Where is aafter_model() defined?
aafter_model() is defined in libs/langchain_v1/langchain/agents/middleware/todo.py at line 308.
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