-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: improve diff editing error messages for Qwen3 model compatibility #7248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Clarified error messages to distinguish between diff structure markers and file content - Added explicit guidance that diff markers should NEVER be escaped in the structure - Emphasized that escaping is only needed for markers within file content being modified - Maintained backward compatibility with existing test expectations This fixes issue #7247 where Qwen3 235B model was confused by error messages and tried to escape diff structure markers, causing diff editing to fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reviewed my own code and found it has more issues than a magazine subscription service.
| public settingsImportedAt?: number | ||
| public readonly latestAnnouncementId = "jul-29-2025-3-25-0" // Update for v3.25.0 announcement | ||
| public readonly latestAnnouncementId = "aug-20-2025-stealth-model" // Update for stealth model announcement | ||
| public readonly providerSettingsManager: ProviderSettingsManager |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this intentional? This file contains changes for a 'stealth model announcement' feature that seems completely unrelated to the diff editing error message improvements described in the PR. Should this be in a separate PR to keep changes focused?
| <Trans | ||
| i18nKey="chat:announcement.feature3" | ||
| i18nKey="chat:announcement.stealthModel.feature" | ||
| components={{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These announcement UI changes appear unrelated to fixing Qwen3 diff editing issues. Consider splitting these changes into a separate PR for better change tracking and review clarity.
| "<<<<<<< SEARCH\n" + | ||
| "content before\n" + | ||
| `\\${found} <-- Note the backslash here in this example\n` + | ||
| `\\${found} <-- Escape ONLY when this is part of the file content\n` + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor inconsistency: This line has 4 spaces after the escape example while the same line in multi-file-search-replace.ts has only 1 space. Consider making the formatting consistent across both files.
| When applying the diffs, be extra careful to remember to change any closing brackets or other syntax that may be affected by the diff farther down in the file. | ||
| ALWAYS make as many changes in a single 'apply_diff' request as possible using multiple SEARCH/REPLACE blocks | ||
| **IMPORTANT ESCAPING RULES:** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new escaping rules section is helpful! Could we add one more example showing what happens when these patterns appear in actual file content vs. diff markers? This would make it even clearer for AI models.
|
Not scoped yet |
Fixes #7247
Summary
This PR improves the error messages in the diff editing system to better support the Qwen3 235B Instruct model, which was having trouble with diff editing due to confusing error messages about escaping.
Problem
The Qwen3 model was receiving error messages that told it to escape "=======" and other diff markers, but the messages didn't clearly distinguish between:
This confusion caused the model to try escaping the diff structure markers themselves, leading to failed diff edits.
Solution
Changes Made
reportMergeConflictErrorin both diff strategy files to clarify when escaping is neededreportInvalidDiffErrorto maintain backward compatibility while improving clarityTesting
npx vitest run core/diff/strategies/__tests__/multi-search-replace.spec.ts)Impact
This change will help AI models (especially Qwen3 and similar models) better understand when to escape special characters in diff operations, reducing confusion and improving success rates for diff editing operations.
Important
Improves diff editing error messages for Qwen3 model by clarifying escaping rules and updating tool descriptions in strategy files.
multi-file-search-replace.tsandmulti-search-replace.tsto specify that diff structure markers should never be escaped.latestAnnouncementIdinClineProvider.tsfor stealth model announcement.Announcement.tsxto support new features.This description was created by
for 4d36750. You can customize this summary. It will automatically update as commits are pushed.