We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a70862c commit 90bed46Copy full SHA for 90bed46
packages/server/api/src/app/ai/chat/utils.ts
@@ -23,9 +23,18 @@ export function mergeToolResultsIntoMessages(
23
const msg = messages[i];
24
25
if (isToolMessage(msg)) {
26
- const toolResult = (msg.content as any[])[0];
27
- if (toolResult?.toolCallId) {
28
- toolResultsToMerge.push({ toolResult, messageIndex: i });
+ if (Array.isArray(msg.content) && msg.content.length > 0) {
+ const toolResult = msg.content[0];
+ if (
29
+ toolResult &&
30
+ typeof toolResult === 'object' &&
31
+ 'toolCallId' in toolResult
32
+ ) {
33
+ toolResultsToMerge.push({
34
+ toolResult: toolResult as ToolResultPart,
35
+ messageIndex: i,
36
+ });
37
+ }
38
}
39
continue;
40
0 commit comments