Google AI Studio Build Mode is corrupting my large source files when Gemini 3.7 Flash is asked to make a small, surgical code change.
The files are approximately 13,000 lines each. Gemini is explicitly instructed to modify only the requested code and preserve everything else. Instead, after the edit, parts of the file become corrupted and contain large amounts of replacement characters (�), control characters, and binary-looking garbage.
This makes the source file unusable.
-
Google AI Studio / Build Mode
-
Model: Gemini 3.7 Flash
-
Windows desktop
-
Browser: Opera
-
Source files: large Java/Minecraft AI source files stored as .txt
-
File size: approximately 13,000 lines per file
-
Encoding before editing: UTF-8
-
Task: surgical modification of existing code
I have also tested different browsers, accounts, and disabled browser extensions. The problem persists.
The request was for a small, surgical modification to an existing large source file.
I specifically instructed Gemini to:
-
modify only the requested functionality
-
preserve all existing behavior
-
preserve existing combos and logic
-
avoid rewriting unrelated code
-
make a surgical change rather than regenerate the entire file
After Gemini performed the edit, the file displayed normally for part of its contents, but another section became corrupted.
The corrupted section contains things resembling:
There are also large numbers of Unicode replacement characters (�).
This is visible directly in the AI Studio code editor.
The screenshot attached to this report shows the issue occurring inside the affected file.
If Gemini is unable to safely modify a 13,000-line file, I would expect it to:
-
Refuse the operation.
-
Explain that the file is too large for reliable rewriting.
-
Ask me to provide a smaller relevant section.
-
Or make a genuine surgical patch.
It should never silently replace valid UTF-8 source code with corrupted/binary-looking content.
This is not merely an incorrect code change.
The problem is that the underlying source file can become corrupted.
A coding assistant can make an incorrect implementation and the developer can fix it. However, if the assistant damages the source file itself, it can cause loss of working code and make it difficult to determine which parts of the original file were modified.
This is especially concerning for large files where manually comparing thousands of lines is difficult.
The problem appears more likely when working with large files and asking for targeted modifications.
The affected files are around 13,000 lines, which should not be anywhere near Gemini’s advertised context capacity.
I understand that context-window size and safe file rewriting are different things. However, if AI Studio cannot reliably edit files of this size, it should avoid silently regenerating or corrupting them.
-
Is this a known Build Mode issue with large text/source files?
-
Is AI Studio recreating entire files rather than applying true surgical patches?
-
Is there a known limitation around large UTF-8 files?
-
Why can the resulting workspace file contain replacement characters and control/binary-looking data?
-
Is there a recommended maximum file size/line count for reliable Build Mode editing?
-
Is there a way to force Build Mode to apply a patch/diff instead of regenerating the entire file?
-
Can the engineering team investigate the attached example?
I would appreciate confirmation from the AI Studio team about whether this is a known issue.




