Skip to content

Commit b00b014

Browse files
authored
fix: clear history for inputTooLong errors (#1268)
1 parent becfee0 commit b00b014

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

server/aws-lsp-codewhisperer/src/language-server/agenticChat/agenticChatController.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,7 @@ describe('AgenticChatController', () => {
10811081
const typedChatResult = chatResult as ResponseError<ChatResult>
10821082
assert.strictEqual(
10831083
typedChatResult.data?.body,
1084-
'Too much context loaded. Please start a new conversation or ask about specific files.'
1084+
'Too much context loaded. I have cleared the conversation history. Please retry your request with smaller input.'
10851085
)
10861086
})
10871087

server/aws-lsp-codewhisperer/src/language-server/agenticChat/agenticChatController.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1591,6 +1591,10 @@ export class AgenticChatController implements ChatHandlers {
15911591

15921592
if (customerFacingErrorCodes.includes(err.code)) {
15931593
this.#features.logging.error(`${loggingUtils.formatErr(err)}`)
1594+
if (err.code === 'InputTooLong') {
1595+
// Clear the chat history in the database for this tab
1596+
this.#chatHistoryDb.clearTab(tabId)
1597+
}
15941598
return new ResponseError<ChatResult>(LSPErrorCodes.RequestFailed, err.message, {
15951599
type: 'answer',
15961600
body: err.message,

server/aws-lsp-codewhisperer/src/language-server/chat/chatSessionService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export class ChatSessionService {
143143
requestId = e.$metadata?.requestId
144144
}
145145
throw new AgenticChatError(
146-
'Too much context loaded. Please start a new conversation or ask about specific files.',
146+
'Too much context loaded. I have cleared the conversation history. Please retry your request with smaller input.',
147147
'InputTooLong',
148148
e instanceof Error ? e : undefined,
149149
requestId

0 commit comments

Comments
 (0)