Skip to content

fix(prompt): Make interactive command avoidance conditional - #11225

Merged
galdawave merged 13 commits into
mainfrom
galzahavi/fix/system-prompt
Oct 17, 2025
Merged

galdawave merged 13 commits into
mainfrom
galzahavi/fix/system-prompt

Conversation

@galdawave

Copy link
Copy Markdown
Contributor

TLDR

This pull request makes the "- Interactive Commands" section of the core system prompt conditional. This instruction will now only be included when the CLI is running in a non-interactive mode (config.isInteractive is false).

This change is to reduce the size and complexity of the system prompt for interactive sessions where this guidance is not relevant.

Dive Deeper

The system prompt contains guidance for the model on how to behave. One piece of guidance is to avoid using interactive shell commands (like git rebase -i) because they can cause the CLI to hang in non-interactive or automated environments.

However, when a user is in an interactive session, they can handle these prompts directly, making the warning unnecessary. Removing it in interactive mode saves tokens and simplifies the instructions for the model.

The implementation uses a small, self-executing function within the template literal for basePrompt in packages/core/src/core/prompts.ts. This conditionally returns the text block based on the config.isInteractive flag, which is a clean way to handle this and is consistent with other conditional logic in the same file.

Reviewer Test Plan

To test this change, a reviewer can inspect the generated system prompt in both interactive and non-interactive modes.

  1. Temporarily add console.log(basePrompt); at the end of the getCoreSystemPrompt function in packages/core/src/core/prompts.ts.
  2. Rebuild the CLI: npm run build.
  3. Run in interactive mode: npx dist/gemini.js. The logged prompt should NOT contain the "Interactive Commands" section.
  4. Run in non-interactive mode: npx dist/gemini.js -p "list files". The logged prompt SHOULD contain the "Interactive Commands" section.
  5. Remember to remove the console.log before merging.

Testing Matrix

🍏 🪟 🐧
npm run ✅ ❓ ❓
npx ✅ ❓ ❓
Docker ❓ ❓ ❓
Podman ❓ - -
Seatbelt ❓ - -

Linked issues / bugs

None

@galdawave
galdawave requested a review from a team as a code owner October 15, 2025 19:32
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @galz10, 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 optimizes the core system prompt by making the 'Interactive Commands' section conditional. The guidance, which advises against using interactive shell commands, will now only be present in non-interactive CLI sessions. This ensures that the prompt remains concise and relevant, avoiding unnecessary instructions and token consumption when the user can directly manage interactive prompts.

Highlights

  • Conditional System Prompt Guidance: The guidance instructing the model to avoid interactive commands is now conditionally included in the system prompt. It will only appear when the CLI is running in a non-interactive environment.
  • Prompt Optimization: This change reduces the size and complexity of the system prompt for interactive sessions, where the guidance on avoiding interactive commands is not relevant, thereby saving tokens.
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. ↩

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

Copy link
Copy Markdown
Contributor

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 aims to conditionally include the 'Interactive Commands' guidance in the system prompt based on whether the session is interactive. The approach of using a self-executing function within the template literal is consistent with other parts of the file. However, I've found a formatting issue with the current implementation that adds an extra newline in interactive mode, which I've detailed in a specific comment. Addressing this will ensure the prompt remains well-formatted.

Comment on lines +210 to +215
${(function () {
if (!config.isInteractive()) {
return `- **Interactive Commands:** Try to avoid shell commands that are likely to require user interaction (e.g. \`git rebase -i\`). Use non-interactive versions of commands (e.g. \`npm init -y\` instead of \`npm init\`) when available, and otherwise remind the user that interactive shell commands are not supported and may cause hangs until canceled by the user.`;
}
return '';
})()}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

This implementation introduces an extra newline in the prompt when running in interactive mode. When config.isInteractive() is true, this function returns an empty string. Because the ${...} expression is on its own line within the template literal, an unwanted blank line is rendered, which disrupts the formatting of the bulleted list.

In interactive mode, the list will incorrectly appear as:

- **Background Processes:** ...

- **Remembering Facts:** ...

A more robust approach would be to build this list of guidelines as an array of strings and then use join('\n') to insert it into the prompt. This would handle conditional list items cleanly.

Alternatively, a minimal fix would be to use a ternary operator and attach it to the end of the previous line to control the newline's inclusion, though this would require changing line 209 which is outside this diff.

@github-actions

github-actions Bot commented Oct 15, 2025 •

Copy link
Copy Markdown

Size Change: +788 B (0%)

Total Size: 20.1 MB

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

@galdawave
galdawave requested a review from anj-s October 15, 2025 19:51
@anj-s
anj-s requested a review from NTaylorMullen October 15, 2025 19:54
Comment thread packages/core/src/config/config.ts Resolved
Comment thread packages/core/src/core/prompts.ts Resolved
  This commit introduces a more precise way to detect if the interactive shell is enabled and improves the guidance provided to the
  user in the system prompt.
@galdawave
galdawave enabled auto-merge October 17, 2025 15:55
@galdawave
galdawave added this pull request to the merge queue Oct 17, 2025
Merged via the queue into main with commit 0ded546 Oct 17, 2025
@galdawave
galdawave deleted the galzahavi/fix/system-prompt branch October 17, 2025 16:19
@galdawave

Copy link
Copy Markdown
Contributor Author

/patch preview

@github-actions

Copy link
Copy Markdown

✅ Patch workflow(s) dispatched successfully!

📋 Details:

  • Channels: preview
  • Commit: 0ded546a09c1e9255f3337da2e290affa8164022
  • Workflows Created: 1

🔗 Track Progress:

@github-actions

Copy link
Copy Markdown

❌ Patch creation failed!

There was an error creating the patch release.

🔍 Troubleshooting:

  • Check the workflow logs for detailed error information
  • Verify the commit SHA is valid and accessible
  • Ensure you have permissions to create branches and PRs

🔗 Links:

@galdawave

Copy link
Copy Markdown
Contributor Author

/patch preview

@github-actions

Copy link
Copy Markdown

✅ Patch workflow(s) dispatched successfully!

📋 Details:

  • Channels: preview
  • Commit: 0ded546a09c1e9255f3337da2e290affa8164022
  • Workflows Created: 1

🔗 Track Progress:

@github-actions

Copy link
Copy Markdown

❌ Patch creation failed!

There was an error creating the patch release.

🔍 Troubleshooting:

  • Check the workflow logs for detailed error information
  • Verify the commit SHA is valid and accessible
  • Ensure you have permissions to create branches and PRs

🔗 Links:

thacio added a commit to thacio/auditaria that referenced this pull request Oct 17, 2025
@github-actions

Copy link
Copy Markdown

🚀 Patch Release Started!

📋 Release Details:

⏳ Status: The patch release is now running. You'll receive another update when it completes.

🔗 Track Progress:

@github-actions

Copy link
Copy Markdown

❌ Patch Release Failed!

📋 Details:

  • Version: 0.10.0-preview.2
  • Channel: preview
  • Error: The patch release workflow encountered an error

🔍 Next Steps:

  1. Check the workflow logs for detailed error information
  2. The maintainers have been notified via automatic issue creation
  3. You may need to retry the patch once the issue is resolved

🔗 Troubleshooting:

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

Labels

size/m A medium sized PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

System Prompt limits command execution to only non-interactive commands

4 participants