Skip to content

fix(prompt): Prevent model from reverting successful changes#9253

Merged
galz10 merged 5 commits into
mainfrom
galzahavi/fix/model-revert
Sep 25, 2025
Merged

fix(prompt): Prevent model from reverting successful changes#9253
galz10 merged 5 commits into
mainfrom
galzahavi/fix/model-revert

Conversation

@galz10

@galz10 galz10 commented Sep 23, 2025

Copy link
Copy Markdown
Collaborator

TLDR

This pull request updates the core prompt for the Gemini CLI agent to prevent it from reverting its own changes after successful verification. It was observed that the model would sometimes undo its own work, such as deleting test files, after completing a task. These changes ensure that all work is preserved once it has been successfully verified.

Dive Deeper

The previous prompt was ambiguous about the final state of the work. The model, in an attempt to be "clean", would sometimes revert changes or delete files it created, especially test files. This behavior is undesirable as it destroys valuable work.

The changes in this PR address this issue by:

  1. Updating the "Proactiveness" section of the prompt to explicitly state that all created files, especially tests, should be considered permanent artifacts.
  2. Adding a new "Finalize" step to the "Software Engineering Tasks" workflow. This step explicitly instructs the model not to remove or revert any changes or created files after verification passes and to await the user's next instruction.

These changes make the prompt clearer and more explicit about the desired behavior, ensuring that the model preserves all successful work.

Reviewer Test Plan

To test this change, a reviewer can:

  1. Ask the model to perform a task that involves creating a new file (e.g., a test file).
  2. Verify that the model creates the file and runs the necessary checks.
  3. After the model confirms that the task is complete, check that the created file is still present and has not been deleted.
  4. Ask the model to make a code change and verify it.
  5. After the model confirms the change is complete, check that the code change is still present and has not been reverted.

For example, a good prompt would be: "add a test file for the function foo in foo.ts and write a simple test case for it". After the model is done, the test file should remain in the file system.

Testing Matrix

🍏 🪟 🐧
npm run
npx
Docker
Podman - -
Seatbelt - -

Linked issues / bugs

   The prompt for the CLI agent is updated to prevent the model from reverting its own changes after
   successful verification.

   - The "Proactiveness" section is updated to instruct the model to consider all created files,
   especially tests, as permanent artifacts.
   - A new "Finalize" step is added to the workflow, explicitly instructing the model not to remove
   or revert any changes or created files after verification passes.
@galz10 galz10 requested a review from a team as a code owner September 23, 2025 19:14
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @galz10, 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 enhances the reliability of the Gemini CLI agent by modifying its core prompt to ensure that successfully verified changes and created artifacts are permanently retained. Previously, the agent sometimes reverted its own work, such as deleting test files, after task completion. The updated prompt clarifies the expectation for persistence, preventing unintended data loss and improving the agent's overall consistency.

Highlights

  • Preventing Reversions: The core prompt for the Gemini CLI agent is updated to prevent it from reverting its own successful changes, particularly deleting created files like tests.
  • Explicit Permanence: The 'Proactiveness' section of the prompt now explicitly states that all created files, especially tests, should be considered permanent artifacts.
  • New Finalize Step: A 'Finalize' step has been added to the 'Software Engineering Tasks' workflow, instructing the model not to remove or revert any changes or created files after verification passes.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the core prompt to prevent the AI model from reverting its own successful changes. The changes include making the "Proactiveness" section more explicit about treating created files as permanent artifacts, and adding a new "Finalize" step to the workflow that instructs the model not to undo any work after successful verification. The wording in the "Plan" step has also been improved for clarity. These changes are well-thought-out and directly address the stated problem by providing clearer and more explicit instructions to the model. The modifications should effectively prevent the undesirable behavior of the model deleting its own work.

@github-actions

github-actions Bot commented Sep 23, 2025

Copy link
Copy Markdown

Size Change: +301 B (0%)

Total Size: 17.4 MB

ℹ️ View Unchanged
Filename Size Change
./bundle/gemini.js 17.4 MB +301 B (0%)
./bundle/sandbox-macos-permissive-closed.sb 1.03 kB 0 B
./bundle/sandbox-macos-permissive-open.sb 830 B 0 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB 0 B
./bundle/sandbox-macos-restrictive-closed.sb 3.29 kB 0 B
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB 0 B
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB 0 B

compressed-size-action

@galz10 galz10 enabled auto-merge September 25, 2025 20:47
@galz10 galz10 added this pull request to the merge queue Sep 25, 2025
Merged via the queue into main with commit 6535b71 Sep 25, 2025
17 of 18 checks passed
@galz10 galz10 deleted the galzahavi/fix/model-revert branch September 25, 2025 21:02
geoffdowns pushed a commit to geoffdowns/gemini-cli that referenced this pull request Sep 26, 2025
dtometzki pushed a commit to dtometzki/gemini-cli that referenced this pull request Sep 26, 2025
thacio added a commit to thacio/auditaria that referenced this pull request Oct 4, 2025
giraffe-tree pushed a commit to giraffe-tree/gemini-cli that referenced this pull request Oct 10, 2025
@sripasg sripasg added the size/m A medium sized PR label Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/m A medium sized PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Track and remediate whem a model reverts file changes even without errors

3 participants