Skip to content

feat(core): implement silent fallback for Plan Mode model routing#25317

Merged
jerop merged 2 commits intomainfrom
silent-fallback-plan-mode
Apr 13, 2026
Merged

feat(core): implement silent fallback for Plan Mode model routing#25317
jerop merged 2 commits intomainfrom
silent-fallback-plan-mode

Conversation

@jerop
Copy link
Copy Markdown
Contributor

@jerop jerop commented Apr 13, 2026

Summary

Implement silent fallback for Plan Mode to ensure an uninterrupted user experience when Pro models are unavailable or inaccessible.

Details

This PR introduces a "Unified Injection" approach to enforce silent fallback when the system is in Plan Mode. By intercepting the ModelPolicyChain resolution in resolvePolicyChain, all fallback actions are overridden to 'silent' if ApprovalMode.PLAN is active. This ensures that failures in the primary planning model (Pro) automatically trigger a transition to the next available model (Flash) without interrupting the user with prompts or getting "stuck".

  • Exported SILENT_ACTIONS from policyCatalog.ts.
  • Refactored resolvePolicyChain in policyHelpers.ts to apply silent overrides.
  • Added unit tests in policyHelpers.test.ts verifying silent fallback for both legacy and dynamic routing paths.
  • Updated docs/cli/plan-mode.md to document the new behavior.

Related Issues

Closes #25110

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

This change introduces a 'Unified Injection' approach to enforce silent
fallback when the system is in Plan Mode. By intercepting the
ModelPolicyChain resolution, all fallback actions are overridden to
'silent', ensuring that failures in the primary planning model (Pro)
automatically trigger a transition to the next available model (Flash)
without interrupting the user.

- Exported SILENT_ACTIONS from policyCatalog.ts
- Refactored resolvePolicyChain in policyHelpers.ts to apply silent overrides
- Added unit tests to verify silent fallback in Plan Mode
@jerop jerop requested review from a team as code owners April 13, 2026 18:23
@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 implements a silent fallback mechanism for Plan Mode to ensure a seamless user experience. By overriding model policy actions to 'silent' when Plan Mode is active, the system can automatically transition to alternative models without interrupting the user with prompts or blocking execution when primary models are unavailable.

Highlights

  • Silent Fallback Implementation: Introduced a unified injection mechanism in resolvePolicyChain that forces silent fallback actions when the system is in Plan Mode.
  • Policy Configuration: Exported SILENT_ACTIONS from policyCatalog.ts to allow consistent application of silent fallback policies across the core module.
  • Testing and Documentation: Added unit tests to verify silent fallback behavior for both legacy and dynamic routing paths, and updated the CLI documentation to reflect this change.
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 13, 2026

Size Change: +242 B (0%)

Total Size: 34.1 MB

Filename Size Change
./bundle/chunk-MAJ3LJ7B.js 0 B -14.9 MB (removed) 🏆
./bundle/chunk-N66GR2LY.js 0 B -3.8 kB (removed) 🏆
./bundle/chunk-RRQY3D3B.js 0 B -3.54 MB (removed) 🏆
./bundle/core-N3ZGBU6H.js 0 B -46.4 kB (removed) 🏆
./bundle/devtoolsService-DBBSGIZX.js 0 B -28.4 kB (removed) 🏆
./bundle/gemini-MMZCPTCB.js 0 B -553 kB (removed) 🏆
./bundle/interactiveCli-RABDRH5H.js 0 B -1.29 MB (removed) 🏆
./bundle/oauth2-provider-TKLSMUTJ.js 0 B -9.16 kB (removed) 🏆
./bundle/chunk-BXPMZ3LJ.js 14.9 MB +14.9 MB (new file) 🆕
./bundle/chunk-MZGDNZ4G.js 3.54 MB +3.54 MB (new file) 🆕
./bundle/chunk-Y7RAS27O.js 3.8 kB +3.8 kB (new file) 🆕
./bundle/core-NPUUSHKP.js 46.4 kB +46.4 kB (new file) 🆕
./bundle/devtoolsService-LNXLXW6F.js 28.4 kB +28.4 kB (new file) 🆕
./bundle/gemini-TCTIUQST.js 553 kB +553 kB (new file) 🆕
./bundle/interactiveCli-UD72RAPB.js 1.29 MB +1.29 MB (new file) 🆕
./bundle/oauth2-provider-2TQ57JTU.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-MKPNQHQJ.js 1.96 MB 0 B
./bundle/chunk-RJTRUG2J.js 39.8 kB 0 B
./bundle/cleanup-XMDNMCN4.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/gemini.js 4.97 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-ZLS4FEK7.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/tree-sitter-7U6MW5PS.js 274 kB 0 B
./bundle/tree-sitter-bash-34ZGLXVX.js 1.84 MB 0 B
./bundle/cleanup-A3XYNSBD.js 932 B +932 B (new file) 🆕

compressed-size-action

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 documentation to reflect automatic model fallback behavior and implements a unified silent policy injection when the CLI is in Plan Mode. The resolvePolicyChain function was refactored to ensure consistent application of dynamic slicing and to override policy actions with SILENT_ACTIONS during planning. A review comment identifies a potential issue where SILENT_ACTIONS is assigned by reference, which could lead to shared state across policies; it is recommended to use the spread operator to provide each policy with its own instance of the actions map.

@gemini-cli gemini-cli bot added area/core Issues related to User Interface, OS Support, Core Functionality area/agent Issues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Quality labels Apr 13, 2026
This addresses a review comment pointing out that assigning SILENT_ACTIONS
directly could lead to shared state across policies. We now use the spread
operator to provide each policy with its own instance of the actions map.
@jerop jerop added this pull request to the merge queue Apr 13, 2026
Merged via the queue into main with commit 050c303 Apr 13, 2026
27 of 28 checks passed
@jerop jerop deleted the silent-fallback-plan-mode branch April 13, 2026 20:34
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 area/core Issues related to User Interface, OS Support, Core Functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI constantly get stuck for 15 minutes or more on a simple implmentation plan review

2 participants