You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(amazonq): Address multiple history bugs (aws#7059)
## Problem
- `fixHistory` only processes the first conversation associated with the
tab, but there can be multiple. Results in an incomplete history and
messes up the history sent in the request
- We currently delete the entire history for a tab if an exception is
thrown. This is not ideal and leads to customer confusion when they are
not able to continue using their chat history after an error.
- Right-click actions like `Explain this code` fail when preceding
message history contains toolResults. Mynah does not recognize this enum
- Fake messages for tooluse failures are being stored the chat history.
## Solution
- Collect message across all conversation associated with the current
tab and consolidate them into a single conversation
- Remove clearTab() call when exception is thrown
- Do not include history for requests to Mynah
- Remove clearRecentHistory as this is no longer used
- Do not store these fake messages to the chatHistory
## Testing
- Manually tested fixes:
- Chat history still remains after exception is thrown
- Mynah no longer throws exception for right-click action following tool
execution

---
- 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.
Copy file name to clipboardExpand all lines: packages/core/src/codewhispererChat/controllers/chat/controller.ts
+10-7Lines changed: 10 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -744,6 +744,7 @@ export class ChatController {
744
744
consttoolResults: ToolResult[]=[]
745
745
746
746
letresponse=''
747
+
letshouldDisplayMessage=true
747
748
if(toolUseError){
748
749
toolResults.push({
749
750
content: [{text: toolUseError.message}],
@@ -753,6 +754,7 @@ export class ChatController {
753
754
if(toolUseErrorinstanceofSyntaxError){
754
755
response=
755
756
"Your toolUse input isn't valid. Please check the syntax and make sure the input is complete. If the input is large, break it down into multiple tool uses with smaller input."
757
+
shouldDisplayMessage=false
756
758
}
757
759
}else{
758
760
constresult=ToolUtils.tryFromToolUse(toolUse)
@@ -844,6 +846,7 @@ export class ChatController {
844
846
contextLengths: {
845
847
...defaultContextLengths,
846
848
},
849
+
shouldDisplayMessage: shouldDisplayMessage,
847
850
},
848
851
triggerID
849
852
)
@@ -1138,9 +1141,6 @@ export class ChatController {
// Drop empty assistant partial if it’s the last message
379
344
this.handleEmptyAssistantMessage(allMessages)
380
345
@@ -387,11 +352,33 @@ export class Database {
387
352
// If the last message is from the assistant and it contains tool uses, and a next user message is set without tool results, then the user message will have cancelled tool results.
388
353
this.handleToolUses(allMessages,newUserMessage)
389
354
390
-
activeConversation.messages=allMessages
355
+
tabData.conversations=[
356
+
{
357
+
conversationId: conversationId,
358
+
clientType: ClientType.VSCode,
359
+
messages: allMessages,
360
+
},
361
+
]
362
+
tabData.updatedAt=newDate()
391
363
tabCollection.update(tabData)
392
364
this.logger.info(`Updated tab data in collection`)
0 commit comments