Skip to content

Conversation

@Thomas-Shephard
Copy link

@Thomas-Shephard Thomas-Shephard commented Jan 7, 2026

Summary

Fixes an issue where the agent would attempt to use Linux-specific shell commands (like grep and &&) when running on Windows. Since Gemini CLI's shell tool implementation forces the use of PowerShell on Windows, these Unix-style commands were failing. This PR makes the system prompt platform-aware, ensuring the agent uses compatible syntax and utilities.

Details

The core problem was a mismatch between the agent's instructions (which assumed a POSIX-like shell) and the CLI's actual execution environment on Windows (PowerShell).

Related Issues

How to Validate

  1. Unit Tests: Run the core prompt tests to verify cross-platform logic:
    npx vitest packages/core/src/core/prompts.test.ts
  2. Manual Verification (Windows):
  • Start Gemini CLI on a Windows machine.
  • Ask the agent to "check git status and show recent logs".
  • Expected Result: The agent should call run_shell_command with commands chained by ; instead of &&.
  • Ask the agent to search for a string in a file using a shell command.
  • Expected Result: The agent should use Select-String instead of grep.

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 @Thomas-Shephard, 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 resolves a critical cross-platform compatibility issue where the agent's system prompt assumed a POSIX-like shell environment, leading to errors when executed on Windows machines which default to PowerShell. By making the system prompt platform-aware, the agent will now correctly utilize Windows-specific commands such as 'Select-String' and PowerShell's command chaining (' ; ') instead of their Unix counterparts, thereby enhancing the agent's reliability and functionality across different operating systems.

Highlights

  • Platform-Aware Shell Commands: The system prompt now dynamically adjusts shell commands based on the operating system to ensure compatibility.
  • Windows Compatibility: Addresses an issue where the agent would attempt to use Linux-specific commands (like 'grep' and '&&') on Windows, leading to execution failures.
  • PowerShell Integration: Ensures the agent utilizes compatible PowerShell syntax and utilities, such as 'Select-String' and ';' for command chaining, when running on Windows.
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 effectively addresses a cross-platform compatibility issue where Linux-specific shell commands were being suggested in the system prompt on Windows environments. By introducing platform-aware logic to select the appropriate commands (Select-String vs grep, ; vs &&, etc.), the changes ensure that the agent receives correct examples for its execution environment. The implementation is clean, centralizing the platform detection, and the accompanying tests thoroughly validate the behavior for both Windows and Linux platforms. The changes look solid and correctly solve the problem.

@Thomas-Shephard Thomas-Shephard marked this pull request as ready for review January 7, 2026 20:41
@Thomas-Shephard Thomas-Shephard requested a review from a team as a code owner January 7, 2026 20:41
@jacob314 jacob314 added the status/need-issue Pull requests that need to have an associated issue. label Jan 7, 2026
const isWindows = process.platform === 'win32';
const commandSeparator = isWindows ? ';' : '&&';
const grepCommand = isWindows ? 'Select-String' : 'grep';
const tailCommand = isWindows ? 'Get-Content -Tail 10' : 'tail';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are the windows versions specifying a number of responses to request?

vi.resetAllMocks();
vi.stubEnv('GEMINI_SYSTEM_MD', undefined);
vi.stubEnv('GEMINI_WRITE_SYSTEM_MD', undefined);
Object.defineProperty(process, 'platform', {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be better to mock the platform rather than using define property. Please do that instead if feasible.

@jacob314 jacob314 requested a review from a team January 8, 2026 01:28
@jacob314
Copy link
Collaborator

jacob314 commented Jan 8, 2026

Fyi @mattKorwel these prompt changes should improve quality a bit on windows without impacting other platforms.

@Thomas-Shephard
Copy link
Author

Apologies, I accidentally deleted the forked branch so the pr was automatically closed :/

Please see #16152 instead and I'll reply to your comments in there :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status/need-issue Pull requests that need to have an associated issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants