I partially solved this problem,
When the agent stops unexpectedly, switching the model to another model (in this case I’m using gemini-2.5-flash) and tell the agent to continue the task, before it performs any actual editing, stops and switches back to the gemini-2.5-pro model again.
My guess is that the gemini-2.5 pro model can’t call the summary function, so every time it reaches the token limit and calls that function, it gets errors and stops. Switching to another model allows the summary function to be called correctly and then proceeds successfully.
Thanks, I really appreciate that Cursor has provided us with such a great tool. Please let me know if there is any further information I can provide to help investigate the problem.