Remove all duplicate detection logic

- Remove existingToolCall and existingToolResult checks
- Add every API event as a new message regardless of duplicates
- Provides complete unfiltered log of all API data after middleware
- Useful for debugging and understanding raw data flow
This commit is contained in:
Glen Maddern 2025-06-25 12:09:31 +10:00
commit ab73226b87

View file

@ -241,20 +241,14 @@ export const useStreamResponse = ({
const updated = [...prev] const updated = [...prev]
const conv = updated.find((c) => c.id === conversationId) const conv = updated.find((c) => c.id === conversationId)
if (conv) { if (conv) {
// Check if this tool call already exists conv.messages.push({
const existingToolCall = conv.messages.find( role: 'tool-call',
(msg) => msg.role === 'tool-call' && 'callId' in msg && msg.callId === event.toolCallId toolName: event.toolName,
) toolArgs: event.args || {},
if (!existingToolCall) { callId: event.toolCallId || 'unknown',
conv.messages.push({ })
role: 'tool-call', debugMessages('Added new tool-call message:', event.toolName, 'callId:', event.toolCallId)
toolName: event.toolName, debugMessages('Current messages:', JSON.stringify(conv.messages))
toolArgs: event.args || {},
callId: event.toolCallId || 'unknown',
})
debugMessages('Added new tool-call message:', event.toolName, 'callId:', event.toolCallId)
debugMessages('Current messages:', JSON.stringify(conv.messages))
}
} }
return updated return updated
}) })
@ -269,23 +263,15 @@ export const useStreamResponse = ({
const updated = [...prev] const updated = [...prev]
const conv = updated.find((c) => c.id === conversationId) const conv = updated.find((c) => c.id === conversationId)
if (conv) { if (conv) {
// Check if this tool result already exists conv.messages.push({
const existingToolResult = conv.messages.find( role: 'tool-result',
(msg) => msg.role === 'tool-result' && 'callId' in msg && msg.callId === (event as any).toolCallId toolName: (event as any).toolName,
) toolArgs: (event as any).args || {},
if (!existingToolResult) { toolResult: (event as any).result,
// Add tool result message callId: (event as any).toolCallId,
conv.messages.push({ })
role: 'tool-result', debugMessages('Added new tool-result message:', (event as any).toolName, 'callId:', (event as any).toolCallId)
toolName: (event as any).toolName, debugMessages('Current messages:', JSON.stringify(conv.messages))
toolArgs: (event as any).args || {},
toolResult: (event as any).result,
callId: (event as any).toolCallId,
})
debugMessages('Added new tool-result message:', (event as any).toolName, 'callId:', (event as any).toolCallId)
debugMessages('Current messages:', JSON.stringify(conv.messages))
} else {
}
} }
return updated return updated
}) })