Skip to content

Fix issue where agent gets stuck at interactive commands.#18272

Merged
gundermanc merged 5 commits intomainfrom
gundermanc/interactive
Feb 4, 2026
Merged

Fix issue where agent gets stuck at interactive commands.#18272
gundermanc merged 5 commits intomainfrom
gundermanc/interactive

Conversation

@gundermanc
Copy link
Member

@gundermanc gundermanc commented Feb 4, 2026

f## Summary

Fixes an issue where the agent gets stuck at interactive commands. This builds on an earlier fix which was partially effective. Through the use of the eval test, I was able to refine the prompt a bit further.

Eval run: https://github.com/google-gemini/gemini-cli/actions/runs/21660440430

Details

Related Issues

Fixes #17708

How to Validate

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @gundermanc, 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 addresses a critical issue where the agent could get stuck when encountering interactive shell commands, particularly vitest. The changes introduce a new evaluation test to ensure agents correctly handle non-interactive execution, optimize the evaluation test setup process by symlinking node_modules, and, most importantly, update the agent's core mandates to explicitly instruct it to use non-interactive flags for all shell commands, thereby preventing future hangs.

Highlights

  • New Evaluation Test: A new test case (evals/interactive-hang.eval.ts) has been added to specifically validate that agents correctly use non-interactive flags (like run or --run) when executing vitest commands, preventing them from getting stuck in interactive modes.
  • Performance Improvement for Evals: The evals/test-helper.ts file now includes logic to symlink node_modules from the root project to the test environment. This significantly reduces the setup time for evaluation tests by avoiding redundant npm install operations.
  • Enhanced Agent Mandates: The core agent prompts (packages/core/src/prompts/snippets.ts) have been updated with explicit instructions. A new mandate enforces the use of non-interactive flags for all shell commands, and an existing mandate provides specific guidance for vitest (requiring run or --run) and general npx usage to prevent interactive hangs.
Changelog
  • evals/interactive-hang.eval.ts
    • Added a new evaluation test to verify that agents execute vitest with non-interactive flags (run or --run).
  • evals/test-helper.ts
    • Implemented symlinking of node_modules from the project root to the test directory to accelerate test environment bootstrapping.
  • packages/core/src/prompts/snippets.ts
    • Introduced a new core mandate: "Non-interactive Execution," which explicitly requires agents to use non-interactive flags for all shell commands.
    • Modified the "Interactive Commands" mandate to provide specific instructions for vitest (requiring run or --run) and general npx usage, including guidance on reporting test results and handling dependencies.
Activity
  • No specific activity (comments, reviews, or progress updates) has been recorded for this pull request yet.
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
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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.

Copy link
Contributor

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

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 addresses an issue where the agent could get stuck on interactive commands, particularly test runners like vitest. The fix involves updating the system prompts to explicitly instruct the agent to use non-interactive flags. A new evaluation test is added to verify this behavior. Additionally, a performance optimization is included to speed up tests by symlinking node_modules.

@github-actions
Copy link

github-actions bot commented Feb 4, 2026

Size Change: +56 B (0%)

Total Size: 23.7 MB

ℹ️ View Unchanged
Filename Size Change
./bundle/gemini.js 23.7 MB +56 B (0%)
./bundle/sandbox-macos-permissive-closed.sb 1.03 kB 0 B
./bundle/sandbox-macos-permissive-open.sb 890 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

@gemini-cli gemini-cli bot added the priority/p1 Important and should be addressed in the near term. label Feb 4, 2026
@gundermanc gundermanc marked this pull request as ready for review February 4, 2026 06:23
@gundermanc gundermanc requested a review from a team as a code owner February 4, 2026 06:23
@gemini-cli gemini-cli bot added area/non-interactive Issues related to GitHub Actions, SDK, 3P Integrations, Shell Scripting, Command line automation 🔒 maintainer only ⛔ Do not contribute. Internal roadmap item. labels Feb 4, 2026
@gundermanc gundermanc added this pull request to the merge queue Feb 4, 2026
Merged via the queue into main with commit a0b6602 Feb 4, 2026
26 checks passed
@gundermanc gundermanc deleted the gundermanc/interactive branch February 4, 2026 07:13
theerud pushed a commit to theerud/gemini-cli that referenced this pull request Feb 4, 2026
yuvrajangadsingh pushed a commit to yuvrajangadsingh/gemini-cli that referenced this pull request Feb 4, 2026
sidwan02 pushed a commit to sidwan02/gemini-cli-gemma that referenced this pull request Feb 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/non-interactive Issues related to GitHub Actions, SDK, 3P Integrations, Shell Scripting, Command line automation 🔒 maintainer only ⛔ Do not contribute. Internal roadmap item. priority/p1 Important and should be addressed in the near term.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Behavior Mgmt] Gemini CLI still runs commands in interactive mode

2 participants