refactor: simplify tool output truncation to single config#18446
refactor: simplify tool output truncation to single config#18446SandyTao520 merged 2 commits intomainfrom
Conversation
|
Hi @SandyTao520, 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! |
|
Hi there! Thank you for your contribution to Gemini CLI. To improve our contribution process and better track changes, we now require all pull requests to be associated with an existing issue, as announced in our recent discussion and as detailed in our CONTRIBUTING.md. This pull request is being closed because it is not currently linked to an issue. Once you have updated the description of this PR to link an issue (e.g., by adding How to link an issue: Thank you for your understanding and for being a part of our community! |
Summary of ChangesHello @SandyTao520, 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 streamlines the configuration and behavior of tool output truncation. By unifying multiple settings into a single character-based threshold and implementing a more informative head-and-tail display for truncated content, the system becomes easier to manage and provides better context for large outputs, especially when interacting with language models. The default truncation limit has also been adjusted to be more practical for current LLM constraints. 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 effectively simplifies the tool output truncation configuration by consolidating three settings into a single truncateToolOutputThreshold. The implementation of the new head/tail truncation logic is clean and the related changes across the codebase, including tests and schemas, are consistent. The default threshold has also been reasonably lowered.
However, I've identified one critical issue where the chat history compression logic might be unintentionally truncating tool outputs far more aggressively than before (from 4,000 characters down to 30), which could lead to significant context loss for the model. Please see the specific comment for details.
|
Size Change: -2.53 kB (-0.01%) Total Size: 23.8 MB
ℹ️ View Unchanged
|
56d9fe6 to
6322f18
Compare
| this.config.getTruncateToolOutputLines() > 0 | ||
| ) { | ||
| const originalContentLength = content.length; | ||
| if (typeof content === 'string' && toolName === SHELL_TOOL_NAME) { |
There was a problem hiding this comment.
I forget, why do we need thr truncation logic at the tool executor level instead of inside of the shell tool?
There was a problem hiding this comment.
So we plan to expand this to other tools like grep and web_search which have large outputs, will explore this a bit and see if should proceed or just remove it.
3d2e677 to
e2f1c33
Compare
e2f1c33 to
0bb4d22
Compare
…e unused totalLines
Summary
Consolidate three truncation settings into one (
truncateToolOutputThreshold). Truncated output now shows head (20%) + tail (80%) with an omission marker. Default threshold lowered from 4M to 40K characters.Details
enableToolOutputTruncationandtruncateToolOutputLinessettingstruncateToolOutputThreshold > 0enables truncation,<= 0disables it[N characters omitted]marker, last 80% of threshold charslinesfield fromToolOutputTruncatedEventtelemetryRelated Issues
#17037
How to Validate
cata large file)[N characters omitted]+ tailtruncateToolOutputThreshold: 0and verify truncation is disabledPre-Merge Checklist