Iterative planning fails

Where does the bug appear (feature/product)?

Cursor CLI

Describe the Bug

iterative planning fails. when asking cursor to update a plan, cursor hangs. it can be restarted by prompting with something like “keep going” but this should have to happen each time. i asked cursor to analyze the problem and write a bug report and it appears to have done an excellent job of it. i attach the report below:

Bug Report: mcp_create_plan Tool - Plan Update Failures

Summary

The mcp_create_plan tool fails when attempting to update existing plans using the old_str and new_str parameters for partial plan updates. The tool consistently returns “invalid string to replace” errors even when the strings appear to match the plan content.

Environment

  • Tool: mcp_create_plan
  • Operation: Updating existing plan using old_str/new_str parameters
  • Plan size: Large (~200+ lines, complex markdown structure)

Steps to Reproduce

  1. Create an initial plan using mcp_create_plan with name, overview, plan, and todos parameters
  2. Attempt to update the plan using old_str and new_str parameters to replace a specific section
  3. Observe error: “Received invalid string to replace in plan”

Error Details

Error Message

Error calling tool: Received invalid string to replace in plan. The current contents are: [full plan content shown]

Observed Behavior

  • The tool shows the full current plan content in the error message
  • The error occurs even when old_str appears to exactly match content from the plan
  • Multiple attempts with different string matching approaches all fail
  • The tool sometimes times out instead of returning an error

Example Failed Call

mcp_create_plan(
    old_str="### Phase 5: Entry Points & Compatibility\n1. Create `bin_py/` directory...",
    new_str="### Phase 5: State Management & Progress Tracking\n1. Create state management system..."
)

Root Cause Analysis

Suspected Issues

  1. Whitespace/Formatting Mismatch: The plan content may have different whitespace (tabs vs spaces, line endings) than what’s being matched
  2. String Matching Precision: The tool requires exact string matches including all whitespace, which is fragile
  3. Plan Content Encoding: Special characters or markdown formatting may not match exactly
  4. Large Plan Size: The plan is very large (~200+ lines), which may cause issues with string matching
  5. Tool Implementation: The tool may not properly normalize whitespace or handle markdown formatting differences

Impact

  • Severity: High - Blocks iterative plan refinement
  • Workaround: Must recreate entire plan instead of making incremental updates
  • User Experience: Frustrating - requires re-entering entire plan content for small changes

Suggested Fixes

Option 1: Improve String Matching

  • Normalize whitespace (tabs→spaces, normalize line endings)
  • Trim leading/trailing whitespace before comparison
  • Use fuzzy matching or regex patterns instead of exact string matching

Option 2: Add Section-Based Updates

  • Allow updates by section ID/header instead of exact string matching
  • Example: update_section="Phase 5" instead of old_str/new_str

Option 3: Better Error Messages

  • Show diff between expected and actual content
  • Highlight where the mismatch occurs
  • Suggest closest matching sections

Option 4: Alternative Update Mechanism

  • Provide a way to update specific fields (e.g., update_plan_section, update_todos)
  • Allow appending/prepending instead of replacement
  • Support JSON/YAML structured updates

Workaround

Currently, the only workaround is to recreate the entire plan with all content when updates are needed, which is inefficient for large plans.

Additional Context

  • The tool works correctly for initial plan creation
  • The issue only occurs when attempting to update existing plans
  • Plan content includes complex markdown with code blocks, lists, and nested structures
  • Multiple attempts with different string extraction methods all failed

Requested Priority

High - This significantly impacts usability when refining plans iteratively.

Steps to Reproduce

Create an initial plan using mcp_create_plan with name, overview, plan, and todos parameters
Attempt to update the plan using old_str and new_str parameters to replace a specific section
Observe error: “Received invalid string to replace in plan”

Expected Behavior

things would work

Operating System

MacOS

Current Cursor Version (Menu → About Cursor → Copy)

Version: 2.1.36
VSCode Version: 1.105.1
Commit: 9cd7c8b6cebcbccc1242df211dee45a4b6fe15e0
Date: 2025-11-26T03:43:48.079Z
Electron: 37.7.0
Chromium: 138.0.7204.251
Node.js: 22.20.0
V8: 13.8.258.32-electron.0
OS: Darwin arm64 25.0.0

For AI issues: which model did you use?

composer-1

Does this stop you from using Cursor

No - Cursor works, but with this issue

Hey, thanks for the report. This is a known issue that affects plan updates.

It matches a similar bug reported for IDE Plan Mode, where the problem is that the plan storage format differs from what’s displayed, causing string matching to fail.

Temporary workarounds:

  • Recreate the entire plan instead of using old_str/new_str updates (as you’ve discovered)
  • Manually edit plans in .cursor/plans/ if saved to the workspace

If you have a Request ID from one of the failed sessions, it would help with debugging.

This topic was automatically closed 22 days after the last reply. New replies are no longer allowed.