feat(core): refine Edit and WriteFile tool schemas for Gemini 3#19476
feat(core): refine Edit and WriteFile tool schemas for Gemini 3#19476SandyTao520 merged 7 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! |
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 focuses on optimizing the tool schema descriptions for 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 does a great job of refining and optimizing the tool schemas for Edit and WriteFile, specifically for Gemini 3 models. The changes successfully reduce token usage and improve clarity by simplifying descriptions and resolving a key logical contradiction around multiple replacements. The overall direction is excellent. I have one suggestion to further improve the clarity of the replace tool's schema to prevent potential ambiguity for the model.
|
Size Change: -2.74 kB (-0.01%) Total Size: 24.5 MB
ℹ️ View Unchanged
|
fcc8848 to
5f95733
Compare
5f95733 to
2b39807
Compare
aishaneeshah
left a comment
There was a problem hiding this comment.
One question/suggestion
| **Important:** If ANY of the above are not satisfied, the tool will fail. CRITICAL for \`old_string\`: Must uniquely identify the single instance to change. Include at least 3 lines of context BEFORE and AFTER the target text, matching whitespace and indentation precisely. If this string matches multiple locations, or does not match exactly, the tool will fail. | ||
| 5. Prefer to break down complex and long changes into multiple smaller atomic calls to this tool. Always check the content of the file after changes or not finding a string to match. | ||
| **Multiple replacements:** Set \`expected_replacements\` to the number of occurrences you want to replace. The tool will replace ALL occurrences that match \`old_string\` exactly. Ensure the number of replacements matches your expectation.", | ||
| "description": "Replaces text within a file. By default, replaces a single occurrence, but can replace multiple occurrences when \`expected_replacements\` is specified. This tool requires providing significant context around the change to ensure precise targeting. |
There was a problem hiding this comment.
The expected_replacement part is mentioned multiple times - would it make sense to just add "only" here at the higher level description, and remove them from below?
There was a problem hiding this comment.
I think we can still reduce further
"Replaces text within a file. By default, replaces a single occurrence, but can replace multiple occurrences ONLY when `expected_replacements` is specified. This tool requires providing significant context around the change to ensure precise targeting.
The user has the ability to modify the `new_string` content. If modified, this will be stated in the response.
CRITICAL for `old_string`: Include at least 3 lines of context BEFORE and AFTER the target text, matching whitespace and indentation precisely."
WDYT?
6399bbb to
e8bf7a3
Compare
adamfweidman
left a comment
There was a problem hiding this comment.
LGTM, just remove the .tgz file
e8bf7a3 to
eb3f5fc
Compare
213b975 to
9e3e03d
Compare
Summary
This PR refines and optimizes the tool schema descriptions for the
Edit(replace) andWriteFiletools, specifically for Gemini 3 models. The goal is to reduce token usage, improve clarity, and resolve internal contradictions in the schema definitions.Details
read_filefrom the top-level description.instructionparameter description by removing verbose 'how-to' sections and examples.old_stringcontext requirement whenexpected_replacementsis used.old_stringandnew_stringdescriptions to reflect the strict requirement for unescaped literal text.packages/core/src/tools/definitions/model-family-sets/gemini-3.ts. The legacy tool set remains unchanged to preserve historical behavior.Related Issues
Related to #17547, #17546
Relates to #19269
How to Validate
npm run test -w @google/gemini-cli-core -- src/tools/definitions/coreToolsModelSnapshots.test.tsPre-Merge Checklist