Fix tool results being mixed into thinking blocks
- Add missing tool-result event handling in useStreamResponse - Tool results now appear as separate ToolResultMessage components - Prevents tool response content from being incorrectly added to reasoning content - Maintains proper message order: thinking → tool call → tool result → assistant response
This commit is contained in:
parent
e7dd5776c3
commit
6126405ab0
1 changed files with 23 additions and 0 deletions
|
|
@ -288,6 +288,29 @@ export const useStreamResponse = ({
|
||||||
} else {
|
} else {
|
||||||
console.warn('[useStreamResponse] Tool call event missing toolName:', event)
|
console.warn('[useStreamResponse] Tool call event missing toolName:', event)
|
||||||
}
|
}
|
||||||
|
} else if (event.type === 'tool-result') {
|
||||||
|
debugLog(`[useStreamResponse] Tool result:`, event)
|
||||||
|
|
||||||
|
if (event.toolName && event.toolCallId) {
|
||||||
|
setConversations((prev) => {
|
||||||
|
const updated = [...prev]
|
||||||
|
const conv = updated.find((c) => c.id === conversationId)
|
||||||
|
if (conv) {
|
||||||
|
// Add tool result message
|
||||||
|
conv.messages.push({
|
||||||
|
role: 'tool-result',
|
||||||
|
toolName: event.toolName,
|
||||||
|
toolArgs: event.args || {},
|
||||||
|
toolResult: event.result,
|
||||||
|
callId: event.toolCallId,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return updated
|
||||||
|
})
|
||||||
|
scrollToBottom(true)
|
||||||
|
} else {
|
||||||
|
console.warn('[useStreamResponse] Tool result event missing toolName or toolCallId:', event)
|
||||||
|
}
|
||||||
} else if (event.type === 'text-delta') {
|
} else if (event.type === 'text-delta') {
|
||||||
debugLog(`[useStreamResponse] Text delta:`, event.textDelta)
|
debugLog(`[useStreamResponse] Text delta:`, event.textDelta)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue