Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refactors the file writing and content correction mechanisms to prevent overaggressive unescaping, particularly when interacting with newer language models. By consolidating correction logic and introducing model-aware unescaping, the system ensures more accurate and predictable file modifications, addressing issues where content was incorrectly altered due to excessive escaping. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a significant refactoring to the file writing logic to prevent overaggressive unescaping of content, especially with newer models. The core change is the removal of the complex ensureCorrectEdit function, unifying the logic for both new and existing file writes under a simplified ensureCorrectFileContent function. A new aggressiveUnescape flag has been added, which is conditionally set based on the active Gemini model version. For Gemini 3.0 and newer models, aggressive unescaping is disabled, addressing the issue of incorrect content modification. For older models, the existing unescaping behavior is preserved. The tests have been thoroughly updated to reflect these changes, removing mocks for the deprecated ensureCorrectEdit and adding necessary mocks for getActiveModel. The changes simplify the codebase, improve maintainability, and correctly fix the reported bug. The implementation appears solid and well-tested.
|
Size Change: -17.5 kB (-0.07%) Total Size: 25.7 MB
ℹ️ View Unchanged
|
| mockBaseLlmClientInstance, | ||
| abortSignal, | ||
| true, | ||
| true, // aggressiveUnescape |
There was a problem hiding this comment.
can you also added a test without aggressiveUnescape to verify the behavior there. Consider parameterizing all these tests to run with. and without aggressiveUnescape with modified expectations for each cases

Summary
When using newer models, don't aggressively unescape file writes.
Details
This makes two changes to write_file:
The first change is safe because the only difference between the two old paths was that with
disableLLMCorrection=false, the overwrite path's call to the LLM included the old file contents which isn't super useful for figuring out if the new value is correctly escaped (it might even make performance worse). And anyways,disableLLMCorrection=trueby default so this is unlikely to affect many users.Note also: The reason why we had this difference in the first place was that we were treating an overwrite like an "edit where you replace the whole text". However, when we moved to smart-edit, the edit tool stopped using that codepath so the overwrite case was the only thing using that code (and most of it was dead code that could never be visited with the way overwrite was calling it).
Related Issues
Fixes #19802
How to Validate
Ask
Pre-Merge Checklist