Skip to content

feat(core): centralize read_file limits and update gemini-3 description#20619

Merged
aishaneeshah merged 8 commits intomainfrom
tools-feedback
Mar 2, 2026
Merged

feat(core): centralize read_file limits and update gemini-3 description#20619
aishaneeshah merged 8 commits intomainfrom
tools-feedback

Conversation

@aishaneeshah
Copy link
Contributor

Summary

Updated read_file tool description for Gemini 3 models to explicitly mention truncation limits and navigation parameters. Centralized shared constants for tool limits in packages/core/src/utils/constants.ts to ensure consistency between implementation and model instructions.

Details

  • Moved DEFAULT_MAX_LINES_TEXT_FILE, MAX_LINE_LENGTH_TEXT_FILE, and MAX_FILE_SIZE_MB to packages/core/src/utils/constants.ts.
  • Updated packages/core/src/tools/definitions/model-family-sets/gemini-3.ts to import these constants and use them in the read_file description.
  • Refactored packages/core/src/utils/fileUtils.ts to use the centralized constants.
  • Updated model snapshots to reflect the improved description.

Related Issues

Related to #19459

How to Validate

Run existing model snapshot and tool tests:

npm test -w @google/gemini-cli-core -- src/tools/definitions/coreToolsModelSnapshots.test.ts
npm test -w @google/gemini-cli-core -- src/tools/read-file.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:
    • Linux
      • npm run

@aishaneeshah aishaneeshah requested a review from a team as a code owner February 27, 2026 21:36
@gemini-cli
Copy link
Contributor

gemini-cli bot commented Feb 27, 2026

Hi @aishaneeshah, thank you so much for your contribution to Gemini CLI! We really appreciate the time and effort you've put into this.

We're making some updates to our contribution process to improve how we track and review changes. Please take a moment to review our recent discussion post: Improving Our Contribution Process & Introducing New Guidelines.

Key Update: Starting January 26, 2026, the Gemini CLI project will require all pull requests to be associated with an existing issue. Any pull requests not linked to an issue by that date will be automatically closed.

Thank you for your understanding and for being a part of our community!

@gemini-code-assist
Copy link
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 clarity and maintainability of file processing limits within the core module. By centralizing key constants, it ensures that the read_file tool's behavior and its description to the model are always in sync, providing more accurate and consistent information about truncation and file size handling for Gemini 3 models.

Highlights

  • Centralized Tool Limits: Moved DEFAULT_MAX_LINES_TEXT_FILE, MAX_LINE_LENGTH_TEXT_FILE, and MAX_FILE_SIZE_MB into a shared constants.ts file to ensure consistency across the codebase.
  • Updated read_file Tool Description: The read_file tool description for Gemini 3 models has been updated to explicitly mention truncation limits (lines and characters) and file size limits, using the newly centralized constants.
  • Refactored File Utilities: The fileUtils.ts module was updated to import and utilize the centralized constants for file processing limits, removing redundant local definitions.
Changelog
  • packages/core/src/tools/definitions/snapshots/coreToolsModelSnapshots.test.ts.snap
    • Updated the read_file tool description within the Gemini-3-pro-preview model snapshot to reflect new truncation and size limits.
  • packages/core/src/tools/definitions/model-family-sets/gemini-3.ts
    • Imported DEFAULT_MAX_LINES_TEXT_FILE, MAX_LINE_LENGTH_TEXT_FILE, and MAX_FILE_SIZE_MB constants.
    • Updated the read_file tool description to dynamically include these limits.
  • packages/core/src/utils/constants.ts
    • Added new constants: DEFAULT_MAX_LINES_TEXT_FILE, MAX_LINE_LENGTH_TEXT_FILE, and MAX_FILE_SIZE_MB.
  • packages/core/src/utils/fileUtils.ts
    • Imported the newly centralized constants.
    • Removed the local definitions of DEFAULT_MAX_LINES_TEXT_FILE and MAX_LINE_LENGTH_TEXT_FILE.
    • Replaced the hardcoded 20 MB limit with MAX_FILE_SIZE_MB in the processSingleFileContent function.
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.

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 refactors the read_file tool by centralizing its limits for maximum lines, line length, and file size into a shared constants.ts file. The implementation in fileUtils.ts and the tool description for Gemini 3 models in gemini-3.ts are updated to use these new constants, ensuring consistency. The test snapshots are updated accordingly. The changes are confined to this refactoring and appear correct.

@github-actions
Copy link

github-actions bot commented Feb 27, 2026

Size Change: +435 B (0%)

Total Size: 25.8 MB

ℹ️ View Unchanged
Filename Size Change
./bundle/gemini.js 25.3 MB +435 B (0%)
./bundle/node_modules/@google/gemini-cli-devtools/dist/client/main.js 221 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/_client-assets.js 227 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/index.js 11.5 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

compressed-size-action

@gemini-cli gemini-cli bot added the 🔒 maintainer only ⛔ Do not contribute. Internal roadmap item. label Feb 27, 2026
exports[`coreTools snapshots for specific models > Model: gemini-3-pro-preview > snapshot for tool: read_file 1`] = `
{
"description": "Reads and returns the content of a specified file. If the file is large, the content will be truncated. The tool's response will clearly indicate if truncation has occurred and will provide details on how to read more of the file using the 'start_line' and 'end_line' parameters. Handles text, images (PNG, JPG, GIF, WEBP, SVG, BMP), audio files (MP3, WAV, AIFF, AAC, OGG, FLAC), and PDF files. For text files, it can read specific line ranges.",
"description": "Reads and returns the content of a specified file. For text files, it reads up to 2000 lines at a time (use 'start_line' and 'end_line' to navigate) and truncates lines longer than 2000 characters. The tool's response will clearly indicate if truncation has occurred. Supports files up to 20MB. Handles text, images (PNG, JPG, GIF, WEBP, SVG, BMP), audio files (MP3, WAV, AIFF, AAC, OGG, FLAC), and PDF files.",
Copy link
Member

@gundermanc gundermanc Feb 27, 2026

Choose a reason for hiding this comment

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

One thing that might be worth checking is if telling the agent explicitly what the threshold discourages it from using the start_line and end_line and if that increases token consumption, etc. as a result. It seems like a delicate balance between wanting to read less and wanting to avoid extra turns on follow up reads.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point - I have modified the description to still encourage surgical reads, while mentioning the safety limits. I experimented with a few versions, and have updated to this one which seems to bring a good balance between two.

@aishaneeshah aishaneeshah enabled auto-merge March 2, 2026 04:09
@aishaneeshah aishaneeshah disabled auto-merge March 2, 2026 15:01
@aishaneeshah aishaneeshah enabled auto-merge March 2, 2026 15:02
@aishaneeshah aishaneeshah added this pull request to the merge queue Mar 2, 2026
Merged via the queue into main with commit 659301f Mar 2, 2026
27 checks passed
@aishaneeshah aishaneeshah deleted the tools-feedback branch March 2, 2026 20:30
BryanBradfo pushed a commit to BryanBradfo/gemini-cli that referenced this pull request Mar 5, 2026
struckoff pushed a commit to struckoff/gemini-cli that referenced this pull request Mar 6, 2026
liamhelmer pushed a commit to badal-io/gemini-cli that referenced this pull request Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔒 maintainer only ⛔ Do not contribute. Internal roadmap item.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants