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

This commit is contained in:
Joel 2026-07-10 14:33:26 +08:00 committed by GitHub
parent d0f0134314
commit 4a8c6773a3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 3 deletions

View File

@ -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()

View File

@ -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