fix: prevent hangs in non-interactive mode and improve agent guidance#20893
Conversation
Summary of ChangesHello, 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 significantly enhances the stability and behavior of the agent when operating in non-interactive or headless environments. It addresses potential issues where tools might hang awaiting user input by configuring subprocesses to fail quickly under such conditions. Additionally, it refines the agent's instructions to ensure it provides clear explanations for failures and suggests alternative solutions, rather than attempting to interact with the user in contexts where interaction is not possible. Highlights
Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request effectively addresses hangs in non-interactive mode by disabling interactive prompts for shell commands executed without a TTY. The changes in shellExecutionService.ts correctly inject environment variables to force tools like Git to fail fast instead of hanging. The accompanying improvements to the agent's system prompt provide clearer guidance for behavior in headless environments. The new unit tests properly validate the core logic change. The implementation is robust and aligns with the goal of improving stability in non-interactive sessions.
There was a problem hiding this comment.
Code Review
This pull request makes excellent improvements to prevent hangs in non-interactive mode by disabling interactive prompts from tools like Git and providing clearer guidance to the agent. The changes to the system prompts and the addition of unit tests are well-executed. However, I've identified a critical issue in how the Git configuration environment variables are being set, which could unintentionally break users' existing configurations. My review includes a detailed explanation and a suggested fix for this issue.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request improves the agent's behavior in non-interactive mode by preventing hangs from tools requiring credentials and by providing better guidance to the model. However, a critical issue was identified in shellExecutionService.ts: environment variables intended for non-interactive mode are unconditionally applied in the child_process fallback, which could break interactive credential prompts if the PTY fails to load during an interactive session. No specific security vulnerabilities were identified in this review.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request effectively addresses process hangs in non-interactive mode by setting environment variables to prevent tools like Git from prompting for credentials. The accompanying changes to the agent's system prompt provide better guidance for headless environments, and the new unit tests are comprehensive. Based on repository rules, the suggested robustness check for GIT_CONFIG_COUNT is not necessary as we assume internally managed configurations are valid.
…idance - Injects headless-safe environment variables into non-interactive subprocesses to prevent credential prompt deadlocks (fixes google-gemini#16567). - Updates system instructions for non-interactive mode to discourage impossible user questions (addresses google-gemini#5724). - Adds unit tests to verify environment injection.
Co-authored-by: Keith Schaab <keith.schaab@gmail.com>
1351a4c to
0f06a03
Compare
…google-gemini#20893) Co-authored-by: Keith Schaab <keith.schaab@gmail.com>
…google-gemini#20893) Co-authored-by: Keith Schaab <keith.schaab@gmail.com>
…google-gemini#20893) Co-authored-by: Keith Schaab <keith.schaab@gmail.com>
Summary
This PR improves stability and agent behavior in non-interactive mode by preventing tool hangs and providing clearer guidance to the model.
Details
childProcessFallbackinpackages/core/src/services/shellExecutionService.tsto inject a minimal set of environment variables (GIT_TERMINAL_PROMPT,GIT_ASKPASS,GH_PROMPT_DISABLED,DISPLAY, etc.). This forces tools like Git and GitHub CLI to fail instantly rather than hanging for 5 minutes when they encounter an interactive credential requirement while running in a detached process group without a TTY.packages/core/src/prompts/snippets.ts. The agent is now explicitly informed it is in a headless environment and should not ask the user questions, but instead explain failures (like missing credentials) and suggest alternatives.shellExecutionService.test.tsto verify the correct injection of these variables and updated prompt snapshots.Related Issues
Fixes #16567
Addresses #5724
How to Validate
Pre-Merge Checklist