AI stuck in file-reading loop and fails to complete task

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

I’m using Windows and experiencing an issue when working with AI on my Next.js project.

The AI starts processing my prompt, but instead of making actual code changes, it spends most of its time repeatedly reading files and running grep/search operations. After consuming a significant number of tokens, it suddenly stops without providing any result, code modification, explanation, or completion of the requested task.

As a result, a large amount of my token quota is consumed, but no meaningful work is completed. This behavior occurs even for tasks that should be straightforward.

Could you please investigate why the AI gets stuck in a loop of file reading and searching, then terminates unexpectedly without producing an output? I would also appreciate any guidance on how to prevent this from happening in future sessions.

Steps to Reproduce

Steps to Reproduce
Use a Windows machine (e.g., Windows 10 or Windows 11).
Open an AI coding assistant connected to a Next.js project.
Ensure the project contains multiple folders and source files (typical Next.js application structure).
Ask the AI to perform a code-related task, such as:
Implementing a new feature.
Refactoring existing code.
Fixing a bug.
Modifying components across multiple files.
Observe the AI’s activity logs or tool execution history.
The AI begins by reading project files and running search/grep operations.
Instead of proceeding to code modifications, the AI continues performing repeated file reads and searches across the project.
Wait until a significant number of tokens have been consumed.
Eventually, the AI session stops, times out, or ends unexpectedly.
No code changes are applied, and no final response, explanation, or implementation is provided.

Expected Behavior

The AI should analyze the relevant files.
The AI should identify the required changes.
The AI should modify the necessary files or provide the requested implementation.
The AI should return a final response explaining the completed work.

Screenshots / Screen Recordings

Operating System

Windows 10/11

Version Information

IDE: Cursor (latest version)
Operating System: Windows 10
Issue observed while working on a Next.js project.

For AI issues: which model did you use?

Auto

For AI issues: add Request ID with privacy disabled

a7c99bce-7baa-48e7-a441-65fa3dadd97c
02306039-98ab-4364-b936-22d7005ad4f1
650ae8fa-5dd6-4f81-b4cd-630be4757c06

Does this stop you from using Cursor

Yes - Cursor is unusable

Hey, thanks for the detailed report and the request ID, it really helped. I checked the logs for all three requests. The agent on Auto gets stuck in a long loop reading files and searching, the stream degrades over time, and then it ends with a timeout without a final output. I can reproduce it and I’ve reported it internally. I don’t have an exact ETA for a fix yet, but this over-exploration with no result is a known behavior the team is working to improve.

For now, here’s what noticeably reduces the chance of hitting this:

  1. Pick a specific strong model instead of Auto for complex multi-file tasks, for example Claude Sonnet or GPT-5, so routing won’t switch you into a mode where this happens more often.
  2. Narrow the context. @-mention specific files or folders in the prompt so the agent doesn’t walk the whole project tree.
  3. Split the task into smaller steps so less context builds up and the stall risk is lower.

If it still happens with a specific model and a scoped prompt, send a new request ID and I’ll take another look.