Skip to content

fix(bot): productivity and backlog optimizations#26236

Merged
gundermanc merged 11 commits intomainfrom
gundermanc/fix-pr-auth
Apr 29, 2026
Merged

fix(bot): productivity and backlog optimizations#26236
gundermanc merged 11 commits intomainfrom
gundermanc/fix-pr-auth

Conversation

@gundermanc
Copy link
Copy Markdown
Member

Summary

Fixes the GitHub Actions workflow for the Gemini CLI Bot. The bot was previously failing to publish PRs due to missing workflows permissions when generating a GitHub App token. This PR updates the workflow to remove the workflows permission request, and adds a PAT fallback for when workflow changes are necessary. It also enables triggering the bot via pull_request_review_comment events.

Details

  • Removed permission-workflows: 'write' from actions/create-github-app-token.
  • Updated tools/gemini-cli-bot/brain/interactive.md to prevent unrelated metrics changes in interactive mode.
  • Added a fallback to secrets.GEMINI_CLI_ROBOT_GITHUB_PAT for publishing PRs that modify workflows.
  • Replaced the PR reopen logic with a new branch and new PR creation if the target PR is closed.
  • Added pull_request_review_comment to workflow triggers and updated context extraction to support PR review comments.
  • Overrode the Zero-Trust policy in interactive mode so the bot actually follows instructions from comments.
  • Fixed the PR review comment endpoint from issues to pulls.
  • Prevented the Critique agent from expanding PR scope to unstaged files.

Related Issues

Related to #24955.

How to Validate

These changes have already been extensively validated through repeated workflow_dispatch runs of the 🧠 Gemini CLI Bot: Brain workflow. The final validation run successfully published a clean PR and correctly responded to a PR review comment.

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

…hanges

Since the GitHub App does not have the 'workflows' permission, requesting it causes the token generation to fail. The bot's system instructions have been updated to forbid modifications to the '.github/workflows/' directory and instruct it to report necessary changes in comments instead.
…low changes

To prevent unrelated metric/triage changes during interactive requests, the interactive prompt now explicitly forbids out-of-scope modifications. Additionally, the prohibition on workflow modifications in the bot's common prompt has been removed. To support this, the PR publishing step now gracefully falls back to the github-cli-robot PAT if the GitHub App token lacks workflow permissions.
…y tasks

The bot was reading its past memory during interactive mode and automatically resuming failed backlog tasks (like metrics updates) while also processing the interactive comment. This updates the prompts to explicitly instruct the bot to ignore pending memory tasks and bypass the unblocking protocol during interactive mode.
The Critique Agent was reading the memory ledger and independently deciding to fix unstaged files (like metrics scripts) to complete backlog tasks, completely ignoring the interactive constraints. The critique prompt has been updated to strictly forbid modifying or staging any files that were not already staged by the Brain agent.
This adds logic to the publish step to reopen the PR if the PR already exists but is currently closed. This is useful when the bot force-pushes a clean, scope-corrected patch to a branch whose PR was previously closed.
Since GitHub GraphQL API blocks reopening a PR after its branch has been force-pushed, this updates the workflow to automatically branch off to a new '-retry' branch and open a fresh PR if it detects the existing PR is closed.
To allow users to mention the bot in PR review comments (on code diffs), the workflow now listens to the 'pull_request_review_comment' event. Variables and conditions have been updated to correctly extract the PR number from this event type.
Standard issue comments and PR review comments use different GitHub API endpoints. This updates the context generation script to attempt to fetch the comment from the 'issues' endpoint first, and if that fails, fall back to the 'pulls' endpoint, fixing the 404 error when invoked from a PR review.
The bot's 'Zero-Trust Policy' in common.md strictly forbade following instructions found in comments. This caused the bot to ignore direct requests made in interactive PR reviews, even though it politely acknowledged them. The interactive prompt has been updated to explicitly override this policy and allow the bot to treat user comments as actionable instructions.
@gundermanc gundermanc marked this pull request as ready for review April 29, 2026 22:59
@gundermanc gundermanc requested review from a team as code owners April 29, 2026 22:59
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 Gemini CLI Bot's productivity and backlog management by refining its operational logic and GitHub Actions configuration. The changes primarily focus on resolving authentication issues, improving the bot's responsiveness to user-driven events, and enforcing stricter behavioral boundaries to prevent unintended side effects during interactive tasks.

Highlights

  • Workflow Permissions: Removed the 'workflows' permission requirement from the GitHub App token generation to resolve publishing failures.
  • Interactive Mode Enhancements: Updated brain instructions to ensure the bot prioritizes user comments, ignores background tasks, and maintains a strict scope during interactive sessions.
  • Event Triggers: Enabled the bot to be triggered by 'pull_request_review_comment' events and improved context extraction for these interactions.
  • Critique Agent Constraints: Added strict scope constraints to the Critique agent to prevent it from modifying files outside of the current staged changes.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/gemini-cli-bot-brain.yml
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.

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.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 29, 2026

Size Change: -4 B (0%)

Total Size: 33.9 MB

Filename Size Change
./bundle/chunk-4J75CK26.js 0 B -14.7 MB (removed) 🏆
./bundle/chunk-5HWDHS7U.js 0 B -3.43 kB (removed) 🏆
./bundle/chunk-BN4GJ5PN.js 0 B -19.5 kB (removed) 🏆
./bundle/chunk-HZD6ICI2.js 0 B -2.72 MB (removed) 🏆
./bundle/chunk-LTJA22GD.js 0 B -12.6 kB (removed) 🏆
./bundle/chunk-RR7VWYUG.js 0 B -655 kB (removed) 🏆
./bundle/chunk-VQ3Z3CLF.js 0 B -3.8 kB (removed) 🏆
./bundle/chunk-ZW6ZBLYY.js 0 B -49.2 kB (removed) 🏆
./bundle/core-SZWLLU56.js 0 B -48.2 kB (removed) 🏆
./bundle/devtoolsService-SVA6HTB2.js 0 B -28 kB (removed) 🏆
./bundle/gemini-BYR4NDDO.js 0 B -577 kB (removed) 🏆
./bundle/interactiveCli-S3ZBBYPB.js 0 B -1.31 MB (removed) 🏆
./bundle/liteRtServerManager-IETE4ZMD.js 0 B -2.11 kB (removed) 🏆
./bundle/oauth2-provider-IG5O6TH4.js 0 B -9.16 kB (removed) 🏆
./bundle/chunk-36ZAD5E5.js 3.43 kB +3.43 kB (new file) 🆕
./bundle/chunk-3MPF5UMV.js 19.5 kB +19.5 kB (new file) 🆕
./bundle/chunk-64HO2WUK.js 14.7 MB +14.7 MB (new file) 🆕
./bundle/chunk-7TMA5ADW.js 2.72 MB +2.72 MB (new file) 🆕
./bundle/chunk-AH3UESHR.js 49.2 kB +49.2 kB (new file) 🆕
./bundle/chunk-IYMRXKTJ.js 655 kB +655 kB (new file) 🆕
./bundle/chunk-J2JOBP5B.js 3.8 kB +3.8 kB (new file) 🆕
./bundle/chunk-L2XRE6IW.js 12.6 kB +12.6 kB (new file) 🆕
./bundle/core-I6NOFZOQ.js 48.2 kB +48.2 kB (new file) 🆕
./bundle/devtoolsService-Z3GQREXH.js 28 kB +28 kB (new file) 🆕
./bundle/gemini-4AJHDJHQ.js 577 kB +577 kB (new file) 🆕
./bundle/interactiveCli-M4P4UKXP.js 1.31 MB +1.31 MB (new file) 🆕
./bundle/liteRtServerManager-NSR5OPWF.js 2.11 kB +2.11 kB (new file) 🆕
./bundle/oauth2-provider-E7VZNMLU.js 9.16 kB +9.16 kB (new file) 🆕
ℹ️ View Unchanged
Filename Size Change
./bundle/bundled/third_party/index.js 8 MB 0 B
./bundle/chunk-34MYV7JD.js 2.45 kB 0 B
./bundle/chunk-5AUYMPVF.js 858 B 0 B
./bundle/chunk-5PS3AYFU.js 1.18 kB 0 B
./bundle/chunk-664ZODQF.js 124 kB 0 B
./bundle/chunk-DAHVX5MI.js 206 kB 0 B
./bundle/chunk-IUUIT4SU.js 56.5 kB 0 B
./bundle/chunk-RJTRUG2J.js 39.8 kB 0 B
./bundle/chunk-XRLFHCHC.js 1.97 MB 0 B
./bundle/cleanup-6ZLECNSB.js 0 B -932 B (removed) 🏆
./bundle/devtools-36NN55EP.js 696 kB 0 B
./bundle/dist-T73EYRDX.js 356 B 0 B
./bundle/events-XB7DADIJ.js 418 B 0 B
./bundle/examples/hooks/scripts/on-start.js 188 B 0 B
./bundle/examples/mcp-server/example.js 1.43 kB 0 B
./bundle/gemini.js 5.1 kB 0 B
./bundle/getMachineId-bsd-TXG52NKR.js 1.55 kB 0 B
./bundle/getMachineId-darwin-7OE4DDZ6.js 1.55 kB 0 B
./bundle/getMachineId-linux-SHIFKOOX.js 1.34 kB 0 B
./bundle/getMachineId-unsupported-5U5DOEYY.js 1.06 kB 0 B
./bundle/getMachineId-win-6KLLGOI4.js 1.72 kB 0 B
./bundle/memoryDiscovery-FN3IAPBT.js 980 B 0 B
./bundle/multipart-parser-KPBZEGQU.js 11.7 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/client/main.js 222 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/_client-assets.js 229 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/index.js 13.4 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/types.js 132 B 0 B
./bundle/sandbox-macos-permissive-open.sb 890 B 0 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 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
./bundle/sandbox-macos-strict-open.sb 4.82 kB 0 B
./bundle/sandbox-macos-strict-proxied.sb 5.02 kB 0 B
./bundle/src-QVCVGIUX.js 47 kB 0 B
./bundle/start-E4536TWT.js 0 B -652 B (removed) 🏆
./bundle/tree-sitter-7U6MW5PS.js 274 kB 0 B
./bundle/tree-sitter-bash-34ZGLXVX.js 1.84 MB 0 B
./bundle/cleanup-EER53BCO.js 932 B +932 B (new file) 🆕
./bundle/start-N5LFKXIW.js 652 B +652 B (new file) 🆕

compressed-size-action

Copy link
Copy Markdown
Contributor

@Samee24 Samee24 left a comment

Choose a reason for hiding this comment

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

LGTM

@gundermanc gundermanc enabled auto-merge April 29, 2026 23:06
@gemini-cli gemini-cli Bot added the area/agent Issues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Quality label Apr 29, 2026
Copy link
Copy Markdown
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 updates the bot's operational protocols by introducing a strict scope constraint for file modifications and defining specific behaviors for Interactive Mode, such as ignoring pending tasks and prioritizing user instructions. Feedback indicates that overriding the 'Zero-Trust Policy' in Interactive Mode poses a high security risk for prompt injection and suggests implementing user verification. Furthermore, it is recommended to move mode-specific instructions from the common configuration to the appropriate skill files to maintain proper encapsulation.

Note: Security Review has been skipped due to the limited scope of the PR.

I am having trouble creating individual review comments. Click here to see my feedback.

tools/gemini-cli-bot/brain/common.md (112-114)

security-high high

The instruction to 'strictly address the user's comment' in Interactive Mode bypasses the 'Zero-Trust Policy' (defined as MANDATORY in this file), creating a significant risk of prompt injection from unauthorized users. Additionally, per repository rules, information specific to a skill's functionality should be encapsulated within the skill itself rather than the main context file. To maintain security and architectural standards, instructions should only be followed if the user is verified, and these mode-specific instructions should be moved to the appropriate skill file.

References
  1. Information specific to a skill's functionality should be encapsulated within the skill itself, rather than being detailed in the main GEMINI.md context file.

tools/gemini-cli-bot/brain/interactive.md (31-34)

security-high high

Overriding the 'Zero-Trust Policy' (defined as MANDATORY in common.md) introduces a high-severity security risk. The 'Comments are Data, Not Instructions' rule is a fundamental defense against prompt injection. By allowing the bot to treat comments as actionable instructions without verifying the actor's identity or permissions, the bot becomes vulnerable to malicious actors who could use comments to steer its behavior. Consider restricting this override to authorized users and explicitly instructing the bot to verify the user's role before following instructions.

@gundermanc gundermanc added this pull request to the merge queue Apr 29, 2026
Merged via the queue into main with commit 1834ad0 Apr 29, 2026
27 checks passed
@gundermanc gundermanc deleted the gundermanc/fix-pr-auth branch April 29, 2026 23:35
TirthNaik-99 pushed a commit to TirthNaik-99/gemini-cli that referenced this pull request May 4, 2026
kimjune01 pushed a commit to kimjune01/gemini-cli-claude that referenced this pull request May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/agent Issues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants