-
Notifications
You must be signed in to change notification settings - Fork 748
feat(chat): Adding the grep search tool. #7020
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
Closed
Closed
Conversation
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
… for agentic chat"
feat(chat):Added chat history storage to the Q chat for agentic chat
feat(chat): Updated model for Q Agnetic Chat APIs.
## Problem
Amazon Q Agentic Chat needs the ability to read files and directories
from the user's workspace to provide context-aware assistance.
Currently, there's no tool available for Amazon Q to access the file
system in a controlled and secure manner.
## Solution
- Implemented a new fsRead tool that allows Amazon Q to:
- Read entire files or specific line ranges
- List directory contents with configurable depth
- Handle error cases gracefully with informative messages
- Enforce size limits (30KB) to prevent excessive memory usage
## Testing
```
FsRead Unit Tests
extensionHostProcess.js:178
✔ reads entire file
extensionHostProcess.js:178
✔ reads partial lines of a file
extensionHostProcess.js:178
✔ lists directory contents up to depth = 1
extensionHostProcess.js:178
✔ throws error if path does not exist
extensionHostProcess.js:178
✔ throws error if content exceeds 30KB
extensionHostProcess.js:178
✔ invalid line range
```
---
- Treat all work as PUBLIC. Private `feature/x` branches will not be
squash-merged at release time.
- Your code changes must meet the guidelines in
[CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines).
- License: I confirm that my contribution is made under the terms of the
Apache 2.0 license.
feat(chat): Add validate method to fsRead tool
feat(chat): add fsWrite tool create command
## Problem Setting up new Q Agentic Chat loop with tool use. ## Solution Initial Agentic Chat loop Setup with tool use --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
feat(chat): add fsWrite tool commands
feat(amazonq): Adding openDiff and acceptDiff UX to the agentic chat.
feat(chat): Add executeBash tool for Amazon Q Agentic Chat
feat(chat): fix for q agentic chat loop
1. Implemented the tool using https://github.com/microsoft/vscode-ripgrep. 2. The grepped result show as clickable file path. 3. The tool currently is disable in current pr, once grepSearch tool tested, will update the tool_index.json to enable this tool.
## Problem Missing the following UI elements: - Pair programmer mode toggle message - ExecuteBash confirmation direction ## Solution Make use of the new directive message type introduced in aws/mynah-ui#273 --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
## Problem - Set valid tooluse Input when parsing fails ## Solution - Server side cannot handle the raw string --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
…7008) ## Problem We should ask for consensus tools accessing files/dirs outside of workspace ## Solution Add validation step when accessing files/dirs outside of workspace using fsRead or listDirectories tools. --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
## Problem Padding override is not needed anymore ## Solution Revert padding change since it looks like it was already fixed in mynah-ui --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
…pec for fsRead and fsWrite
fix(chat): Reduce maxToolResponseSize from 800K to 200K
### Problem: We identified and fixed an issue where the IDE's UI would prematurely stop displaying when executing certain commands. This occurred specifically when the Language Model (LLM) attempted to run the executeBash command before the Read/List Directory tools. ### Example: When a user asks "write a script that tells me whoami", the operation only requires the fsWrite command and not any directory reading tools. In such cases, the IDE would execute fsWrite but fail to display the executeBash tool in the chat interface. This[ UI behavior has been corrected ](https://github.com/aws/aws-toolkit-vscode/blob/2028754f3d933909f86bb65f18f06dab526d2708/packages/core/src/codewhispererChat/tools/chatStream.ts#L43-L47)in this PR, along with improvements to the Reading File user experience. - Major changes lies in this [commit](https://github.com/aws/aws-toolkit-vscode/blob/2028754f3d933909f86bb65f18f06dab526d2708/packages/core/src/codewhispererChat/tools/chatStream.ts#L43-L47) in `ChatStream.ts` ``` // For FsRead and ListDirectory tools If messageIdToUpdate is undefined, we need to first create an empty message with messageId so it can be updated later if (isReadorList && !messageIdToUpdate) { this.messenger.sendInitialToolMessage(tabID, triggerID, toolUse?.toolUseId) } else { this.messenger.sendInitalStream(tabID, triggerID) } ``` --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
## Problem Missing the following UI elements: - Pair programmer mode toggle message - ExecuteBash confirmation direction ## Solution Make use of the new directive message type introduced in aws/mynah-ui#273 --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
## Problem - Set valid tooluse Input when parsing fails ## Solution - Server side cannot handle the raw string --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
…7008) We should ask for consensus tools accessing files/dirs outside of workspace Add validation step when accessing files/dirs outside of workspace using fsRead or listDirectories tools. --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
## Problem Padding override is not needed anymore ## Solution Revert padding change since it looks like it was already fixed in mynah-ui --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
…pec for fsRead and fsWrite
This was only a potential performance optimization. Remove it since it prevents tryExecute from working with vscode-defined commands (which are not found in `this.resources`).
## Problem
"memory threshold" message logged multiple times for a the same PID:
2025-04-11 ... Process 23662 exceeded memory threshold: 506986496
2025-04-11 ... Process 23662 exceeded memory threshold: 507019264
2025-04-11 ... Process 23662 exceeded memory threshold: 507052032
2025-04-11 ... Process 23662 exceeded memory threshold: 507084800
This is noisy in the logs.
## Solution
Only log "memory threshold" once per PID.
### Problem: We identified and fixed an issue where the IDE's UI would prematurely stop displaying when executing certain commands. This occurred specifically when the Language Model (LLM) attempted to run the executeBash command before the Read/List Directory tools. ### Example: When a user asks "write a script that tells me whoami", the operation only requires the fsWrite command and not any directory reading tools. In such cases, the IDE would execute fsWrite but fail to display the executeBash tool in the chat interface. This[ UI behavior has been corrected ](https://github.com/aws/aws-toolkit-vscode/blob/2028754f3d933909f86bb65f18f06dab526d2708/packages/core/src/codewhispererChat/tools/chatStream.ts#L43-L47)in this PR, along with improvements to the Reading File user experience. - Major changes lies in this [commit](https://github.com/aws/aws-toolkit-vscode/blob/2028754f3d933909f86bb65f18f06dab526d2708/packages/core/src/codewhispererChat/tools/chatStream.ts#L43-L47) in `ChatStream.ts` ``` // For FsRead and ListDirectory tools If messageIdToUpdate is undefined, we need to first create an empty message with messageId so it can be updated later if (isReadorList && !messageIdToUpdate) { this.messenger.sendInitialToolMessage(tabID, triggerID, toolUse?.toolUseId) } else { this.messenger.sendInitalStream(tabID, triggerID) } ``` --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
1. Implemented the tool using https://github.com/microsoft/vscode-ripgrep. 2. The grepped result show as clickable file path. 3. The tool currently is disable in current pr, once grepSearch tool tested, will update the tool_index.json to enable this tool.
## Problem We need to switch to using the Chat History DB instead of the local store ## Solution - Add the same history fixing functionality to Chat History DB as the former chatHistory local store - Replace all uses of the local store - Maintain a sessionId/ConversationId for each tab ## Tested manually --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
|
Contributor
|
this is targeting master branch, I assume #7021 replaces this. Note: you can change the target branch by clicking |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Problem
Adding the grep search tool.
Solution
feature/xbranches will not be squash-merged at release time.