Skip to content

Repeating: The model used search patterns that don't match anything in the file. Retrying... #8237

Closed

Description

@mosmondor

Plugin Type

VSCode Extension

Cline Version

3.44.1

What happened?

Every so often (almost in every task) I get this:

Image

Message repeats without stopping. If I'm not there to stop it, it will run indefinitely.

Please fix.

Steps to reproduce

Provider/Model

No response

System Information

No response

Activity

  1. linear commented on Dec 20, 2025

    @linear
  2. mosmondor commented on Dec 20, 2025

    @mosmondor
    Author

    Was using gpt-5.2 at the time.

  3. alexe100dra commented on Dec 21, 2025

    @alexe100dra

    happens a lot lately .... i'm on gpt-5.1

  4. deleted a comment from github-actions on Dec 21, 2025
  5. github-actions commented on Dec 21, 2025

    @github-actions
    Contributor

    Thanks for reporting this. This is a known, long-standing issue tracked in #4384 (the meta-issue for file editing reliability), and there's also #7665 which is essentially a duplicate reporting the same infinite retry loop.

    What's happening

    When Cline uses the replace_in_file tool, it needs the model to provide an exact text match of the code being replaced. When the model outputs search patterns that don't match the file (often due to whitespace/indentation differences or the model "remembering" an older version of the file), Cline retries. Without intervention, this can loop indefinitely, burning through tokens and money.

    GPT-5.1/5.2 context

    You mentioned using GPT-5.2 and another commenter mentioned GPT-5.1. Interestingly, Cline recently added an APPLY_PATCH tool specifically for GPT-5.1+ models (PR #8167, merged Dec 18) which should theoretically be more reliable since it's the patch format these models were trained on. However, this only applies when native tool calling is enabled.

    Could you confirm:

    1. Are you using native tool calling in your settings?
    2. Is this happening with a specific type of file or code pattern?
    3. Can you share the Cline logs from when this occurs? (They would help identify whether it's using replace_in_file vs APPLY_PATCH)

    Existing safeguards

    Cline already has a maxConsecutiveMistakes setting (default: 3) that should pause and ask for guidance when this happens repeatedly. There's also a recent PR (#8189) that auto-fails tasks in YOLO mode when this limit is hit. However, the core issue is that the model keeps retrying the same failing pattern.

    Workarounds

    From #4384 comments, some users have had success adding custom instructions like:

    "For replace_in_file tool, ensure you use correct indentation. If search and replace does not work after 2 attempts, fall back to write_to_file or ask the user for help."

    SME Reason
    @abeatrix Authored the APPLY_PATCH tool PR #8167 and handles streaming/diff edit issues
    @arafatkatze Active on file editing reliability, authored auto-fail PR #8189

    Possible Duplicates:

  6. added
    Bot RespondedIssue has received an automated response
    and removed on Dec 21, 2025
  7. saoudrizwan commented on Dec 21, 2025

    @saoudrizwan
    Contributor

    hey! we tracked this down to a bug with recent changes to native tool calling and parallel tool calling. fix is coming in the next release 🙏

  8. RuntimeRacer commented on Jan 4, 2026

    @RuntimeRacer

    Still an Issue in Cline v3.46.1; had these issues repeatedly during last few days. Sorry for cross posting; it's just super annoying. Steals time and token budget.
    Image

  9. BlackDahlia313 commented on Feb 11, 2026

    @BlackDahlia313

    I am having this issue and I am using claude. Like Cline has become useless to me now.

  10. ClineXDiego commented on Mar 24, 2026

    @ClineXDiego
    Contributor

    Thanks for the report. PR #9933 was just merged — it adds detection for repeated identical tool calls, which should catch the repeating search pattern issue. Expect the fix in the next release. Feel free to reopen if you still see it after updating.

  11. riverar commented on May 15, 2026

    @riverar

    Stiill seeing this in 3.83.0 w/ gemma-4-26B-A4B-it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bot RespondedIssue has received an automated responseInvestigation NeededRequires debugging or root cause analysisModel QualityIssues caused by model limitations, not Cline bugsVS CodeIssues specific to VS Code

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions