Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion core/util/messageConversion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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,
});
}
}
}
Expand Down
Loading