From 0792b949bdf629fd14dac45478b2027962b77454 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Thu, 11 Dec 2025 21:18:13 +0530 Subject: [PATCH] fix(cli): compaction for missing tool results --- core/util/messageConversion.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/util/messageConversion.ts b/core/util/messageConversion.ts index b94d7e63f27..dff75869933 100644 --- a/core/util/messageConversion.ts +++ b/core/util/messageConversion.ts @@ -327,7 +327,7 @@ export function convertFromUnifiedHistory( messages.push(baseMessage); - // Add tool result messages if there are completed tool calls + // Add tool result messages if there are completed tool calls, and fallback when tool output is missing if (item.toolCallStates) { for (const toolState of item.toolCallStates) { if (toolState.output && toolState.output.length > 0) { @@ -336,6 +336,12 @@ export function convertFromUnifiedHistory( content: toolState.output.map((o: any) => o.content).join("\n"), tool_call_id: toolState.toolCallId, }); + } else { + messages.push({ + role: "tool", + content: "Tool cancelled", + tool_call_id: toolState.toolCallId, + }); } } }