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,11 +241,6 @@ 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
const existingToolCall = conv.messages.find(
(msg) => msg.role === 'tool-call' && 'callId' in msg && msg.callId === event.toolCallId
)
if (!existingToolCall) {
conv.messages.push({ conv.messages.push({
role: 'tool-call', role: 'tool-call',
toolName: event.toolName, toolName: event.toolName,
@ -255,7 +250,6 @@ export const useStreamResponse = ({
debugMessages('Added new tool-call message:', event.toolName, 'callId:', event.toolCallId) debugMessages('Added new tool-call message:', event.toolName, 'callId:', event.toolCallId)
debugMessages('Current messages:', JSON.stringify(conv.messages)) debugMessages('Current messages:', JSON.stringify(conv.messages))
} }
}
return updated return updated
}) })
scrollToBottom(true) scrollToBottom(true)
@ -269,12 +263,6 @@ 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
const existingToolResult = conv.messages.find(
(msg) => msg.role === 'tool-result' && 'callId' in msg && msg.callId === (event as any).toolCallId
)
if (!existingToolResult) {
// Add tool result message
conv.messages.push({ conv.messages.push({
role: 'tool-result', role: 'tool-result',
toolName: (event as any).toolName, toolName: (event as any).toolName,
@ -284,8 +272,6 @@ export const useStreamResponse = ({
}) })
debugMessages('Added new tool-result message:', (event as any).toolName, '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)) debugMessages('Current messages:', JSON.stringify(conv.messages))
} else {
}
} }
return updated return updated
}) })