diff --git a/web/app/components/base/chat/chat/__tests__/hooks.spec.tsx b/web/app/components/base/chat/chat/__tests__/hooks.spec.tsx index f1a2e34c6c4..ccfcd3c78ff 100644 --- a/web/app/components/base/chat/chat/__tests__/hooks.spec.tsx +++ b/web/app/components/base/chat/chat/__tests__/hooks.spec.tsx @@ -2010,7 +2010,7 @@ describe('useChat', () => { }) const lastResponse = result.current.chatList[1] - expect(lastResponse!.content).toBe('') + expect(lastResponse!.content).toBe('history top-level answer') expect(lastResponse!.agent_response_parts).toBeUndefined() expect(lastResponse!.workflow_run_id).toBe('history-workflow-run') expect(lastResponse!.workflowProcess).toBeUndefined() diff --git a/web/app/components/base/chat/chat/hooks.ts b/web/app/components/base/chat/chat/hooks.ts index 612f977d38b..81cd70e625d 100644 --- a/web/app/components/base/chat/chat/hooks.ts +++ b/web/app/components/base/chat/chat/hooks.ts @@ -984,10 +984,9 @@ export const useChat = ( return onConversationComplete?.(conversationIdRef.current, completedWorkflowRunId) const historyAgentThoughts = getHistoryAgentThoughts(newResponseItem) - const hasHistoryAgentThoughtAnswer = historyAgentThoughts.some(thought => thought.answer?.trim()) const lastHistoryAgentThought = historyAgentThoughts.at(-1) const historyAnswer = newResponseItem.answer || '' - const isUseAgentThought = (lastHistoryAgentThought?.thought === historyAnswer) || (options.isNewAgent && hasHistoryAgentThoughtAnswer) + const isUseAgentThought = !options.isNewAgent && lastHistoryAgentThought?.thought === historyAnswer const messageLog = Array.isArray(newResponseItem.message) ? newResponseItem.message : [] const answerTokens = newResponseItem.answer_tokens ?? 0 const messageTokens = newResponseItem.message_tokens ?? 0