gemini-cli - 💡(How to fix) Fix [Bug] Multiple sequential edits to the same file are lost - only the last one persists (after fix #8513) [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
google-gemini/gemini-cli#25868Fetched 2026-04-24 06:13:45
View on GitHub
Comments
1
Participants
2
Timeline
3
Reactions
1
Timeline (top)
commented ×1labeled ×1subscribed ×1

Fix Action

Fix / Workaround

References:

  • Original issue: #8372 (closed as fixed by #8513)
  • PR that was supposed to fix it: #8513
RAW_BUFFERClick to expand / collapse

What happened?

Description: After the fix in PR #8513 ("Serialize function calls that mutate state"), the bug of multiple edits on the same file still occurs.

When the model performs multiple sequential edits on the same file (even when each edit is individually accepted with ✓ Edit ... → Accepted), only the last edit is persisted. All previous edits are lost/overwritten.

Steps to Reproduce:

  1. Ask Gemini CLI to make changes to a file (in my case update_prompts_v7.sql)
  2. The model proposes edit 1 → I accept it
  3. The model proposes edit 2 on the same file → I accept it
  4. The model proposes edit 3 on the same file → I accept it
  5. Only the 3rd edit remains. Edits 1 and 2 are gone.

What did you expect to happen?

All accepted edits should be applied sequentially and persist in the file.

Actual behavior: Only the last accepted edit is kept. Previous edits are discarded.

Client information

  • CLI Version: 0.39.0
  • Git Commit: 398f78dca
  • Session ID: 2d20a950-0729-40c7-a778-3d937abf3493
  • Operating System: linux v20.19.2
  • Sandbox Environment: no sandbox
  • Model Version: gemini-3.1-pro-preview
  • Auth Type: oauth-personal
  • Memory Usage: 443.4 MB
  • Terminal Name: Unknown
  • Terminal Background: #1e1e1e
  • Kitty Keyboard Protocol: Unsupported

Login information

No response

Anything else we need to know?

  • I have strong rules in GEMINI.md telling the model to never do multiple edits on the same file and to always plan everything in one edit, but it still happens.
  • This occurs even though each edit is confirmed individually.
  • The problem was supposedly fixed in #8513, but it is still reproducible in April 2026.

References:

  • Original issue: #8372 (closed as fixed by #8513)
  • PR that was supposed to fix it: #8513

This is a critical reliability issue for using Gemini CLI in real development workflows.

extent analysis

TL;DR

The issue may be resolved by re-examining the implementation of the fix in PR #8513, specifically the serialization of function calls that mutate state, to ensure that all accepted edits are properly persisted.

Guidance

  • Review the code changes made in PR #8513 to verify that the serialization of function calls correctly handles multiple sequential edits on the same file.
  • Check the logic for accepting and applying edits to ensure that each accepted edit is properly persisted before the next edit is applied.
  • Investigate the possibility of a race condition or other concurrency issue that could cause previous edits to be overwritten.
  • Consider adding additional logging or debugging statements to track the state of the file and the edits being applied to help identify the root cause of the issue.

Example

No code snippet is provided as the issue does not contain sufficient information to create a specific example.

Notes

The issue may be related to the implementation of the fix in PR #8513, and re-examining this code may be necessary to resolve the issue. Additionally, the problem may be specific to the Gemini CLI version 0.39.0 or the gemini-3.1-pro-preview model version.

Recommendation

Apply workaround: Revert to a previous version of the Gemini CLI or model that did not exhibit this issue, if possible, until a proper fix can be implemented and verified.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

gemini-cli - 💡(How to fix) Fix [Bug] Multiple sequential edits to the same file are lost - only the last one persists (after fix #8513) [1 comments, 2 participants]