Hi team, I have been using Claude Sonnet 4.0 thinking and see it keeps getting stuck in loops. For example, when I tell it to run my test suite and fix a few failing tests, it has repeatedly run my test suite an infinite number of times and doesn’t progress to fixing the tests.
I don’t know if this is an issue with Sonnet or Cursor’s use of it but wanted to put this on your radar. Any suggestions on how to resolve this?
Hi, as thinking models have a very different handling of prompts and reasoning, usage of such models requires knowledge by user as to how the model works and how to prompt it effectively. This is not really an Cursor related question as it applies to most reasoning models.
Here is the Claude 4 prompt engineering page by Antropic (makers of Claude).
Its best to start with simple precise steps and to expand on prompts as you get to know the model and how to use it.
There are a few potential causes that you may watch out for and prevent such cases:
Give the AI clear task and goal.
Start with a fresh chat as long context leads to likely conflicting information and it may misinterpret things as a cause which isnt true.
When the model starts hallucinating its likely there is either conflicting / insufficient info or context may be running out (long chat).
Dont attach to many files or reference too big rules. Such models need just the required information as anything extra leads likely to wrong conclusions
If you see the model going in circles then stop it (you can stop the prompt processing)
In some cases if you notice the reason what it misunderstood you can go up one step to previous prompt and insert that info so it is guided on the right path.
However in case you suspect there is really an issue could you then provide more information?
See Cursor documentation for Trubleshooting Guide.
I’ve ben having the same issue. It has rewritten the same cache scaffolding, and curled the same API endpoints in the same chat. I don’t think I’ve ever made as many reversions before as I have today.