Files
gemini-cli/packages/core
Adam Weidman d5c0212b01 # PR Description: Refactor read_file Tool to Discourage Pagination
## Changes
- Removed `offset` and `limit` parameters from the `read_file` tool and the underlying `processSingleFileContent` utility.
- Updated `read_file` to always return the first 2000 lines of a text file if it exceeds that length.
- Added explicit guidance in the tool's truncation message and description, distinguishing between `grep_search` for pattern finding and `run_shell_command` (specifically `sed`) for extracting specific line ranges.
- Simplified `ProcessedFileReadResult` by removing `linesShown`.
- Updated all internal callers (including `ReadManyFilesTool`, `planCommand`, and `ExitPlanModeDialog`) to match the new signature of `processSingleFileContent`.
- Updated unit tests in `read-file.test.ts` and `fileUtils.test.ts` to verify the new 2000-line default truncation and remove pagination-related test cases.

## Motivation & Feedback
These changes were made to address feedback regarding how the model interacts with large files:
- **Discouraging Inefficient Pagination:** Feedback noted that providing `offset` and `limit` encouraged models to "paginate" through files chunk-by-chunk, which is often an inefficient "looping" behavior.
- **Encouraging Targeted Search:** By removing pagination parameters, we push the model toward more powerful and standard search behaviors. As the feedback stated: *"In my experience it's better to encourage the model to use grep or more complex bash commands to find what it needs."*
- **Compatibility with Search Results:** Models frequently use `grep -n` to find points of interest. Standard Unix tools like `sed` and `grep` are more compatible with 1-based line numbers and sophisticated searching than a manual 0-based `offset`/`limit` implementation.
- **Clarity on Truncation:** Addressed the feedback *"Could be useful to specify how will it be truncated"* by explicitly stating the 2000-line limit in the tool's output and description.
2026-02-09 13:56:02 -05:00
..
2026-02-06 16:10:17 +00:00