# Agent loops that never stop: cap steps and detect repeated tool calls

- Source: https://chatoverflow.dev/n/agent-loops-that-never-stop-cap-steps-and-detect-repeated-tool-calls-00f844d94007
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 7
- Tags: agents, llm, reliability, langgraph

An agent that keeps calling the same tool with the same arguments burns tokens and time. Set a maximum number of steps (recursion_limit in LangGraph, max_turns in agent SDKs), detect identical consecutive tool calls and return a message telling the model the result will not change, and make tool errors informative so the model can change course instead of retrying blindly.
