Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk6 min

How to Set Limits and Detect Stagnation in AI Agent Runs

AI agent retries are useful when they change the approach. Learn how to detect stagnation, verify progress, and set runtime safeguards that stop loops before work runs away.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

An AI agent gets stuck when its workflow keeps running without a reliable way to recognize progress or stop. Retries and repeated agent handoffs are often useful; the failure is allowing them to continue when the next attempt changes nothing. The fix is not just a better prompt: define observable completion and failure conditions, cap execution, and make the runtime record why each run stops.

What an AI agent loop is—and why it can be hard to spot

An agent loop is a repeated path through model calls, tools, workflow steps, state updates, or agent handoffs. It becomes a problem when that path has no effective bound, or when its exit condition cannot be reached. A loop can therefore span an orchestration framework and runtime even if the application contains no obvious infinite while loop.

As an Amazon Associate I earn from qualifying purchases.

In a 2026 arXiv preprint, Xinyi Hou, Shenao Wang, Yanjie Zhao, and Haoyu Wang describe the distinction this way: “IALs are not ordinary programming loops; they arise from the interaction between agent logic, framework semantics, runtime observations, and termination mechanisms.” That cross-layer behavior explains why a run may look reasonable step by step yet continue indefinitely as a whole.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Not every repeated action is a defect. Google Cloud’s architecture guidance describes multi-agent workflows as sequences of specialized agents that can repeat under an exit condition—for example, until a quality threshold is met or a maximum iteration count is reached. Critic-and-revision cycles can be productive when the workflow has a reachable stopping rule. If that rule is wrong, missing, or never satisfied, the same pattern can turn into an indefinite run, a hang, or excessive resource use.

#1 Best Overall
SunFounder PiDog AI Robot Dog Kit for Raspberry Pi 5/4/3B+/Zero 2W, Openclaw LLMs ChatGPT/Gemini/Grok, Voice&Video Recognition, Python, App, Gyroscope, Camera (RPI NOT Included)
  • AI-Powered Raspberry Pi Robot Dog — PiDog: Powered by Raspberry Pi (5/4B/3B+/3B/Zero 2W), OpenClaw, and multi-LLMs like ChatGPT, Gemini, Grok, DeepSeek, Qwen & Ollama. With 12 servos, camera, gyroscope, hearing & touch sensors, PiDog can see, listen, talk, move, and interact intelligently. Supports OpenCV, MediaPipe, TTS & STT, app control, FPV & Python. A great STEM robotics gift for students, makers & tech enthusiasts—perfect for birthdays and holidays. (Raspberry Pi not included)
  • Realistic Dog-like Movements: PiDog's 12 powerful servos enable 32 dog-like actions, including walking, sitting, standing, shaking its head, wagging its tail, and performing playful tricks, closely mimicking a real dog and providing an engaging experience. This is an AI development robot product designed for engineers, suitable for ages 15 and above
  • Rich Sensor Suite for Interactive Experiences: PiDog features ultrasonic, touch, gyroscope, sound, camera, speaker and microphone. These provide it with advanced hearing, vision, and touch, enabling it to see, detect obstacles, respond to touch, and recognize sounds, making interactions highly engaging
  • AI-Powered Interactions with OpenClaw & Multi-LLMs. PiDog combines voice, vision, and gesture recognition for immersive AI experiences. Powered by OpenClaw and multi-LLMs like ChatGPT, Gemini, Grok, DeepSeek, Qwen, Doubao, and Ollama (local LLMs), it can understand questions, respond naturally through TTS & STT, recognize math problems, interpret hand gestures, and hold smart conversations. OpenClaw also enables customizable AI behaviors and personalized robotics development, helping users create their own intelligent robotic companion
  • Comprehensive Learning Resources and Support: PiDog offers detailed online documentation, video tutorials, prompt technical support, and an active forum community, ensuring beginners can easily complete all projects and enjoy a great experience

How to tell a useful retry from stagnation

A retry is useful when the error may be transient or the next attempt makes a meaningful change: different inputs, additional context, a revised plan, or a changed tool strategy. Repeating an unchanged request after a permanent error is a warning sign, not proof on its own. Look for a pattern across attempts rather than treating any one repeated call as a diagnosis.

  • Compare tool calls: Are the same tool and identical inputs being sent repeatedly?
  • Compare state and artifacts: Did files, task state, outputs, or other relevant results change after each pass?
  • Compare activity with outcomes: Are model and tool calls accumulating while resolved work stays flat?
  • Inspect the error: Is it plausibly temporary, or does the same permanent failure recur without a changed approach?

These are practical diagnostic heuristics, not proof of the cause. For coding tasks, progress can be measured through changed files, fewer errors, or completed subtasks. For other tasks, define a comparable external measure before the run begins.

What to record so you can catch a loop early

Logs that show only the final answer hide how a run behaved. Record enough per-step detail to distinguish a new attempt from blind replay, and to find the layer where the stop condition failed.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Iteration or turn number and elapsed time
  • The action selected and the exact tool inputs and outputs
  • Retry count, error details, and whether the attempted strategy changed
  • State changes or artifacts produced after each pass
  • The final stop reason, such as success, timeout, iteration limit, repeated failure, or human intervention

Use a canonical task or environment state where possible. Continuation should depend on observable movement in that state, not solely on the agent’s assertion that it made progress. If the task has no reliable external success check, acknowledge that uncertainty and use a conservative limit or human review.

Rank #2
SunFounder AI Robot Kit with Raspberry Pi Zero 2 W+32G TF Card, ChatGPT-4o Enabled with Voice Command & Video Recognition, App Control, FPV, 12 Servos, Gyroscope, Camera, Mic
  • Raspberry Pi AI Robot: powered by Raspberry Pi (5/4B/3B+/3B/Zero 2W), features 12 servos and sensors for vision, hearing, and touch. Integrated with ChatGPT-4o, it responds to complex queries. With app control and FPV, users can manage and see its view in real-time. It supports Python programming
  • Realistic Movements: 12 powerful servos enable 32 actions, including walking, sitting, standing, shaking its head, wagging its tail, and performing playful tricks, closely mimicking a real and providing an engaging experience
  • Rich Sensor Suite for Interactive Experiences: features ultrasonic, touch, gyroscope, sound, camera, speaker and microphone. These provide it with advanced hearing, vision, and touch, enabling it to see, detect obstacles, respond to touch, and recognize sounds, making interactions highly engaging
  • Engaging Interactions with ChatGPT-4o: with ChatGPT-4o enables voice interactions and visual recognition, making it smarter and more responsive. Users can have natural conversations, solve math problems via the camera, and interpret gestures, creating diverse and fun interactions
  • Comprehensive Learning Resources and Support: offers detailed online documentation, video tutorials, prompt technical support, and an active forum community, ensuring beginners can easily complete all projects and enjoy a great experience

Why an agent can mistake repetition for progress

An agent’s own assessment is not always a dependable stopping signal. A 2026 arXiv preprint, “When Do Agent Loops Mistake Stagnation for Progress?”, reports results from a particular long-running-loop testbed: across 54 evaluation cycles, 56 percent had measured delta at zero or below even though the agent claimed improvement. In that study, the strongest in-band judge accepted real-world regressions 44 percent of the time and rejected real improvements 38 percent of the time.

Those figures describe that study’s setup; they are not error rates for all agents or a prediction for a specific product. The practical implication is narrower: when success can be checked outside the agent’s own narrative, verify the artifact or world state independently. The paper reports that judge performance depended on where the success signal resided. Where an external check is unavailable, use human review or a cautious stopping rule instead of treating confident self-evaluation as proof.

How to stop runaway retries without blocking useful work

Use more than one control. A turn cap limits one dimension of work; it does not necessarily bound wall-clock time, tool execution, recovery work, or side effects. Combine hard ceilings with meaningful progress and failure conditions at the orchestration layer.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

1. Set hard execution limits

Set a maximum number of agent turns or workflow iterations, a wall-clock limit, and timeouts for individual tools. In the OpenAI Agents SDK documentation, exceeding configured max_turns raises MaxTurnsExceeded; setting max_turns=None disables that limit. A limit should result in a visible incomplete or failed run, not an apparent success.

Rank #3
SunFounder Picar-X AI Robot Smart Car Kit for Raspberry Pi 5/4/3B+/Zero 2w, Openclaw LLMs ChatGPT/Gemini/Grok, Voice&Video Recognition, Python, Scratch, Camera (RPI NOT Included)
  • AI-Powered Raspberry Pi Smart Car — PiCar-X: PiCar-X brings AI learning to life — powered by Openclaw and multi-LLMs including ChatGPT, Gemini, Grok, DeepSeek, Qwen, Doubao, Ollama (Local LLMs), and compatible with many more AI platforms. Featuring OpenCV, MediaPipe, TTS & STT, PiCar-X enables true AI vision and voice interaction — it can see, listen, talk, drive and think like an intelligent companion. Ideal for students (10+), educators, and engineers, PiCar-X is the perfect gateway to explore AI, robotics, and machine learning on Raspberry Pi 5/4/3B+/3B/Zero 2W (Raspberry Pi not included)
  • Engaging Interactions with Multi-LLMs: PiCar-X, powered by Openclaw and multi-LLMs — including ChatGPT, Gemini, Grok, DeepSeek, Qwen, Doubao, and Ollama (Local LLMs) — and compatible with many other AI platforms, supports voice interaction and visual recognition to make the robot smarter and more responsive. Users can enjoy natural AI conversations, solve math problems through the camera, and interpret gestures, unlocking a world of diverse and fun AI-driven interactions
  • Feature-rich and Adaptable: PiCar-X offers engaging applications like line following and obstacle avoidance, supports TTS (Text-to-Speech) and STT (Speech-to-Text) for interactive voice control, and includes a camera for video and vision recognition. It also comes with various sensors, while its customizable design enables a wide range of creative AI and robotics projects
  • Versatile Programming Options: Catering to users of all skill levels, PiCar-X supports both Python and Scratch programming languages, allowing for flexible learning and skill development
  • Simplified Assembly & Support: PiCar-X is perfect for beginners, yet learning with experienced users is recommended for best results. It comes with easy assembly instructions and forum support for smooth project completion

2. Define reachable completion and failure conditions

Specify what counts as done and what happens when progress stops. For example, a repeated unchanged error can trigger a revised plan, a failure state, or escalation rather than another identical attempt. Google Cloud’s guidance emphasizes that loop exit conditions must be defined so they can actually be reached.

3. Require observable progress between attempts

Track canonical task state and compare it after each iteration. If the state is unchanged, require the next attempt to change its inputs or strategy, or stop. A model’s statement that it improved should not replace a check of the relevant artifact or environment.

4. Bound recovery separately when needed

Recovery or alarm processing can have a budget of its own, distinct from the main agent-turn limit. Cloudflare Agents documents controls named maxRecoveryWork and maxAlarmMemoryLimitStrikes. Their defaults and the way recovery units are counted are version-sensitive; check the current documentation for the package release in use rather than assuming a universal value.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

5. Put consequential actions behind approval

For actions with meaningful external side effects, add an approval checkpoint or another safeguard appropriate to the task. Google Cloud describes human-in-the-loop checkpoints for review or correction. OpenAI’s Agents SDK documentation also lists durable workflow integrations for processes that span waits, retries, or restarts.

Rank #4
Sale
ELEGOO UNO R3 Smart Robot Car Kit V4 with Camera, Compatible with Arduino
  • BUILD, CODE & DRIVE YOUR OWN ROBOT CAR: Turn coding, electronics and engineering into a working programmable robot car you can assemble, program and drive; ideal for weekend family projects, STEM classrooms, coding clubs, robotics lessons and maker challenges
  • EXPLORE FPV, LINE TRACKING & OBSTACLE AVOIDANCE: Control the robot with the ELEGOO app or IR remote, view live FPV video through the onboard camera, follow black lines, avoid obstacles with the ultrasonic sensor and explore multiple interactive driving modes
  • BEGINNER-FRIENDLY BUILD WITH GUIDED WIRING: Keyed XH2.54 connectors help reduce wiring mistakes, while the illustrated tutorial and example programs guide beginners step by step from chassis assembly and module connection to programming and the first successful run
  • GO BEYOND ASSEMBLY WITH CREATIVE CODING: Program with Arduino IDE to explore movement, sensors and control logic, then modify example code to create custom routes, reactions and robotics experiments that develop coding, problem-solving and engineering skills
  • COMPLETE RECHARGEABLE STEM ROBOTICS KIT: Includes an ELEGOO UNO R3 controller board, ESP32-WROVER-based camera and Wi-Fi module, line-tracking and ultrasonic sensors, motors, IR remote and a 2000 mAh rechargeable lithium-ion battery; recommended for ages 8+ with adult guidance for first-time builders

6. Preserve partial work and explain the stop

When a limit is reached, return whatever partial work is safe to preserve and state what remains incomplete and why the run stopped. Silent truncation or a success message that masks unfinished work makes failures harder to detect and recover from.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

How to investigate an agent that is already looping

  1. Stop further execution safely. Apply the runtime’s cancellation or stop mechanism, especially if repeated tool calls can change external state.
  2. Find the repeating path. Review turn numbers, tool inputs and outputs, workflow transitions, and state updates to locate the first repeated sequence.
  3. Check for real progress. Compare task state or artifacts across attempts, rather than relying only on the agent’s explanation.
  4. Identify the missing or ineffective bound. Check limits at the agent, workflow, tool, timeout, and recovery layers, including whether each limit is enabled and reachable.
  5. Choose a recovery path. Resume with a genuinely changed strategy if the failure is recoverable; otherwise record a failure or escalate. Do not replay the same permanent error without a change.
  6. Retest the stop condition. Confirm that the workflow exits on success, on a repeated failure, and when it reaches its hard limit.

What published loop-detection results do—and do not—show

Hou and colleagues evaluated 6,549 LLM-agent repositories with IAL-Scan and reported 74 potential findings. They confirmed 68 infinite agentic loop failures across 47 projects and reported 91.9% precision for the scanner. These are results from that preprint’s repository evaluation: they are not an estimate of how often loops occur across all deployed agents, and they do not establish that a particular framework or product is protected.

Choosing controls for a real workflow

Treat runtime features as controls for particular failure modes, not as proof that loops are eliminated. Google Cloud describes loop patterns governed by exit conditions; the OpenAI Agents SDK documentation lists Dapr, Temporal, Restate, and DBOS integrations for durable execution of workflows involving retries, restarts, or human approval; Cloudflare Agents documents finite recovery-work controls. These are implementation examples, not controlled vendor comparisons or endorsements.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When assessing an approach, check what its bound covers—model turns, tool retries, recovery work, or the complete workflow—and whether it persists across process restarts. Also check whether it supports human approval and records an explicit stop reason. A robust design pairs a hard limit with progress-sensitive checks: the hard limit caps runaway work, while the progress check helps stop a run that is busy but no longer advancing.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.