fix(core): allow redirection in YOLO and AUTO_EDIT modes without sandboxing#26542
fix(core): allow redirection in YOLO and AUTO_EDIT modes without sandboxing#26542
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 addresses a regression in the policy engine where shell commands involving redirection were being unnecessarily downgraded to require user approval. By removing the dependency on sandboxing status for trusted execution modes, the engine now correctly respects the YOLO and AUTO_EDIT configurations, ensuring a smoother user experience in environments where sandboxing is disabled. 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 the 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 counterproductive. 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. Footnotes
|
|
Size Change: -105 B (0%) Total Size: 34 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Code Review
This pull request updates the PolicyEngine to ensure that redirected commands are not downgraded to ASK_USER in AUTO_EDIT or YOLO modes, regardless of whether sandboxing is enabled. This change simplifies the logic by removing the dependency on the sandbox status for these specific approval modes. Additionally, a new test case was added to policy-engine.test.ts to confirm that YOLO mode correctly allows redirected commands even when using a NoopSandboxManager. I have no feedback to provide.
|
/patch both |
|
🚀 [Step 1/4] Patch workflow(s) waiting for approval! 📋 Details:
⏳ Status: The patch creation workflow has been triggered and is waiting for deployment approval. Please visit the specific workflow links below and approve the runs. 🔗 Track Progress: |
|
🚀 [Step 2/4] Patch PR Created! 📋 Patch Details:
📝 Next Steps:
🔗 Track Progress: |
|
🚀 [Step 2/4] Patch PR Created! 📋 Patch Details:
📝 Next Steps:
🔗 Track Progress: |
|
🚀 [Step 3/4] Patch Release Waiting for Approval! 📋 Release Details:
⏳ Status: The patch release has been triggered and is waiting for deployment approval. Please visit the specific workflow run link below and approve the deployment. You'll receive another update when it completes. 🔗 Track Progress: |
|
🚀 [Step 3/4] Patch Release Waiting for Approval! 📋 Release Details:
⏳ Status: The patch release has been triggered and is waiting for deployment approval. Please visit the specific workflow run link below and approve the deployment. You'll receive another update when it completes. 🔗 Track Progress: |
|
✅ [Step 4/4] Patch Release Complete! 📦 Release Details:
🎉 Status: Your patch has been successfully released and published to npm! 📝 What's Available:
🔗 Links: |
|
✅ [Step 4/4] Patch Release Complete! 📦 Release Details:
🎉 Status: Your patch has been successfully released and published to npm! 📝 What's Available:
🔗 Links: |

Summary
Fixed a regression where commands with redirection (pipes, redirects) were being downgraded to
ASK_USERin YOLO and AUTO_EDIT modes when sandboxing was disabled.Details
In
PolicyEngine.shouldDowngradeForRedirection, the logic was checking if sandboxing was enabled before allowing YOLO/AUTO_EDIT modes to bypass the redirection safeguard. This caused unnecessary approval prompts in environments where sandboxing is disabled (e.g., certain git worktrees or specific OS configurations). The fix removes thesandboxEnabledrequirement for these trusted modes.Related Issues
Fixes the reported regression where commands like
npm test ... 2>&1 | tail -80prompted for approval in YOLO mode.How to Validate
Run the new regression test:
npm test -w @google/gemini-cli-core -- src/policy/policy-engine.test.tsThe test
should NOT downgrade to ASK_USER for redirected commands in YOLO mode even without sandboxverifies the fix.Pre-Merge Checklist