fix: validate separator newline in apply_diff to catch malformed ------- markers#12212
Draft
roomote-v0[bot] wants to merge 1 commit intomainfrom
Draft
fix: validate separator newline in apply_diff to catch malformed ------- markers#12212roomote-v0[bot] wants to merge 1 commit intomainfrom
roomote-v0[bot] wants to merge 1 commit intomainfrom
Conversation
…--- markers When the LLM omits the newline after the ------- separator (e.g. "-------import"), the parser silently absorbs the separator into the search content, producing a confusing "No sufficiently similar match found" error. This causes smaller models to loop without recovering. Add detection in validateMarkerSequencing for lines starting with "-------" that have non-whitespace content appended, returning a clear actionable error message that tells the model to place the separator on its own line. Closes #12210
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related GitHub Issue
Closes: #12210
Description
This PR attempts to address Issue #12210. Feedback and guidance are welcome.
When the LLM omits the newline after the
-------separator (e.g.-------import { useTranslate }), the parser silently absorbs the separator into the search content, producing a confusing "No sufficiently similar match found" error. This causes smaller models like Qwen 3.6 to loop without recovering.Implementation: Added detection in
validateMarkerSequencing(insrc/core/diff/strategies/multi-search-replace.ts) for lines starting with-------that have non-whitespace content appended. When detected, a clear, actionable error message is returned telling the model to place the separator on its own line with search content starting on the next line.Test Procedure
src/core/diff/strategies/__tests__/multi-search-replace.spec.ts::start_line:present):start_line:cd src && npx vitest run core/diff/strategies/__tests__/multi-search-replace.spec.tsPre-Submission Checklist
Documentation Updates
Additional Notes
The fix is minimal and targeted -- it only adds a check in the existing
AFTER_SEARCHstate of the marker validation state machine. The regex/^-------\S/catches lines where-------is immediately followed by a non-whitespace character (i.e. missing newline). The error message includes the trailing content to help the model understand what went wrong.Interactively review PR in Roo Code Cloud