diff --git a/packages/core/src/codewhispererChat/constants.ts b/packages/core/src/codewhispererChat/constants.ts index 093b7e1a1d2..f1b1c5f235c 100644 --- a/packages/core/src/codewhispererChat/constants.ts +++ b/packages/core/src/codewhispererChat/constants.ts @@ -56,6 +56,8 @@ export const defaultContextLengths: ContextLengths = { export const defaultStreamingResponseTimeoutInMs = 180_000 +export const maxHistoryMessages = 100 + export const ignoredDirectoriesAndFiles = [ // Dependency directories 'node_modules', diff --git a/packages/core/src/codewhispererChat/controllers/chat/controller.ts b/packages/core/src/codewhispererChat/controllers/chat/controller.ts index 573a26fc5e2..92756f60cd1 100644 --- a/packages/core/src/codewhispererChat/controllers/chat/controller.ts +++ b/packages/core/src/codewhispererChat/controllers/chat/controller.ts @@ -92,6 +92,7 @@ import { additionalContentInnerContextLimit, workspaceChunkMaxSize, defaultContextLengths, + maxHistoryMessages, } from '../../constants' import { ChatSession } from '../../clients/chat/v0/chat' import { amazonQTabSuffix } from '../../../shared/constants' @@ -1601,7 +1602,7 @@ export class ChatController { // Do not include chatHistory for requests going to Mynah request.conversationState.history = request.conversationState.currentMessage?.userInputMessage?.userIntent ? [] - : this.chatHistoryDb.getMessages(tabID).map((chat) => messageToChatMessage(chat)) + : this.chatHistoryDb.getMessages(tabID, maxHistoryMessages).map((chat) => messageToChatMessage(chat)) request.conversationState.conversationId = session.sessionIdentifier triggerPayload.documentReferences = this.mergeRelevantTextDocuments(triggerPayload.relevantTextDocuments)