Repository navigation
fix(cli): defer tool exclusions to policy engine in non-interactive mode - #20639
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 refactors the CLI's tool exclusion mechanism in non-interactive (headless) mode. Previously, certain tools were hardcoded for exclusion, which could incorrectly override explicit 'allow' rules defined by the Policy Engine. The changes centralize tool availability decisions within the Policy Engine, making it the definitive source of truth. This ensures that the CLI behaves predictably in headless environments, automatically denying tools requiring user interaction unless explicitly permitted by a policy, thereby preventing hangs and improving security. 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
|
There was a problem hiding this comment.
Code Review
This pull request refactors the tool exclusion logic for non-interactive mode. It removes the hardcoded extraExcludes from the CLI configuration and delegates the responsibility of handling tool availability to the Policy Engine. This allows high-priority allow rules in the Policy Engine to correctly override default behaviors in headless mode. The change is supported by updates to unit tests and the addition of a new integration test suite that validates the new policy-driven behavior in various headless scenarios.
Removes the hardcoded `extraExcludes` logic from the CLI configuration layer that was incorrectly overriding high-priority Policy Engine 'allow' rules in non-interactive mode. The Policy Engine now serves as the single source of truth for tool availability, relying on its native `ASK_USER` to `DENY` translation to ensure headless safety. Verifies that the Policy Engine correctly downgrades ASK_USER tools to DENY in headless (non-interactive) mode when no custom policy is present. Also ensures that explicit ALLOW policies defined in .toml files can override this behavior. Fixes google-gemini#20469
Removes leftover generateContent mock responses that caused 'Unexpected response type' crashes when executed from npm script environments where the Agent Router is correctly bypassed (e.g. CI). Also replaces hardcoded absolute paths in read_file test mocks with relative paths to prevent file-not-found errors in dynamic test directories.
df4cd47 to
fafd16a
Compare
…ode (google-gemini#20639) Co-authored-by: Bryan Morgan <bryanmorgan@google.com>
…ode (google-gemini#20639) Co-authored-by: Bryan Morgan <bryanmorgan@google.com>
…ode (google-gemini#20639) Co-authored-by: Bryan Morgan <bryanmorgan@google.com>
…ode (google-gemini#20639) Co-authored-by: Bryan Morgan <bryanmorgan@google.com>
…ode (google-gemini#20639) Co-authored-by: Bryan Morgan <bryanmorgan@google.com>
…ode (google-gemini#20639) Co-authored-by: Bryan Morgan <bryanmorgan@google.com>
…ode (#20639) Co-authored-by: Bryan Morgan <bryanmorgan@google.com>
…ode (google-gemini#20639) Co-authored-by: Bryan Morgan <bryanmorgan@google.com>
Summary
Removes the hardcoded
extraExcludeslogic from the CLI configuration layer that was incorrectly overriding high-priority Policy Engine 'allow' rules in non-interactive mode.Details
The Policy Engine now serves as the single source of truth for tool availability, relying on its native
ASK_USERtoDENYtranslation to ensure headless safety.Verifies that the Policy Engine correctly downgrades ASK_USER tools to DENY in headless (non-interactive) mode when no custom policy is present. Also ensures that explicit ALLOW policies defined in .toml files can override this behavior.
Related Issues
Fixes #20469
How to Validate
Pre-Merge Checklist