diff --git a/ui/desktop/src/hooks/useChatStream.ts b/ui/desktop/src/hooks/useChatStream.ts index 64ed1912de43..e084b04d6e2a 100644 --- a/ui/desktop/src/hooks/useChatStream.ts +++ b/ui/desktop/src/hooks/useChatStream.ts @@ -146,6 +146,8 @@ async function streamFromResponse( } case 'UpdateConversation': { log.messages('conversation-update', event.conversation.length); + // WARNING: Since Message handler uses this local variable, we need to update it here to avoid the client clobbering it. + // Longterm fix is to only send the agent the new messages, not the entire conversation. currentMessages = event.conversation; updateMessages(event.conversation); break; diff --git a/ui/desktop/src/hooks/useMessageStream.ts b/ui/desktop/src/hooks/useMessageStream.ts index 081d264a7a54..2eb98835935b 100644 --- a/ui/desktop/src/hooks/useMessageStream.ts +++ b/ui/desktop/src/hooks/useMessageStream.ts @@ -354,6 +354,9 @@ export function useMessageStream({ } case 'UpdateConversation': { + // WARNING: Since Message handler uses this local variable, we need to update it here to avoid the client clobbering it. + // Longterm fix is to only send the agent the new messages, not the entire conversation. + currentMessages = parsedEvent.conversation; setMessages(parsedEvent.conversation); break; }