Fix tools again, except it's still in the wrong format goddammit

This commit is contained in:
Alex Gleason committed 2025-08-23 15:38:32 -05:00
1 parent 4bc1ae96c9
commit c565decbe3
2 files changed
+22 -15

No files matched your search

+2 -2
View File
@@ -37,9 +37,9 @@ export const AssistantContent = memo(({ content }: AssistantContentProps) => {
}
// Handle direct string results
if (typeof toolResult.output === 'string') {
if (toolResult.output.type === 'text') {
return {
result: toolResult.output,
result: toolResult.output.value,
isError: false
};
}
+20 -13
View File
@@ -340,21 +340,28 @@ export function useStreamingChat({
// Add tool result to current message
if (currentAssistantMessageId) {
updateMessage(currentAssistantMessageId, (prev) => {
const currentContent = prev.content;
const content: Array<TextPart | ToolCallPart | ToolResultPart> = Array.isArray(currentContent) ?
currentContent.filter((part): part is TextPart | ToolCallPart | ToolResultPart =>
part.type === 'text' || part.type === 'tool-call' || part.type === 'tool-result'
) :
typeof currentContent === 'string' && currentContent ? [{ type: 'text' as const, text: currentContent }] : [];
if (prev.role === 'assistant') {
let content = prev.content;
content.push({
type: 'tool-result' as const,
toolCallId: chunk.toolCallId,
toolName: chunk.toolName,
output: chunk.output
});
if (typeof content === 'string') {
content = [{ type: 'text', text: content }];
}
return { content };
content.push({
type: 'tool-result',
toolCallId: chunk.toolCallId,
toolName: chunk.toolName,
output: {
type: 'text',
value: String(chunk.output),
},
});
return { content };
} else {
console.warn(`Streaming message should be an assistant message. Was a ${prev.role} message.`)
return prev;
}
});
}
break;