From e08aa8533adc016084bdd29e9f4d31741ab1815e Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Mon, 19 Jan 2026 19:34:20 +0530 Subject: [PATCH] search through conversation history - instead of using toolcallstates --- core/util/conversationCompaction.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/core/util/conversationCompaction.ts b/core/util/conversationCompaction.ts index fda114bf8..45f11d95a 100644 --- a/core/util/conversationCompaction.ts +++ b/core/util/conversationCompaction.ts @@ -55,15 +55,14 @@ export async function compactConversation({ messages.push(item.message); // toolcalls only exist in an assistant message if (item.message.role === "assistant" && item.message.toolCalls) { - // for every toolcall, if there is no toolcallstate or its output, add a chat message saying that it is empty + // for every toolcall, if there is no tool message with a tool call id already, add a chat message saying that it is empty item.message.toolCalls.forEach((toolCall) => { - const foundToolCallState = item.toolCallStates?.find( - (toolCallState) => toolCallState.toolCallId === toolCall.id, - ); if ( - !foundToolCallState || - !foundToolCallState.output || - !foundToolCallState.output.length + !filteredHistory.find( + (item) => + item.message.role === "tool" && + item.message.toolCallId === toolCall.id, + ) ) { messages.push({ role: "tool",