-
Notifications
You must be signed in to change notification settings - Fork 10.6k
fix(core): use platform-specific shell commands in system prompt #16089
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(core): use platform-specific shell commands in system prompt #16089
Conversation
Summary of ChangesHello @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
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
|
There was a problem hiding this 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.
packages/core/src/core/prompts.ts
Outdated
| const isWindows = process.platform === 'win32'; | ||
| const commandSeparator = isWindows ? ';' : '&&'; | ||
| const grepCommand = isWindows ? 'Select-String' : 'grep'; | ||
| const tailCommand = isWindows ? 'Get-Content -Tail 10' : 'tail'; |
There was a problem hiding this comment.
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', { |
There was a problem hiding this comment.
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.
|
Fyi @mattKorwel these prompt changes should improve quality a bit on windows without impacting other platforms. |
2c993b1 to
19bdd95
Compare
|
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 :) |
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
npx vitest packages/core/src/core/prompts.test.tsPre-Merge Checklist