File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
server/aws-lsp-codewhisperer/src/language-server/agenticChat/tools/chatDb Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -442,6 +442,17 @@ export class ChatDatabase {
442442 // Make sure max characters ≤ remaining Character Budget
443443 allMessages = this . trimMessagesToMaxLength ( allMessages , remainingCharacterBudget )
444444
445+ // Edge case: If the history is empty and the next message contains tool results, then we have to just abandon them.
446+ if (
447+ allMessages . length === 0 &&
448+ newUserMessage . userInputMessage ?. userInputMessageContext ?. toolResults ?. length &&
449+ newUserMessage . userInputMessage ?. userInputMessageContext ?. toolResults ?. length > 0
450+ ) {
451+ this . #features. logging . warn ( 'History overflow: abandoning dangling toolResults.' )
452+ newUserMessage . userInputMessage . userInputMessageContext . toolResults = [ ]
453+ newUserMessage . userInputMessage . content = 'The conversation history has overflowed, clearing state'
454+ }
455+
445456 const clientType = this . #features. lsp . getClientInitializeParams ( ) ?. clientInfo ?. name || 'unknown'
446457
447458 tabData . conversations = [
You can’t perform that action at this time.
0 commit comments