feat(core): migrate read_file to 1-based start_line/end_line parameters - #19526
Conversation
|
Hi @adamfweidman, 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 @adamfweidman, 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 refactors 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
|
|
Size Change: +83 B (0%) Total Size: 24.5 MB ℹ️ View Unchanged
|
There was a problem hiding this comment.
Code Review
The pull request successfully migrates the read_file tool to use 1-based start_line and end_line parameters, which improves alignment with how Large Language Models naturally reason about line ranges. The core logic in fileUtils.ts and the tool definitions have been updated correctly to handle these new parameters. However, a regression was identified in the line-slicing logic where the default safety limit is no longer applied if start_line is provided without an accompanying end_line. Additionally, the truncation message in the tool output has lost its helpful example for pagination, which should be restored to assist the model in subsequent calls.
Summary
Migrates the
read_filetool from 0-basedoffset/limitparameters to 1-basedstart_line/end_lineparameters. This improves precision and aligns the API with how Large Language Models naturally reason about line ranges.Details
offset(0-based) andlimitwithstart_line(1-based) andend_line(1-based, inclusive) inReadFileToolParams.processSingleFileContentinfileUtils.tsto correctly handle 1-based ranges, converting them to 0-based array indices internally.default-legacy.tsandgemini-3.tswith revised descriptions and schemas.snippets.tsto guide models toward using the new parameters for large files.start_line >= 1,end_line >= 1, andstart_line <= end_line.Math.maxcalls in utility logic and corrected minor typos in system prompts.read-file.test.tsandfileUtils.test.ts, updated snapshots, and resolved ESLintno-explicit-anyviolations.Related Issues
Fixes #17542
How to Validate
npm test -w @google/gemini-cli-core -- src/tools/read-file.test.ts src/utils/fileUtils.test.tsPre-Merge Checklist