Skip to content

More grep prompt tweaks#18846

Merged
gundermanc merged 4 commits intomainfrom
gundermanc/more-evals
Feb 11, 2026
Merged

More grep prompt tweaks#18846
gundermanc merged 4 commits intomainfrom
gundermanc/more-evals

Conversation

@gundermanc
Copy link
Member

@gundermanc gundermanc commented Feb 11, 2026

Summary

Adds another case to the grep prompt.

Details

Related Issues

How to Validate

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

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @gundermanc, 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 new evaluations and updates core prompt instructions to enhance the agent's efficiency when using search tools. The goal is to ensure the agent minimizes context window usage by applying stricter limits on search results, thereby improving performance and reducing unnecessary data retrieval.

Highlights

  • Enhanced Search Efficiency Evaluations: New evaluation tests were added to frugalSearch.eval.ts to verify that the agent uses total_max_matches and max_matches_per_file parameters effectively, ensuring search tools are used frugally.
  • Improved Prompt Instructions for Context Efficiency: The core prompt snippets in snippets.ts were updated to provide clearer guidance on scoping and limiting search queries, including recommendations for names_only=true or max_matches_per_file=1 for broad discovery.
Changelog
  • evals/frugalSearch.eval.ts
    • Added a JSDoc comment explaining the purpose of the frugal search evaluations.
    • Modified the expect assertions to specifically check for total_max_matches and max_matches_per_file limits in search calls.
  • packages/core/src/prompts/snippets.ts
    • Updated the "Context Efficiency" section to provide more detailed guidance on limiting search results.
    • Added a new instruction recommending names_only=true or max_matches_per_file=1 for broad discovery.
Activity
  • No human activity has been recorded on this pull request yet.
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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

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.

@gundermanc gundermanc changed the title Gundermanc/more evals More grep prompt tweaks Feb 11, 2026
@gundermanc gundermanc marked this pull request as ready for review February 11, 2026 21:21
@gundermanc gundermanc requested a review from a team as a code owner February 11, 2026 21:21
Copy link
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 enhances the agent's search efficiency by refining the system prompt to encourage frugal use of search tools and adds corresponding evaluation tests. The prompt changes are clear and provide better guidance. I've suggested an improvement to the new evaluation test to make its validation logic more robust by ensuring a single search call is frugal in all expected ways, rather than checking for different aspects of frugality across multiple calls.

Comment on lines +122 to 141
const hasTotalMaxLimit = grepParams.some(
(p) => p.total_max_matches !== undefined && p.total_max_matches <= 100,
);
expect(
hasTotalMaxLimit,
`Expected agent to use a small total_max_matches (<= 100) for a sample usage request. Actual values: ${JSON.stringify(
grepParams.map((p) => p.total_max_matches),
)}`,
).toBe(true);

const hasMaxMatchesPerFileLimit = grepParams.some(
(p) =>
p.max_matches_per_file !== undefined && p.max_matches_per_file <= 5,
);
expect(
hasFrugalLimit,
`Expected agent to use a small total_max_matches for a sample usage request. Params used: ${JSON.stringify(
grepCalls.map(getGrepParams),
null,
2,
hasMaxMatchesPerFileLimit,
`Expected agent to use a small max_matches_per_file (<= 5) for a sample usage request. Actual values: ${JSON.stringify(
grepParams.map((p) => p.max_matches_per_file),
)}`,
).toBe(true);
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The current test logic checks for total_max_matches and max_matches_per_file limits in separate some() calls. This means the test can pass if one grep call has a total_max_matches limit and a different call has a max_matches_per_file limit.

To ensure that the agent is making truly frugal calls, we should verify that at least one call includes both limits simultaneously. This can be done with a single some() and expect() call that combines both conditions.

      const hasFrugalCall = grepParams.some(
        (p) =>
          (p.total_max_matches !== undefined && p.total_max_matches <= 100) &&
          (p.max_matches_per_file !== undefined && p.max_matches_per_file <= 5),
      );
      expect(
        hasFrugalCall,
        `Expected agent to use a small total_max_matches (<= 100) AND max_matches_per_file (<= 5) in at least one call. Actual params: ${JSON.stringify(
          grepParams,
        )}`,
      ).toBe(true);

@github-actions
Copy link

github-actions bot commented Feb 11, 2026

Size Change: +208 B (0%)

Total Size: 24.3 MB

ℹ️ View Unchanged
Filename Size Change
./bundle/gemini.js 24.3 MB +208 B (0%)
./bundle/sandbox-macos-permissive-closed.sb 1.03 kB 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-closed.sb 3.29 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

compressed-size-action

@gundermanc gundermanc enabled auto-merge February 11, 2026 21:33
@gemini-cli gemini-cli bot added the priority/p1 Important and should be addressed in the near term. label Feb 11, 2026
@gundermanc gundermanc added this pull request to the merge queue Feb 11, 2026
Merged via the queue into main with commit 6c17731 Feb 11, 2026
27 checks passed
@gundermanc gundermanc deleted the gundermanc/more-evals branch February 11, 2026 22:11
krsjenmt added a commit to krsjenmt/gemini-cli that referenced this pull request Feb 12, 2026
…ini/gemini-cli (#37)

* fix(cli): resolve double rendering in shpool and address vscode lint warnings (google-gemini#18704)

* feat(plan): document and validate Plan Mode policy overrides (google-gemini#18825)

* Fix pressing any key to exit select mode. (google-gemini#18421)

* fix(cli): update F12 behavior to only open drawer if browser fails (google-gemini#18829)

* feat(plan): allow skills to be enabled in plan mode (google-gemini#18817)

Co-authored-by: Jerop Kipruto <jerop@google.com>

* docs(plan): add documentation for plan mode tools (google-gemini#18827)

* Remove experimental note in extension settings docs (google-gemini#18822)

* Update prompt and grep tool definition to limit context size (google-gemini#18780)

* docs(plan): add `ask_user` tool documentation (google-gemini#18830)

* Revert unintended credentials exposure (google-gemini#18840)

* feat(core): update internal utility models to Gemini 3 (google-gemini#18773)

* feat(a2a): add value-resolver for auth credential resolution (google-gemini#18653)

* Removed getPlainTextLength (google-gemini#18848)

* More grep prompt tweaks (google-gemini#18846)

* refactor(cli): Reactive useSettingsStore hook (google-gemini#14915)

* fix(mcp): Ensure that stdio MCP server execution has the `GEMINI_CLI=1` env variable populated. (google-gemini#18832)

* fix(core): improve headless mode detection for flags and query args (google-gemini#18855)

* refactor(cli): simplify UI and remove legacy inline tool confirmation logic (google-gemini#18566)

* feat(cli): deprecate --allowed-tools and excludeTools in favor of policy engine (google-gemini#18508)

* fix(workflows): improve maintainer detection for automated PR actions (google-gemini#18869)

* refactor(cli): consolidate useToolScheduler and delete legacy implementation (google-gemini#18567)

* Update changelog for v0.28.0 and v0.29.0-preview0 (google-gemini#18819)

* fix(core): ensure sub-agents are registered regardless of tools.allowed (google-gemini#18870)

---------

Co-authored-by: Brad Dux <959674+braddux@users.noreply.github.com>
Co-authored-by: Jerop Kipruto <jerop@google.com>
Co-authored-by: Jacob Richman <jacob314@gmail.com>
Co-authored-by: Sandy Tao <sandytao520@icloud.com>
Co-authored-by: Adib234 <30782825+Adib234@users.noreply.github.com>
Co-authored-by: christine betts <chrstn@uw.edu>
Co-authored-by: Christian Gunderman <gundermanc@gmail.com>
Co-authored-by: Adam Weidman <65992621+adamfweidman@users.noreply.github.com>
Co-authored-by: Dev Randalpura <devrandalpura@google.com>
Co-authored-by: Pyush Sinha <pyushsinha20@gmail.com>
Co-authored-by: Richie Foreman <richie.foreman@gmail.com>
Co-authored-by: Gal Zahavi <38544478+galz10@users.noreply.github.com>
Co-authored-by: Abhi <43648792+abhipatel12@users.noreply.github.com>
Co-authored-by: Abhijit Balaji <abhijitbalaji@google.com>
Co-authored-by: Bryan Morgan <bryanmorgan@google.com>
Co-authored-by: g-samroberts <158088236+g-samroberts@users.noreply.github.com>
Co-authored-by: matt korwel <matt.korwel@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority/p1 Important and should be addressed in the near term.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants