-
Notifications
You must be signed in to change notification settings - Fork 14.5k
refactor(core): centralize tool definitions (Group 1: replace, search, grep) #18944
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
71aeeb1
refactor(core): centralize grep_search definition and update descript…
aishaneeshah 24c682b
refactor(core): centralize replace tool definition
aishaneeshah 43cf174
refactor(core): centralize google_web_search tool definition
aishaneeshah a60feef
Merge branch 'refactor-edit-tool' into refactor-tools-group-1
aishaneeshah fcaf465
refactor(core): centralize grep_search, replace, and google_web_searc…
aishaneeshah ee0b201
refactor(core): keep grep_search and ripgrep_search as separate tools…
aishaneeshah 9def9e3
refactor(core): centralize grep_search and google_web_search tool def…
aishaneeshah a7e5ea6
refactor(core): ensure group 1 tool definitions match main exactly
aishaneeshah d5fba27
Merge branch 'main' into refactor-tools-group-1
aishaneeshah 0b81d90
Merge branch 'main' into refactor-tools-group-1
aishaneeshah File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
308 changes: 308 additions & 0 deletions
308
packages/core/src/tools/definitions/__snapshots__/coreToolsModelSnapshots.test.ts.snap
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,9 +20,12 @@ import { | |
| READ_FILE_DEFINITION, | ||
| WRITE_FILE_DEFINITION, | ||
| GREP_DEFINITION, | ||
| RIP_GREP_DEFINITION, | ||
| GLOB_DEFINITION, | ||
| LS_DEFINITION, | ||
| getShellDefinition, | ||
| EDIT_DEFINITION, | ||
| WEB_SEARCH_DEFINITION, | ||
| } from './coreTools.js'; | ||
|
|
||
| describe('coreTools snapshots for specific models', () => { | ||
|
|
@@ -52,12 +55,15 @@ describe('coreTools snapshots for specific models', () => { | |
| { name: 'read_file', definition: READ_FILE_DEFINITION }, | ||
| { name: 'write_file', definition: WRITE_FILE_DEFINITION }, | ||
| { name: 'grep_search', definition: GREP_DEFINITION }, | ||
| { name: 'grep_search_ripgrep', definition: RIP_GREP_DEFINITION }, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this change the name of the tool as seen by the model? I think we want that to stay 'grep'. |
||
| { name: 'glob', definition: GLOB_DEFINITION }, | ||
| { name: 'list_directory', definition: LS_DEFINITION }, | ||
| { | ||
| name: 'run_shell_command', | ||
| definition: getShellDefinition(true, true), | ||
| }, | ||
| { name: 'replace', definition: EDIT_DEFINITION }, | ||
| { name: 'google_web_search', definition: WEB_SEARCH_DEFINITION }, | ||
| ]; | ||
|
|
||
| for (const modelId of modelIds) { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
grep_searchtool (specifically theRipGrepToolimplementation) includes ano_ignoreparameter that, when set totrue, causes the tool to bypass all file ignore rules (such as.gitignoreand.geminiignore). This allows the LLM to search and read potentially sensitive files that are intended to be hidden, such as.envfiles containing secrets, private keys, or configuration files. Sincegrep_searchis a "read" tool (Kind.Search), it may not require user confirmation in many configurations, allowing an LLM to exfiltrate sensitive data without the user's knowledge if it is tricked via prompt injection.Consider removing the
no_ignoreparameter from the tool's public schema to prevent the LLM from bypassing ignore rules. If the functionality is required for users, ensure that its use by the LLM always triggers a high-visibility warning or requires explicit user confirmation.