feat(core): centralize read_file limits and update gemini-3 description#20619
feat(core): centralize read_file limits and update gemini-3 description#20619aishaneeshah merged 8 commits intomainfrom
Conversation
|
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! |
Summary of ChangesHello, 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 Highlights
Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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.
|
Size Change: +435 B (0%) Total Size: 25.8 MB ℹ️ View Unchanged
|
| 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.", |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
f3d7f2e to
293cdba
Compare
Summary
Updated
read_filetool description for Gemini 3 models to explicitly mention truncation limits and navigation parameters. Centralized shared constants for tool limits inpackages/core/src/utils/constants.tsto ensure consistency between implementation and model instructions.Details
DEFAULT_MAX_LINES_TEXT_FILE,MAX_LINE_LENGTH_TEXT_FILE, andMAX_FILE_SIZE_MBtopackages/core/src/utils/constants.ts.packages/core/src/tools/definitions/model-family-sets/gemini-3.tsto import these constants and use them in theread_filedescription.packages/core/src/utils/fileUtils.tsto use the centralized constants.Related Issues
Related to #19459
How to Validate
Run existing model snapshot and tool tests:
Pre-Merge Checklist