Where does the bug appear (feature/product)?
Cursor IDE
Describe the Bug
Summary
In Agent mode (using Auto / Claude 3.7 Sonnet), the agent fell into a completely unconstrained infinite tool-calling loop. It repeatedly called read_file on the exact same file range dozens/hundreds of times.
While infinite loops are a bug in themselves, the most critical issue is that there was no circuit breaker or loop-detection safeguard in place. Because each turn sends the entire accumulated context back and forth, this runaway loop resulted in a massive, unexpected bill / token consumption in a matter of minutes until I manually aborted it.
Screenshot
(Please attach the screenshot here)
Environment
- OS: Windows 10/11
- Cursor Version: [Your Cursor version, e.g. 0.45.x]
- Mode: Agent Mode
- Model Setting: Auto (Auto Cost) / Claude 3.7 Sonnet
What Happened
- The session underwent automatic context summarization (“Chat context summarized”).
- Immediately afterwards, the agent attempted to inspect a file and entered a tight degenerative loop, invoking
read_filewith identical arguments (service.go L970-1029) over and over again without stopping or replying. - Because the client did not detect that the exact same tool call with identical arguments was running consecutively, it kept executing the calls automatically.
- Each repetitive iteration consumed thousands of tokens across the large context window, leading to an alarming surge in API usage/cost within a few minutes.
Critical Concerns & Missing Safeguards
-
Absence of Client-Side Circuit Breaker:
A modern AI agent orchestration framework should immediately trip a circuit breaker when it detects repeated identical tool calls (e.g., calling the same tool with the exact same arguments 3–5 times in a row). Cursor currently lacks any hard stop for this behavior. -
Severe Financial Risk for Users:
If a user steps away from their desk or runs tasks in the background, a bug like this could easily drain hundreds of dollars or deplete monthly usage limits in an hour. Even though models can occasionally hallucinate or loop, the hosting platform must protect users from infinite billing loops.
Proposed Solutions / Feature Requests
- Identical Tool Call Threshold: Automatically interrupt the agent and alert the user if the exact same tool call (same name, same arguments) is repeated more than 3 consecutive times.
- Cost / Iteration Throttling per Turn: Implement a configurable limit on the maximum number of tool calls allowed within a single user turn without intermediate user approval.
- Fail-Safe Abort: Post-context compaction, if the model appears to be repeating previous actions, force a fallback prompt to ask the user for guidance rather than continuing autonomously.
Steps to Reproduce
Steps to Reproduce (Non-deterministic)
Due to the non-deterministic nature of LLMs, this issue cannot be 100% deterministically reproduced with a simple prompt. However, it occurred under the following conditions:
- Engage in an extensive coding session in Agent mode with heavy tool usage (file reads/writes, bash commands).
- Continue until the conversation hits the context window limit and triggers automatic context summarization (
Chat context summarized). - Immediately after compaction, the agent attempts to inspect a file (in my case, calling
read_fileonservice.go L970-1029). - Instead of reading once and reasoning over the content, the agent repeatedly re-issues the identical tool call in an unbroken loop.
Note on Reproducibility:
While reproducing the exact model hallucination may be difficult, the bug report does not rely on reproducing the model’s behavior.
The core issue is architectural: Cursor currently lacks a client-side circuit breaker or loop-detection safeguard. Anyone can verify that if a model outputs identical consecutive tool calls, Cursor’s orchestrator will blindly execute them forever without any threshold-based cutoff, exposing users to catastrophic billing spikes.
Screenshots / Screen Recordings
Operating System
Windows 10/11
Version Information
Version: 3.17.19 (user setup)
VS Code Extension API: 1.128.0
Commit: ae3a2b7231dd56194447fe4570dfdc61640b1e90
Date: 2026-08-24T06:42:14.583Z
Layout: IDE
Build Type: Stable
Release Track: Default
Electron: 40.10.3
Chromium: 144.0.7559.236
Node.js: 24.15.0
V8: 14.4.258.32-electron.0
xterm.js: 6.1.0-beta.291
OS: Windows_NT x64 10.0.26200
For AI issues: which model did you use?
Claude 3.7 Sonnet
Does this stop you from using Cursor
No - Cursor works, but with this issue
