Skip to content

Commit 6f0dc14

Browse files
authored
fix(amazonq): Do not include references in request history (#7105)
## Problem - We currently include codeReferences as part of the history field in the request which can sometimes cause validation issues - `fsWrite` tool tends to favor doing line-by-line replaces which causes an increase in latency. ## Solution - Do not include references in request history - Updated the tool spec to add an important guideline around the fsWrite tool usage - restricting strReplace command to only simple single-line replacements, while recommending the create command for multi-line edits.: `* IMPORTANT: For the `fsWrite` tool, only use the `strReplace` command for simple, isolated single-line replacements. If you are editing multiple lines, always prefer the `create` command and replace the entire file content instead.` ## Testing #### Fields included in request history: ``` history: [ { userInputMessage: { content: 'What is aws cloudwatch in 5 sentences?', userIntent: undefined, origin: 'IDE', userInputMessageContext: { toolResults: undefined } } }, { assistantResponseMessage: { messageId: 'fa3ecd66-9271-4f9b-9ee2-13b80bd65df9', content: 'AWS CloudWatch is a monitoring and observability service that provides real-time monitoring of AWS resources and applications running on AWS infrastructure. It collects and tracks metrics, monitors log files, sets alarms, and automatically reacts to changes in your AWS resources. CloudWatch enables you to gain system-wide visibility into resource utilization, application performance, and operational health. With CloudWatch, you can detect anomalous behavior in your environments, set alarms, visualize logs and metrics side by side, take automated actions, troubleshoot issues, and discover insights to keep your applications running smoothly.', toolUses: [] } } ] ``` #### Latency test results | | Build with strReplace | Build without strReplace | | -------- | ------- | ------- | | renaming a single function | 16s | 17s | | translate comments (multi-line replace +19 -20) | 98s | 20s | --- - 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 parent f6a4e20 commit 6f0dc14

File tree

2 files changed

+1
-2
lines changed

2 files changed

+1
-2
lines changed

packages/core/src/codewhispererChat/tools/tool_index.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
},
2323
"fsWrite": {
2424
"name": "fsWrite",
25-
"description": "A tool for creating and editing a file.\n * The `create` command will override the file at `path` if it already exists as a file, and otherwise create a new file\n * The `append` command will add content to the end of an existing file, automatically adding a newline if the file doesn't end with one. The file must exist.\n Notes for using the `strReplace` command:\n * The `oldStr` parameter should match EXACTLY one or more consecutive lines from the original file. Be mindful of whitespaces!\n * If the `oldStr` parameter is not unique in the file, the replacement will not be performed. Make sure to include enough context in `oldStr` to make it unique\n * The `newStr` parameter should contain the edited lines that should replace the `oldStr`. The `insert` command will insert `newStr` after `insertLine` and place it on its own line.",
25+
"description": "A tool for creating and editing a file.\n * The `create` command will override the file at `path` if it already exists as a file, and otherwise create a new file\n * The `append` command will add content to the end of an existing file, automatically adding a newline if the file doesn't end with one. The file must exist.\n Notes for using the `strReplace` command:\n * IMPORTANT: For the `fsWrite` tool, only use the `strReplace` command for simple, isolated single-line replacements. If you are editing multiple lines, always prefer the `create` command and replace the entire file content instead.\n * The `oldStr` parameter should match EXACTLY one or more consecutive lines from the original file. Be mindful of whitespaces!\n * If the `oldStr` parameter is not unique in the file, the replacement will not be performed. Make sure to include enough context in `oldStr` to make it unique\n * The `newStr` parameter should contain the edited lines that should replace the `oldStr`. The `insert` command will insert `newStr` after `insertLine` and place it on its own line.",
2626
"inputSchema": {
2727
"type": "object",
2828
"properties": {

packages/core/src/shared/db/chatDb/util.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ export function messageToChatMessage(msg: Message): ChatMessage {
6868
assistantResponseMessage: {
6969
messageId: msg.messageId,
7070
content: msg.body,
71-
references: msg.codeReference || [],
7271
toolUses: msg.toolUses || [],
7372
},
7473
}

0 commit comments

Comments
 (0)