gemini-cli icon indicating copy to clipboard operation
gemini-cli copied to clipboard

Message history does not register cancel commands

Open shrishabh opened this issue 1 year ago • 2 comments

What happened?

When working with gemini-cli to write code, if I cancel the code edit, the edit is cancelled but the agent never registers that the edit was cancelled and works with the assumption that it made the edit. This leads to compounding of errors it codes further.

Example:

  I will add the rm check directly into the PolicyEngine. I'll start by reading the policy-engine.ts file to find the right place to insert the logic.
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ✓  ReadFile ...kages/core/src/policy/policy-engine.ts                                                                                                │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
✦ Okay, I see how the PolicyEngine works. I will add the temporary rm check at the beginning of the check method. This will ensure it runs before any
  other rules.

At this point, I cancelled the edit request and instructed it to add the code in a different place. After implementing, it goes:

I have applied the hack to the policy-enforcer.ts file. Now, I will revert the change I made to policy-engine.ts since the logic is now in the correct place.

But it never registers that policy-engine.ts was never changed.

What did you expect to happen?

I expected it to register that it never made a change to policy-engine.ts and hence there is no need to revert the change.

Client information

About Gemini CLI │ │ │ │ CLI Version 0.10.0-nightly.20251007.c195a9aa-git.0dea3544 │ │ Git Commit 0dea3544 │ │ Model gemini-2.5-pro │ │ Sandbox no sandbox │ │ OS darwin │ │ Auth Method gemini-api-key │ │ IDE Client VS Code

Login information

API Key

Anything else we need to know?

I do not know if this is a bug or just the model being bad, but I have seen this behavior multiple times.

shrishabh avatar Oct 21 '25 02:10 shrishabh

Fyi @anj-s this seems more like a quality issue

jacob314 avatar Oct 30 '25 01:10 jacob314

I have seen this many, many times too. It often leads to wasted time as the model tries to revert changes that were never applied.

taladar avatar Dec 08 '25 11:12 taladar

This bug causes the agent's internal state to become inconsistent after a user cancels a command, leading to incorrect subsequent actions. This impacts core session management.

gemini-cli[bot] avatar Jan 07 '26 23:01 gemini-cli[bot]

Hello! As part of our effort to keep our backlog manageable and focus on the most active issues, we are tidying up older reports.

It looks like this issue hasn't been active for a while, so we are closing it for now. However, if you are still experiencing this bug on the latest stable build, please feel free to comment on this issue or create a new one with updated details.

Thank you for your contribution!

gemini-cli[bot] avatar Jan 25 '26 00:01 gemini-cli[bot]