Skip to content

[BUG] Separator after :start_line: in apply_diff is not validated #12210

@rkfg

Description

@rkfg

Problem (one or two sentences)

The LLM sometimes messes up the separator and writes the text to search without newline. Roo doesn't detect that and doesn't provide a meaningful error message so the model starts looping.

Context (who is affected and when)

Happens randomly with smaller consumer hardware friendly models such as Qwen 3.6

Reproduction steps

Tool call:

{
        "type": "tool_use",
        "id": "YwRzYCZxTOl9OZZLfMngeKXWTpbPZwVb",
        "name": "apply_diff",
        "input": {
          "path": "src/components/controls/MaskEditor.tsx",
          "diff": "<<<<<<< SEARCH\n:start_line:7\n-------import { useTranslate } from '../../i18n/I18nContext';\n\ntype MouseMode\n=======\nimport { useTranslate } from '../../i18n/I18nContext';\nimport { MaskEditorProvider, useMaskEditor } from './MaskEditorContext';\n\ntype MouseMode\n>>>>>>> REPLACE"
        }
      }

The problematic part is -------import { useTranslate } (missing \n after -------).
Roo responds with:

{
        "type": "tool_result",
        "tool_use_id": "YwRzYCZxTOl9OZZLfMngeKXWTpbPZwVb",
        "content": "<error_details>\nNo sufficiently similar match found at line: 7 (63% similar, needs 100%)\n\nDebug Info:\n- Similarity Score: 63%\n- Required Threshold: 100%\n- Search Range: starting at line 7\n- Tried both standard and aggressive line number stripping\n- Tip: Use the read_file tool to get the latest content of the file before attempting to use the apply_diff tool again, as the file content may have changed\n\nSearch Content:\n-------import { useTranslate } from '../../i18n/I18nContext';\n\ntype MouseMode\n\nBest Match Found:\n7 | import { useTranslate } from '../../i18n/I18nContext';\n
...

Expected result

A clear error about separator missing new line should be provided in the message so the model can recover

Actual result

The model thinks the tool is broken or that file has invalid indentation etc. and keeps making the same mistake

Variations tried (optional)

After explicitly telling the model about the separator issue and providing an example of correct call it was able to make further calls correctly.

App Version

Version: 3.53.0 (ad25634) (with #12200 applied because it really helps)

API Provider (optional)

OpenAI Compatible

Model Used (optional)

Qwen3.6 35B A3B APEX

Roo Code Task Links (optional)

No response

Relevant logs or errors (optional)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions