Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: final answer in new agent would clear after sse if agent thought has answer (#38649)

Joel4a8c6773a3f0
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