gemini-cli - 💡(How to fix) Fix run_shell_command triggers infinite UI loop output on Windows, consuming 99% of session tokens. [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#25615Fetched 2026-04-19 15:22:57
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Timeline (top)
labeled ×3commented ×1
RAW_BUFFERClick to expand / collapse

What happened?

  • Environment: Gemini CLI v0.38.2, Windows 10, PowerShell 5.1.
  • Reproduction Steps:
    1. Agent executes run_shell_command("gemini "/stats model"") inside a Windows PowerShell environment.
    2. The command triggers a recursive UI refresh or ANSI escape sequence loop.
    3. The output exceeds 11,000,000 characters.
  • Impact: The massive garbage output (terminal codes) is added to the session context, leading to immediate 99% context/token usage and causing the UI to freeze/show "garbage" characters.

What did you expect to happen?

  • Expected Behavior: The CLI should detect recursive execution or limit the raw byte output from sub-processes to prevent token exhaustion.

Client information

  • CLI Version: 0.38.2
  • Git Commit: b0ed611a0
  • Session ID: aebae1e6-3690-47e3-8ced-0cd1c7e0856d
  • Operating System: win32 v24.15.0
  • Sandbox Environment: no sandbox
  • Model Version: gemini-3-flash-preview
  • Auth Type: oauth-personal
  • Memory Usage: 430.9 MB
  • Terminal Name: Unknown
  • Terminal Background: Unknown
  • Kitty Keyboard Protocol: Unsupported
  • IDE Client: VS Code

Login information

No response

Anything else we need to know?

No response

extent analysis

TL;DR

Limit the output of the gemini "/stats model" command to prevent token exhaustion and UI freezing.

Guidance

  • Investigate the run_shell_command function to see if it has an option to limit the output of the command or handle recursive execution.
  • Consider adding a wrapper around the gemini "/stats model" command to truncate or filter its output before it is added to the session context.
  • Review the Gemini CLI documentation to see if there are any configuration options or flags that can be used to limit the output of the command.
  • Check if there are any existing issues or pull requests related to output limiting or token exhaustion in the Gemini CLI repository.

Example

No code example is provided as the issue does not contain sufficient information about the implementation details of the run_shell_command function or the Gemini CLI.

Notes

The solution may require modifications to the Gemini CLI or the run_shell_command function, and may not be possible without additional information about the implementation details.

Recommendation

Apply a workaround by limiting the output of the gemini "/stats model" command, as upgrading to a fixed version is not implied in the issue.

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