Skip to content

feat(bot): implement issue-fixer skill and mandate selection#26951

Open
gundermanc wants to merge 59 commits into
mainfrom
gundermanc/pr-agent2
Open

feat(bot): implement issue-fixer skill and mandate selection#26951
gundermanc wants to merge 59 commits into
mainfrom
gundermanc/pr-agent2

Conversation

@gundermanc
Copy link
Copy Markdown
Member

Summary

This PR implements the issue-fixer skill for the Gemini CLI Bot and adds the ability to manually select the bot's mandate (auto, issue-fixer, metrics, interactive) when triggering the workflow via workflow_dispatch. It also updates the CI policy to allow the activate_skill tool.

Details

  • Issue Fixer Skill: Created a new issue-fixer skill that enables the bot to proactively identify and fix effort/small issues and maintain existing bot-fix PRs.
  • Mandate Selection: Updated the gemini-cli-bot-brain.yml workflow to include a mandate choice input. This allows maintainers to explicitly test specific bot behaviors.
  • Workflow Logic: Refined the shell logic in the workflow to correctly synchronize PROMPT_FILE and MANDATE based on the input override and improved logging for better visibility in Action logs.
  • Policy Update: Added activate_skill to the ci-policy.toml to ensure the bot can utilize its specialized skills in the CI environment.
  • Incremental Refactor Alignment: Successfully rebased and integrated these changes with the recent skills-based refactoring in main.

Related Issues

Related to #26717

How to Validate

  1. Manual Trigger: Go to the Actions tab and run the 🧠 Gemini CLI Bot: Brain workflow on this branch.
  2. Verify Mandate: Select issue-fixer or interactive from the mandate dropdown and verify in the logs that the correct prompt and mandate are selected.
  3. Policy Check: Verify that the activate_skill tool call succeeds (or no longer fails with "Tool not found").

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

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 12, 2026

Size Change: -4 B (0%)

Total Size: 33.8 MB

Filename Size Change
./bundle/chunk-4M4ROHNP.js 0 B -3.43 kB (removed) 🏆
./bundle/chunk-53KM2QET.js 0 B -16.5 MB (removed) 🏆
./bundle/chunk-5SXQEWXY.js 0 B -49.2 kB (removed) 🏆
./bundle/chunk-EGNJHBRW.js 0 B -12.5 kB (removed) 🏆
./bundle/chunk-JIMQKCNQ.js 0 B -658 kB (removed) 🏆
./bundle/chunk-KJ3MEIKE.js 0 B -19.5 kB (removed) 🏆
./bundle/chunk-LHS2Y2CK.js 0 B -2.78 MB (removed) 🏆
./bundle/chunk-WO4FLERD.js 0 B -3.77 kB (removed) 🏆
./bundle/core-A3LYXDWA.js 0 B -49.1 kB (removed) 🏆
./bundle/devtoolsService-IN7BHUX7.js 0 B -28 kB (removed) 🏆
./bundle/gemini-SQL2KYMJ.js 0 B -585 kB (removed) 🏆
./bundle/interactiveCli-EVH65IOT.js 0 B -1.3 MB (removed) 🏆
./bundle/liteRtServerManager-64J5LTFA.js 0 B -2.08 kB (removed) 🏆
./bundle/oauth2-provider-7GLAZ4MT.js 0 B -9.12 kB (removed) 🏆
./bundle/chunk-6AKWOPZW.js 3.77 kB +3.77 kB (new file) 🆕
./bundle/chunk-6VN2HGLE.js 658 kB +658 kB (new file) 🆕
./bundle/chunk-7WUNZJS2.js 2.78 MB +2.78 MB (new file) 🆕
./bundle/chunk-KIIUNFIB.js 16.5 MB +16.5 MB (new file) 🆕
./bundle/chunk-PXUO3ZC4.js 3.43 kB +3.43 kB (new file) 🆕
./bundle/chunk-TQW7MRAP.js 49.2 kB +49.2 kB (new file) 🆕
./bundle/chunk-UZKDEL3Q.js 19.5 kB +19.5 kB (new file) 🆕
./bundle/chunk-ZWPTNQ6A.js 12.5 kB +12.5 kB (new file) 🆕
./bundle/core-W2UX7GLI.js 49.1 kB +49.1 kB (new file) 🆕
./bundle/devtoolsService-IH2CWG7X.js 28 kB +28 kB (new file) 🆕
./bundle/gemini-ZAKIHJQH.js 585 kB +585 kB (new file) 🆕
./bundle/interactiveCli-3OA5DCPP.js 1.3 MB +1.3 MB (new file) 🆕
./bundle/liteRtServerManager-RCI5NIVW.js 2.08 kB +2.08 kB (new file) 🆕
./bundle/oauth2-provider-NCQDLP5R.js 9.12 kB +9.12 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-CTHYVDCX.js 39.8 kB 0 B
./bundle/chunk-DAHVX5MI.js 206 kB 0 B
./bundle/chunk-IUUIT4SU.js 56.5 kB 0 B
./bundle/cleanup-MEX4K5WZ.js 0 B -902 B (removed) 🏆
./bundle/devtools-36NN55EP.js 696 kB 0 B
./bundle/dist-JYLQM7LS.js 373 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.07 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/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-GR6MMZWR.js 0 B -622 B (removed) 🏆
./bundle/tree-sitter-7U6MW5PS.js 274 kB 0 B
./bundle/tree-sitter-bash-34ZGLXVX.js 1.84 MB 0 B
./bundle/cleanup-YMQG73HD.js 902 B +902 B (new file) 🆕
./bundle/start-QXH7GBGE.js 622 B +622 B (new file) 🆕

compressed-size-action

gundermanc added 22 commits May 12, 2026 14:33
- Updates the `issue-fixer` skill to strictly forbid the use of local tools (like lint, tsc, grep) for finding tasks.
- Updates `scheduled.md` to clarify that local tools are for verification only.
- Replaces `gh issue list` with the `--json` flag to prevent default pagers (like `less`) from waiting for user input and hanging the CI run.
- Adds `--no-pager` to `gh run view`.
- Sets `GH_PAGER: ''` in the workflow environment variables to ensure any `gh` CLI commands executed by the bot or in bash scripts do not hang waiting for user input in the headless CI environment.
This adds a settings.json file to the bot's configuration to explicitly allow GH_TOKEN and GITHUB_TOKEN to bypass the environment variable redaction engine. This is required because the bot runs in GitHub Actions, which enforces strict redaction mode by default. The workflow file was also simplified by removing the wrapper script that was previously used to bypass redaction.
- Update the publish workflow to read labels from a pr-labels.txt file and apply them to the PR using the gh CLI.
- Update the prs skill to instruct the bot to write labels to pr-labels.txt.
- Update the issue-fixer and metrics skills to explicitly request the application of their respective labels in pr-labels.txt.
This removes the `NEVER_ALLOWED_NAME_PATTERNS` filter from `getSecureSanitizationConfig`.

Previously, if a user explicitly added a variable like `GH_TOKEN` to their `allowedEnvironmentVariables` in `settings.json`, it would be silently dropped during configuration parsing because it matched the `NEVER_ALLOWED_NAME_PATTERNS` regex.

This change ensures that explicit user allowlists take precedence over heuristic name-based pattern matching, while still maintaining the strict blocklist for known highly-sensitive system variables (`NEVER_ALLOWED_ENVIRONMENT_VARIABLES`).
The pr-labels.txt file was being correctly generated by the bot but was not
being passed to the Publish Artifacts job because it was omitted from the
Archive Brain Data step.
- Added a 60 minute timeout to the Reasoning job in the workflow.
- Updated the issue-fixer skill to instruct the bot to wrap 'npm run preflight' with the linux 'timeout' utility to prevent infinite loops from hanging the entire LLM agent.
The non-interactive CLI defaults to infinite `maxSessionTurns`. This causes the bot to get stuck in infinite trial-and-error loops when it struggles to fix a failing test suite, only stopping when the 60-minute GitHub Actions timeout kills the runner.

By setting `maxSessionTurns: 30` in the bot's configuration, the LLM session will gracefully abort with an error if it cannot find a solution within a reasonable number of attempts.
Updated the issue-fixer skill to instruct the bot to search one top-level
folder at a time and avoid problematic directories with large data files
(memory-tests, last_brain_data) to prevent grep_search timeouts.
- Removed the `maxSessionTurns: 30` limit from the bot's configuration as requested.
- Added `if: always()` to the `Archive Brain Data` step in the workflow to ensure logs (telemetry, debug) are available even when the agent fails or times out.
This fix was recovered from a timed-out bot run. It addresses issue #26979
where the CLI would crash if a user provided an extremely long path string
in an @ command (e.g. @/aaa...a).

Changes:
- Updated 'robustRealpath' in 'packages/core/src/utils/paths.ts' to catch
  and gracefully handle 'ENAMETOOLONG' and 'EINVAL' errors from fs.realpathSync
  and fs.lstatSync.
- Added a defensive try-catch block to 'checkPermissions' in
  'packages/cli/src/ui/hooks/atCommandProcessor.ts' to prevent long path
  strings from crashing the CLI during @ command parsing.
- Added regression unit tests to verify the fix.
- Pin publish job to the specific SHA from reasoning job to avoid drift.

- Use git apply --3way --ignore-whitespace for better conflict resolution.
@gundermanc gundermanc marked this pull request as ready for review May 15, 2026 20:22
@gundermanc gundermanc requested review from a team as code owners May 15, 2026 20:22
@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 enhances the Gemini CLI Bot by implementing a specialized 'issue-fixer' skill and providing maintainers with greater control over bot behavior through mandate selection. These changes streamline the bot's ability to manage repository backlogs while reinforcing security policies and refining the internal logic for environment variable handling and tool usage.

Highlights

  • Issue Fixer Skill Implementation: Introduced a new 'issue-fixer' skill that enables the bot to autonomously identify and resolve 'effort/small' issues and maintain existing 'bot-fix' pull requests.
  • Workflow Mandate Selection: Updated the 'gemini-cli-bot-brain.yml' workflow to support manual mandate selection (auto, issue-fixer, metrics, interactive) via 'workflow_dispatch', allowing for targeted testing of bot behaviors.
  • CI Policy and Security Updates: Updated 'ci-policy.toml' to permit the 'activate_skill' tool and explicitly deny 'google_web_search' to improve security and tool usage control.
  • Environment Sanitization Refinement: Optimized environment variable redaction logic to ensure 'GEMINI_CLI_' variables are correctly handled and allowlisted variables are respected.
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 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 .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 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

  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.

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 environment sanitization logic, refines bot skill workflows with stricter operational constraints—such as mandatory skill activation and test timeouts—and adjusts the CI policy. Review feedback highlights critical security regressions in the sanitization service, specifically noting that moving allowlist checks before secret pattern matching permits sensitive data leakage. The reviewer also flagged the removal of 'value-first' security tests as a major regression and pointed out that allowlisting tokens in settings is both ineffective due to name filtering and poses a security risk.

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

packages/core/src/services/environmentSanitization.ts (172)

critical

The allowedSet check should be restored here, after the value-based pattern matching, to maintain the 'value-first' security policy.

  if (allowedSet?.has(key)) {
    return false;
  }

packages/core/src/services/environmentSanitization.test.ts (233-273)

critical

The removal of the 'value-first security' test suite is a major regression. These tests ensure that high-entropy secrets are caught regardless of the variable name. Deleting them, especially alongside the logic changes that weaken this protection, significantly reduces the security posture of the environment sanitization service. These tests must be restored.

packages/core/src/services/environmentSanitization.ts (153-155)

security-high high

The change in sanitizeEnvironment to check the allowedSet before NEVER_ALLOWED_VALUE_PATTERNS introduces a significant security regression. This 'value-first' security model is crucial for defense-in-depth. Previously, even allowlisted variables were checked for sensitive data. Now, any variable in the user-configurable allowedSet can bypass these safety checks, potentially leaking sensitive values like private keys, GitHub tokens, JWTs, or certificates, even if their names don't match forbidden patterns. The allowedSet check should remain after the value-based pattern matching to ensure all values are scanned for secrets.

Additionally, note that adding GH_TOKEN to the allowed list in settings.json will not work as intended because getSecureSanitizationConfig (line 217) filters out any variables matching NEVER_ALLOWED_NAME_PATTERNS (which includes /TOKEN/i).

  if (value) {
    for (const pattern of NEVER_ALLOWED_VALUE_PATTERNS) {
      if (pattern.test(value)) {
        return true;
      }
    }
  }

  if (allowedSet?.has(key)) {
    return false;
  }
References
  1. Security checks, such as an extension allowlist, should be implemented in a 'fail-closed' manner. If an item's validity cannot be verified, it should be rejected by default.

tools/gemini-cli-bot/.gemini/settings.json (4)

high

Adding GH_TOKEN and GITHUB_TOKEN to the allowed list here will not have the desired effect. The getSecureSanitizationConfig function in environmentSanitization.ts explicitly filters out any variables matching NEVER_ALLOWED_NAME_PATTERNS, which includes /TOKEN/i. Furthermore, allowing these tokens to pass through sanitization is a security risk if the sanitized environment is sent to the LLM. The bot should access these tokens through a secure tool execution mechanism rather than by exposing them in the sanitized environment context.

References
  1. Security checks should be implemented in a 'fail-closed' manner. If an item's validity cannot be verified, it should be rejected by default.

- Use the `prs` skill to list all open PRs labeled `bot-fix`.
- If any require attention (CI failure, requested changes), focus your entire run on resolving ONE of them.
- Do NOT start a new issue fix if an existing PR needs work.
2. **Search for Candidates**: If no PRs need attention, search for `effort/small` issues: `gh issue list --label "effort/small" --limit 10 --json number,title,url`.
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.

i think we only care about open issues? so adding status:open to the search query?


1. **Inventory & Drive PRs**:
- **ACTIVATE SKILLS**: You MUST call `activate_skill(name="memory")` and `activate_skill(name="prs")` before continuing.
- Use the `prs` skill to list all open PRs labeled `bot-fix`.
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.

it might worth also checking if the issue associated with the pr is still open or closed already.

@@ -21,17 +38,22 @@ If you are proposing fixes and PR creation is enabled (per the System Directive)
unrelated refactor, or a metrics script update. Metrics and fixes MUST
be in separate PRs.
2. **Generate PR Description**: Use the `write_file` tool to create
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.

also worth using pr template to keep consistency?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants