From 9b7ee72becd5fa3bf72c6deacd55f671c75ce892 Mon Sep 17 00:00:00 2001 From: chezsmithy Date: Tue, 6 May 2025 22:57:37 -0700 Subject: [PATCH] simplify constructMessages.ts --- core/llm/constructMessages.ts | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/core/llm/constructMessages.ts b/core/llm/constructMessages.ts index b7da0de17..309429d4b 100644 --- a/core/llm/constructMessages.ts +++ b/core/llm/constructMessages.ts @@ -8,9 +8,8 @@ import { } from "../"; import { findLast } from "../util/findLast"; import { normalizeToMessageParts } from "../util/messageContent"; -import { isUserOrToolMsg, messageHasToolCallId } from "./messages"; +import { isUserOrToolMsg } from "./messages"; import { getSystemMessageWithRules } from "./rules/getSystemMessageWithRules"; -import { BuiltInToolNames } from "../tools/builtIn"; export const DEFAULT_CHAT_SYSTEM_MESSAGE_URL = "https://github.com/continuedev/continue/blob/main/core/llm/constructMessages.ts"; @@ -88,21 +87,14 @@ export function constructMessages( (item) => item.message.role !== "system", ); const msgs: ChatMessage[] = []; - const toolCallIdsToRemove: string[] = []; for (let i = 0; i < filteredHistory.length; i++) { const historyItem = filteredHistory[i]; if (messageMode === "chat") { - if (historyItem.toolCallState?.toolCallId) { - // remove all tool calls from the history - toolCallIdsToRemove.push(historyItem.toolCallState.toolCall.id); - continue; - } - const toolMessage: ToolResultChatMessage = historyItem.message as ToolResultChatMessage; - if (toolMessage.toolCallId && toolCallIdsToRemove.includes(toolMessage.toolCallId)) { - // remove toolcall responses from the history + if (historyItem.toolCallState?.toolCallId || toolMessage.toolCallId) { + // remove all tool calls from the history continue; } }