Agent Mode Intermittently Fails to Apply Code Changes
Bug Description
When using Agent Mode (specifically with Gemini 2.5 Pro Max with thinking), I’m experiencing an intermittent issue where code changes sometimes fail to apply properly. The agent acknowledges this failure with messages like “It seems the edit wasn’t applied again” or “Reapply failed as well,” and then attempts to retry or manually specify the edit.
This appears to be similar to an issue reported back in February 18, 2025 (~3 months ago).
Behavior Patterns
I’ve noticed several patterns:
-
Complete failure to apply - Sometimes changes aren’t applied at all
-
Unrecognized success - Sometimes the code change is actually made, but the agent fails to recognize this and suggests manual intervention
-
Partial application - The agent makes smaller incorrect changes or tries to merge code inappropriately, leading to errors like “Table is not defined”
Reproduction Steps
Unfortunately, I haven’t identified a consistent reproduction pattern. The issue occurs randomly during coding sessions in agent mode. However, I’ve noticed:
-
It seems to happen more frequently with larger code blocks or complex replacements
-
If I proactively click the “apply” button as the agent is working (rather than letting the agent handle it automatically), changes seem more likely to be recognized
Impact
While this doesn’t completely prevent me from using Cursor, it does hinder productivity as I need to manually verify changes, perform manual interventions, or restart chats when the agent gets stuck in a loop of failed applications.
System Information
-
Operating System: Windows 10
-
Cursor Version: 0.49.6 (user setup)
-
AI Model: Using Gemini 2.5 Pro Max with thinking enabled in Agent Mode
Screenshots
I’ve attached several screenshots showing the error messages and behavior patterns.
Additional Notes
Overall, Gemini 2.5 Pro Max is doing a great job with coding - most code changes work correctly. This issue appears to be with Cursor’s ability to reliably apply and detect changes rather than with the AI model’s suggestions themselves.
I checked the developer console logs and found the following error patterns that seem relevant:
-
Numerous instances of:
InlineDiffService#addLine: line contains newline characters, which is not supported
-
File path related errors:
The "path" argument must be of type string. Received type undefined
-
Model access issues:
Could not retrieve model lines for diff calculation for URI: [file paths]
These suggest the apply model may be struggling with code blocks that contain newline characters or with certain file path handling, which could explain why large code block replacements are particularly problematic.