LangGraph Agent Loop

Model proposes tool calls, ToolNode runs them, control loops back — until no calls (or recursion_limit) exits to END

LangGraph Agent Loop Model proposes tool calls, ToolNode runs them, control loops back — until no calls (or recursion_limit) exits to END 01 / Agent loop 02 / Tool step 03 / Outcomes Invoke · user message · Agent loop 01 Invoke user message Agent · propose tool calls · Agent loop · model 02 Agent propose tool calls model Tool calls? · none or limit -> END · Agent loop 03 Tool calls? none or limit -> END END · final answer · Agent loop 04 END final answer ToolNode · run tools · Tool step · execute ToolNode run tools execute tool calls results Legend active state waiting terminal success failure / exit

The cycle

  • • The agent node calls the model each turn
  • • Proposed tool calls route to the ToolNode
  • • A back-edge returns results to the agent

Exit condition

  • • A message with no tool calls exits to END
  • • The final answer is the last agent message
  • • END is a real terminal, not a pause

Bounded

  • • recursion_limit caps the number of supersteps
  • • Hitting the cap also forces the exit to END
  • • This prevents an infinite tool-calling loop