From 4f010cd4f5bf98c3a7683191b8b0294b91c6c14e Mon Sep 17 00:00:00 2001 From: Yansong Zhang <916125788@qq.com> Date: Thu, 9 Apr 2026 12:31:49 +0800 Subject: [PATCH] fix(api): stop emitting StreamChunkEvent from tool path to prevent answer duplication The EventAdapter was converting every LLMResultChunk from the agent strategy into StreamChunkEvent. Combined with the answer node's {{#agent.text#}} variable output, this caused the final answer to appear twice (e.g., "It is 2026-04-09 04:27:45.It is 2026-04-09 04:27:45."). Now LLMResultChunk from strategy output is silently consumed (text still accumulates in AgentResult.text via the strategy). Only AgentLogEvent (thought/tool_call/round) is forwarded to the pipeline. Known remaining issues: - workflow/message level total_tokens=0 (node level is correct at 33) because pipeline aggregation doesn't include agent-v2 node tokens - Turn 2 SSE delivery timing with Redis pubsub (celery executes OK) Made-with: Cursor --- api/core/workflow/nodes/agent_v2/event_adapter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/core/workflow/nodes/agent_v2/event_adapter.py b/api/core/workflow/nodes/agent_v2/event_adapter.py index e08bb43a87..6e11a04948 100644 --- a/api/core/workflow/nodes/agent_v2/event_adapter.py +++ b/api/core/workflow/nodes/agent_v2/event_adapter.py @@ -39,7 +39,7 @@ class AgentV2EventAdapter: if isinstance(item, AgentLog): yield self._convert_agent_log(item, node_id=node_id, node_execution_id=node_execution_id) elif isinstance(item, LLMResultChunk): - yield from self._convert_llm_chunk(item, node_id=node_id) + pass except StopIteration as e: result: AgentResult = e.value return result