Skip to content

Add model field for custom TOML command override#24930

Open
mrinank1301 wants to merge 5 commits intogoogle-gemini:mainfrom
mrinank1301:feat/custom-command-model-override
Open

Add model field for custom TOML command override#24930
mrinank1301 wants to merge 5 commits intogoogle-gemini:mainfrom
mrinank1301:feat/custom-command-model-override

Conversation

@mrinank1301
Copy link
Copy Markdown

@mrinank1301 mrinank1301 commented Apr 8, 2026

Summary

Add an optional model field to custom command .toml files, allowing users to pin a specific Gemini model per command. The override is temporary — the previously selected model is automatically restored after the response completes. This lets users save pro-model quota on verbose/lightweight commands like code recaps or documentation generation.

Details

Data flow:

  1. FileCommandLoader parses model from TOML and returns it as modelOverride in the submit_prompt action result
  2. slashCommandProcessor threads modelOverride through to the consumer
  3. useGeminiStream saves the current model, applies the override via config.setModel(), sends the query, and restores the original model in a finally block
  4. nonInteractiveCli follows the same save/override/restore pattern

Files changed:

  • packages/core/src/commands/types.ts — Added modelOverride to SubmitPromptActionReturn
  • packages/cli/src/ui/types.ts — Added modelOverride to SubmitPromptResult
  • packages/cli/src/services/FileCommandLoader.ts — Extended Zod schema with optional model field
  • packages/cli/src/ui/hooks/slashCommandProcessor.ts — Thread modelOverride through result
  • packages/cli/src/ui/hooks/useGeminiStream.ts — Save/restore model around query execution
  • packages/cli/src/nonInteractiveCliCommands.ts — Updated return type to include modelOverride
  • packages/cli/src/nonInteractiveCli.ts — Save/restore model for non-interactive mode
  • packages/cli/src/nonInteractiveCli.test.ts — Updated mock to match new return type
  • packages/cli/src/services/FileCommandLoader.test.ts — Added 2 new tests for model field
  • docs/cli/custom-commands.md — Documented model field with usage example

Related Issues

Related to #19875

How to Validate

  1. Unit tests:
    npx vitest run packages/cli/src/services/FileCommandLoader.test.ts
    npx vitest run packages/cli/src/nonInteractiveCli.test.ts

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

@mrinank1301 mrinank1301 requested review from a team as code owners April 8, 2026 15:34
@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 introduces the ability to specify a preferred Gemini model within custom TOML command definitions. This feature is designed to optimize quota usage by allowing lightweight commands to run on smaller models while preserving pro-model capacity for complex tasks. The implementation ensures that these model overrides are scoped strictly to the command execution, with the system automatically restoring the user's previous model configuration upon completion. Additionally, the PR includes stability improvements for Windows environments, specifically addressing file locking issues during cleanup and improving linter compatibility.

Highlights

  • Custom Model Override: Added support for an optional 'model' field in custom TOML command definitions, allowing users to pin specific Gemini models to individual commands.
  • Temporary Model Switching: Implemented a save-and-restore mechanism for the active model, ensuring that any model override is temporary and automatically reverts to the user's original selection after the command execution completes.
  • Windows Compatibility Improvements: Enhanced 'scripts/clean.js' to handle locked files gracefully on Windows and updated 'scripts/lint.js' to skip unsupported linters (actionlint and shellcheck) on Windows platforms.
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.

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 introduces a model override feature, allowing users to specify a Gemini model in TOML command definitions. It updates the CLI to handle this override during execution and restores the original model upon completion. Additionally, it improves the clean script to handle locked files on Windows and updates the lint script to gracefully skip linters that are not supported on certain platforms. However, the changes to scripts/lint.js introduce critical syntax errors due to improperly closed template literals and unreachable code, which will cause the script to fail.

@gemini-cli gemini-cli bot added area/core Issues related to User Interface, OS Support, Core Functionality help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support! labels Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Issues related to User Interface, OS Support, Core Functionality help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant