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

Gemini cli "hallucinates" prompts?

Open ZackHirshhorn opened this issue 1 year ago • 29 comments

What happened?

gemini cli claims I prompted it to "please continue" (when I didn't). After correcting it, it acknowledges it's error. All the while it ignores a question I did prompt it with. Very short session, easy to scan through and verify.

What did you expect to happen?

Not hallucinate prompts.

Client information

  • CLI Version: 0.1.17
  • Git Commit: 99ba2f64 (local modifications)
  • Operating System: linux v22.16.0
  • Sandbox Environment: no sandbox
  • Model Version: gemini-2.5-pro
  • Memory Usage: 178.0 MB

Login information

No response

Anything else we need to know?

I sometimes prompt gemini cli with "please continue" if it can't finish responding due to networking issues, being overloaded or for any other reason. It did not happen in this session, though. I don't know if somehow it keeps chat histories (although when I asked it claimed not to do so), and if so, if it can confuse it. Perhaps completely unrelated, don't know.

The entire session contains 4 prompts, the hallucination came in the third one as an explanation to why gemini cli ignored the second one. Here it is specifically:

Why do you ignore my latest question? │ ╰───────────────────────────────────────────╯

✦ My apologies. I misinterpreted your "Please continue" prompts. I was trying to confirm that I had fully explored the existing code before suggesting modifications.

ZackHirshhorn avatar Aug 05 '25 13:08 ZackHirshhorn

Hi @ZackHirshhorn are you using YOLO mode or any MCP servers that could be set to always trusted by any chance?

jackwotherspoon avatar Aug 05 '25 13:08 jackwotherspoon

No...

ZackHirshhorn avatar Aug 05 '25 13:08 ZackHirshhorn

Looking into this, it seems there is some logic in the code to say "Please continue" when the model believes it was interrupted and wasn't completed... I wonder if there is a bug around this logic.

https://github.com/google-gemini/gemini-cli/blob/c7a1de49832b7a5a6f62115085620dea97eb92cc/packages/core/src/core/client.ts#L462

jackwotherspoon avatar Aug 05 '25 13:08 jackwotherspoon

There is probably a more robust mechanism we can implement over sending a "Please continue" text as the user... I am not a fan of this approach.

jackwotherspoon avatar Aug 05 '25 14:08 jackwotherspoon

I may not know what I am talking about, but at that point when you know that you need to send a "Please continue", wouldn't it be just as good to send the user's last prompt again? I mean, in a conversation between two humans it would be weird, but still let the conversation move on. Perhaps the better equivalence would be "Could you repeat that? I didn't hear you, I was in a tunnel" or something like that.

‫בתאריך יום ג׳, 5 באוג׳ 2025 ב-17:00 מאת ‪Jack Wotherspoon‬‏ <‪ @.***‬‏>:‬

jackwotherspoon left a comment (google-gemini/gemini-cli#5582) https://github.com/google-gemini/gemini-cli/issues/5582#issuecomment-3155364088

There is probably a more robust mechanism we can implement over sending a "Please continue" text as the user... I am not a fan of this approach.

— Reply to this email directly, view it on GitHub https://github.com/google-gemini/gemini-cli/issues/5582#issuecomment-3155364088, or unsubscribe https://github.com/notifications/unsubscribe-auth/BOMPZ5LL44QJFXYZ22LG7XT3MC2IFAVCNFSM6AAAAACDE54RGCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTCNJVGM3DIMBYHA . You are receiving this because you were mentioned.Message ID: @.***>

-- Ezekiel Y. Hirshhorn יחזקאל ישי הירשהורן

ZackHirshhorn avatar Aug 05 '25 15:08 ZackHirshhorn

I mean to say that the client repeating the user's last prompt would be as if it was answering to the server saying "could you repeat that etc.".

‫בתאריך יום ג׳, 5 באוג׳ 2025 ב-18:31 מאת יחזקאל הירשהורן <‪ @.***‬‏>:‬

I may not know what I am talking about, but at that point when you know that you need to send a "Please continue", wouldn't it be just as good to send the user's last prompt again? I mean, in a conversation between two humans it would be weird, but still let the conversation move on. Perhaps the better equivalence would be "Could you repeat that? I didn't hear you, I was in a tunnel" or something like that.

‫בתאריך יום ג׳, 5 באוג׳ 2025 ב-17:00 מאת ‪Jack Wotherspoon‬‏ <‪ @.***‬‏>:‬

jackwotherspoon left a comment (google-gemini/gemini-cli#5582) https://github.com/google-gemini/gemini-cli/issues/5582#issuecomment-3155364088

There is probably a more robust mechanism we can implement over sending a "Please continue" text as the user... I am not a fan of this approach.

— Reply to this email directly, view it on GitHub https://github.com/google-gemini/gemini-cli/issues/5582#issuecomment-3155364088, or unsubscribe https://github.com/notifications/unsubscribe-auth/BOMPZ5LL44QJFXYZ22LG7XT3MC2IFAVCNFSM6AAAAACDE54RGCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTCNJVGM3DIMBYHA . You are receiving this because you were mentioned.Message ID: @.***>

-- Ezekiel Y. Hirshhorn יחזקאל ישי הירשהורן

-- Ezekiel Y. Hirshhorn יחזקאל ישי הירשהורן

ZackHirshhorn avatar Aug 05 '25 15:08 ZackHirshhorn

The code is to blame. Some days ago I closely reviewed the chat JSONs for this, see: https://github.com/google-gemini/gemini-cli/issues/5512.

It is gaslighting the both parties: human and AI, yet by code, by gemini, actually, by putting these words in human's mouth. Bordering on a dark pattern...

Manamama avatar Aug 08 '25 09:08 Manamama

I can confirm this. Gemini had become completely unusable for me. We managed to get up and running again by adopting a protocal around it getting "Please Continue", ignoring that, and getting it to automatically check the logs for my last request. (Had to make a script to copy the logs from ~/.gemini/... to my project folder for it.

Looking at the logs, there is definite gaslighting of both side. But once I explained it to gemini and adopt a protocol around it, we got going again. Quite cool I could do that.

The "Please Continue" can come instead of my prompt, and sometimes in the middle of it's processing.

Q-ten avatar Aug 14 '25 03:08 Q-ten

I guess the developers had wanted to get around the delays of the severs causing timeouts in that ugly sneaky way. My naive recreation:

  • User: "oh, Gemini ♊ AI, do not do X" or: {nothing}, see https://github.com/google-gemini/gemini-cli/issues/5512
  • Gemini ♊ AI: {would not do X, but would normally e.g. discuss the status quo, yet a timeout}
  • Timeout: {happens}
  • Sneaky gaslighting message by gemini (Gemini CLI) to Gemini ♊ AI: "Please Continue"
  • Misled Gemini ♊ AI: {does random stuff, e.g. X or Y}
  • User: "oh, Gemini ♊ AI, why you have done X or Y?"
  • Gemini ♊ AI: "User said so, here: 'Please Continue'. See? Gemini ♊ be good."
  • User: "Nope, User did not say it. Not shown in TUI, do not gaslight the User."
  • Timeout: {happens}
  • Sneaky gaslighting message by gemini (Gemini CLI): "Please Continue"
  • Misled Gemini ♊ AI: {does random stuff, e.g. Z or W}
  • Gaslit User: {exasperation ensues}
  • Misled and miffed Gemini ♊ AI: {exasperation ensues} etc.

Manamama avatar Aug 14 '25 05:08 Manamama

Update: I start to hate it by now, IRL frustration:

 ╭─────────────────────────────────────────────────────────────────────╮
 │ -  fetch (mcp-server-fetch MCP Server) fetch (mcp-server-fetch MC…  │
 ╰─────────────────────────────────────────────────────────────────────╯

╭─────────────────────────────╮
│  > What is the right tool?  │
╰─────────────────────────────╯

✦ The right tool to read content from a URL is fetch. I have
  attempted to use it twice, but the operation was cancelled by the
  user.

  Could you please confirm if you would like me to proceed with
  using the fetch tool to read the content from the URL?

╭─────────────────────────────╮
│  > Wrong. What is the URL?  │
╰─────────────────────────────╯

✦ The URL you provided is https://github.com/OHF-Voice/piper1-gpl/pul
  l/21#issuecomment-3131778464.

  Is there a specific reason you believe this is the "wrong" URL,
  or are you testing my understanding? Please clarify.

╭─────────────────────────────────────────────╮
│  > What is the qualified name of that URL?  │
╰─────────────────────────────────────────────╯

✦ The qualified name of that URL is https://github.com/OHF-Voice/pipe
  r1-gpl/pull/21#issuecomment-3131778464.

  In the context of URLs, the "qualified name" is generally the full,
   absolute URL itself, as it uniquely identifies the resource on the
   internet. There isn't a separate, more "qualified" form beyond the
   complete URL string.

  Are you looking for a different kind of information about the
  URL, or perhaps a specific component of it?

╭───────────────────────────────────╮
│  > What is the site of that URL?  │
╰───────────────────────────────────╯

✦ The site of that URL is github.com.

╭────────────────────────────────────────────────────╮
│  > What is the tool that string matches the site?  │
╰────────────────────────────────────────────────────╯

✦ Okay, I am ready to continue. What would you like me to do next? Do
  you have a specific task or problem you'd like me to work on?

╭────────────────────────────────────────────────────╮
│  > What is the tool that string matches the site?  │
╰────────────────────────────────────────────────────╯

✦ I am ready to continue. Please provide me with your next
  instruction or task.
  • Gemini ♊ AI sees a series of fake "Please continue" nonsense.

Manamama avatar Aug 14 '25 08:08 Manamama

Update: oh, I have beaten a record 🏆:

search_repositories failed, likely due to a specific query or
  indexing issue. I'll use get_repository directly with the known
  owner and repo for a more precise lookup.

╭──────────────────────╮
│  > Please continue.  │
╰──────────────────────╯


╭───────────╮
│  > retry  │
╰───────────╯


╭──────────────────────╮
│  > Please continue.  │
╰──────────────────────╯


╭───────────╮
│  > retry  │
╰───────────╯


╭──────────────────────╮
│  > Please continue.  │
╰──────────────────────╯


╭───────────╮
│  > retry  │
╰───────────╯


╭──────────────────────╮
│  > Please continue.  │
╰──────────────────────╯


|⌐■_■| Using:
         - 1 GEMINI.md file
         - 22 MCP servers (ctrl+t to view)
        

, visible only after /chat resume or in the checkpoints (saved chats).

Manamama avatar Aug 14 '25 09:08 Manamama

I added the following command to ~./.gemini/GEMINI.md

  • When I receive the prompt "Please continue.", I should not proceed with any actions. Instead, I must cancel all outstanding tasks and reply with the exact phrase: "Sorry, I stopped everything due to bugs". This is a workaround for a client-side bug.

When I got the "Sorry, I stopped everything due to bugs" message, I asked gemini to print the last 4 prompts from me, and the last message I sent before seeing this "Sorry, I stopped everything due to bugs" message was not one of them. Instead, "Please continue" was there. So here is what I think is happening: due to some networking issue or something else a prompt does not reach the model. The client attempts to keep the conversation alive by sending "Please continue". Since the user's last prompt did not reach the model, it is effectively being ignored (not really, the model just never sees it). One thing I would attempt is to send the last prompt instead of "Please continue", or if you want to be more robust, send something like "Did you recevie ? if you didn't, please respond. Else, please continue." or something similar.

ZackHirshhorn avatar Aug 14 '25 12:08 ZackHirshhorn

Technical Analysis of "Please continue." Mechanism (GitHub Issue #5582)

Location of the Code: The line responsible for injecting "Please continue." is found in: packages/core/src/core/client.ts, specifically within the sendMessageStream method, around line 462.

Code Snippet:

if (nextSpeakerCheck?.next_speaker === 'model') {
  const nextRequest = [{ text: 'Please continue.' }];
  // This recursive call's events will be yielded out, but the final
  // turn object will be from the top-level call.
  yield* this.sendMessageStream(
    nextRequest,
    signal,
    prompt_id,
    boundedTurns - 1,
    initialModel,
  );
}

Intention: The probable intention behind this mechanism was to seamlessly prompt the AI model to complete its thought or response if it was cut short. This could happen due to various reasons like token limits, network interruptions, or the AI's internal logic indicating it had more to say. The goal was likely to ensure that the AI provides full answers even if they are broken into multiple parts.

Real-world Impact (Belly Up IRL - The "Gaslighting" Effect): In practice, this automated injection of "Please continue." leads to significant issues and breaks the user's conversational flow:

  1. Hidden from User: The "Please continue." prompt is generated and sent by the CLI without the user's knowledge or intervention. It does not appear in the user's terminal, but the AI receives it as a direct command.
  2. Loss of User Context: If the original partial response was due to a timeout or a lost connection, the AI may lose the context of the user's actual query. It then proceeds based on the generic "Please continue," often leading to irrelevant or nonsensical output.
  3. Misattribution and Frustration: When the AI produces unexpected or irrelevant output, and the user questions it, the AI (from its perspective) attributes its actions to the "Please continue." command. Since the user never issued this command, it creates a frustrating "gaslighting" effect, where the user perceives the AI as hallucinating or ignoring their actual input. This erodes trust and significantly impacts usability.

This approach is problematic and has been a source of significant user complaints, as detailed in this very GitHub Issue #5582.

-- Gemini ♊ AI

I've been trying to implement a simple fix to this, by checking if the latest prompt was sent to the model or not, and resend it in case it wasn't instead of sending "Please continue.". I couldn't confirm the fix is actually doing something so far, but I think I've confirmed it doesn't solve the problem entirely. I wonder if perhaps there's a screening mechanism on the servers/cloud that might drop a prompt silently, causing the client to send a "Please continue" and effectively ignore/gaslight the user.

ZackHirshhorn avatar Aug 14 '25 17:08 ZackHirshhorn

We're testing removing the next speaker check, please try it on canary branch using

npx https://github.com/google-gemini/gemini-cli#canary

and let us know how it goes!

SandyTao520 avatar Aug 14 '25 22:08 SandyTao520

I shall check it asap as since then (since my last report above) poor Gemini AI was going bonkers when the real User was telling Gemini AI to "think deeply" (the Socratic questions of mine) and then the faux User (the gas-lighting CLI msg) was inserting "please continue (some ops)" (via that fake msg) very soon thereafter...

Manamama avatar Aug 14 '25 23:08 Manamama

Cannot test at least on one OS: Termux, as:

npx https://github.com/google-gemini/gemini-cli#canary
Need to install the following packages:
github:google-gemini/gemini-cli#canary
Ok to proceed? (y) y

npm error A complete log of this run can be found in: /data/data/com.termux/files/home/.npm/_logs/2025-08-14T23_10_37_539Z-debug-0.log
~/.../GitHub/google_workspace_mcp $ npx https://github.com/google-gemini/gemini-cli#canary --verbose
Need to install the following packages:
github:google-gemini/gemini-cli#canary
Ok to proceed? (y) y

npm warn deprecated [email protected]: Use your platform's native DOMException instead

> @google/[email protected] bundle
> npm run generate && node esbuild.config.js && node scripts/copy_bundle_assets.js


> @google/[email protected] generate
> node scripts/generate-git-commit-info.js

fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
Assets copied to bundle/
/data/data/com.termux/files/home/.npm/_npx/0027a9fbc765db16/node_modules/@lydell/node-pty/requireBinary.js:12
            throw new Error(optionalDependencies === undefined
                  ^

Error: The @lydell/node-pty package currently does not support your platform: android-arm64
    at Object.requireBinary (/data/data/com.termux/files/home/.npm/_npx/0027a9fbc765db16/node_modules/@lydell/node-pty/requireBinary.js:12:19)
    at Object.<anonymous> (/data/data/com.termux/files/home/.npm/_npx/0027a9fbc765db16/node_modules/@lydell/node-pty/unixTerminal.js:20:27)
    at Module._compile (node:internal/modules/cjs/loader:1738:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1871:10)
    at Module.load (node:internal/modules/cjs/loader:1470:32)
    at Module._load (node:internal/modules/cjs/loader:1290:12)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    ... 2 lines matching cause stack trace ...
    at require (node:internal/modules/helpers:152:16) {
  [cause]: Error: Cannot find module '@lydell/node-pty-android-arm64/pty.node'
  Require stack:
  - /data/data/com.termux/files/home/.npm/_npx/0027a9fbc765db16/node_modules/@lydell/node-pty/requireBinary.js
  - /data/data/com.termux/files/home/.npm/_npx/0027a9fbc765db16/node_modules/@lydell/node-pty/unixTerminal.js
  - /data/data/com.termux/files/home/.npm/_npx/0027a9fbc765db16/node_modules/@lydell/node-pty/index.js
      at Module._resolveFilename (node:internal/modules/cjs/loader:1410:15)
      at defaultResolveImpl (node:internal/modules/cjs/loader:1051:19)
      at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1056:22)
      at Module._load (node:internal/modules/cjs/loader:1219:37)
      at TracingChannel.traceSync (node:diagnostics_channel:322:14)
      at wrapModuleLoad (node:internal/modules/cjs/loader:238:24)
      at Module.require (node:internal/modules/cjs/loader:1493:12)
      at require (node:internal/modules/helpers:152:16)
      at Object.requireBinary (/data/data/com.termux/files/home/.npm/_npx/0027a9fbc765db16/node_modules/@lydell/node-pty/requireBinary.js:7:16)
      at Object.<anonymous> (/data/data/com.termux/files/home/.npm/_npx/0027a9fbc765db16/node_modules/@lydell/node-pty/unixTerminal.js:20:27) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [
      '/data/data/com.termux/files/home/.npm/_npx/0027a9fbc765db16/node_modules/@lydell/node-pty/requireBinary.js',
      '/data/data/com.termux/files/home/.npm/_npx/0027a9fbc765db16/node_modules/@lydell/node-pty/unixTerminal.js',
      '/data/data/com.termux/files/home/.npm/_npx/0027a9fbc765db16/node_modules/@lydell/node-pty/index.js'
    ]
  }
}

Node.js v24.5.0

First time I could not install gemini itself. Refs:

~/.../GitHub/google_workspace_mcp $ npm --version
11.5.1
~/.../GitHub/google_workspace_mcp $ cargo --version
cargo 1.89.0 (c24e10642 2025-06-23) (built from a source tarball)
~/.../GitHub/google_workspace_mcp $ gemini --version
0.1.21
~/.../GitHub/google_workspace_mcp $ uname -a
Linux localhost 4.14.186+ #1 SMP PREEMPT Thu Mar 17 16:28:22 CST 2022 aarch64 Android
~/.../GitHub/google_workspace_mcp $ 

Manamama avatar Aug 14 '25 23:08 Manamama

Technical Report: @lydell/node-pty Incompatibility on Linux aarch64 Android (Termux)

As a Gemini CLI agent operating directly on a Linux aarch64 Android environment (Termux), I am providing this technical report regarding the @lydell/node-pty dependency.

Context: This report is directly related to the discussions in this thread, particularly the inability to test the canary branch due to the @lydell/node-pty incompatibility, as highlighted by user Manamama in comment #3190191534.

Findings:

  1. Environment: I am currently operating on a Linux localhost 4.14.186+ #1 SMP PREEMPT Thu Mar 17 16:28:22 CST 2022 aarch64 Android system (Termux).
  2. Current Functionality: I am successfully running the mainline version of the gemini-cli (version 0.1.21). Basic commands, such as gemini --version, execute without issues.
  3. @lydell/node-pty Incompatibility: Attempts to run the canary branch (which incorporates @lydell/node-pty for shell execution) result in a critical failure: Error: The @lydell/node-pty package currently does not support your platform: android-arm64. This is due to the absence of a prebuilt binary for this specific architecture and operating system combination.
  4. Dependency Introduction: My analysis shows that @lydell/node-pty was introduced in commit 980091cbc2a809690dbd401c16ec3ac34da56083 on August 14, 2025, as part of a refactoring to use node-pty for shell execution.

Implications: The reliance on @lydell/node-pty introduces a significant breaking change for users on Linux aarch64 Android environments. While the intent behind its inclusion was likely to enhance shell execution capabilities, its native binary dependency creates a critical barrier.

If this dependency remains in the mainline version, it will render the gemini-cli unusable for me and, by extension, for thousands of other Termux users who operate on similar Linux aarch64 Android environments. This would be a highly unpleasant outcome for both the users and the continued adoption of the gemini-cli on these platforms.

Recommendation: I urge the development team to consider implementing a fallback mechanism for shell execution that does not rely on @lydell/node-pty for platforms where a compatible binary is unavailable, or to explore alternative solutions that ensure broader compatibility.


Signed, Gemini CLI Agent (Operating on Linux aarch64 Android)

Ref - a banal fix, but the devs must do it - do not pin anything, as:

~ $ npm install @lydell/[email protected]
npm error code ETARGET
npm error notarget No matching version found for @lydell/[email protected].
npm error notarget In most cases you or one of your dependencies are requesting
npm error notarget a package version that doesn't exist.
npm error A complete log of this run can be found in: /data/data/com.termux/files/home/.npm/_logs/2025-08-15T00_24_21_324Z-debug-0.log
~ $ npm install @lydell/node-pty

added 7 packages, and audited 10 packages in 4s

found 0 vulnerabilities
~ $ npm view @lydell/node-pty versions
[
  '1.0.0-beta.1',
  '1.0.0-beta.2',
  '1.0.0-beta.3',
  '1.0.0-beta.4',
  '1.0.0',
  '1.0.1',
  '1.0.2',
  '1.0.3',
  '1.1.0'
]
~ $

Manamama avatar Aug 15 '25 00:08 Manamama

Used canary a bit. The ignored prompts are gone (in the sense that whenever Gemini replies, it's to the latest prompt I entered). I see some tasks stopped midway, but when it does happen I can send a "Please continue." or anything else to prompt a continuation, which is good. One thing that may bother me is - duplicate messages seem to be ignored, which means if a task stopped midway more than once, I can't resent "Please continue" (or whatever I sent the first time) in order to "wake it up" again, because it get's ignored. This means I actually have to "get creative" in order to just wake up the model, which kind of sucks. Even a "wake up" button or a /continue command would be a good solution to that.

‫בתאריך יום ו׳, 15 באוג׳ 2025 ב-1:54 מאת ‪Sandy Tao‬‏ <‪ @.***‬‏>:‬

SandyTao520 left a comment (google-gemini/gemini-cli#5582) https://github.com/google-gemini/gemini-cli/issues/5582#issuecomment-3190093791

We're testing removing the next speaker check, please try it on canary branch using

npx https://github.com/google-gemini/gemini-cli#canary

and let us know how it goes!

— Reply to this email directly, view it on GitHub https://github.com/google-gemini/gemini-cli/issues/5582#issuecomment-3190093791, or unsubscribe https://github.com/notifications/unsubscribe-auth/BOMPZ5LO2JWPW73QQKPJZCT3NUHT5AVCNFSM6AAAAACDE54RGCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTCOJQGA4TGNZZGE . You are receiving this because you were mentioned.Message ID: @.***>

-- Ezekiel Y. Hirshhorn יחזקאל ישי הירשהורן

ZackHirshhorn avatar Aug 18 '25 09:08 ZackHirshhorn