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.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
fix: wrong token usage in iteration node for streaming result (#5336)
rerorero9b7fdadce499
diff --git a/api/core/app/entities/task_entities.py b/api/core/app/entities/task_entities.pyindex cb023ae9fe6..af93399a24a 100644--- a/api/core/app/entities/task_entities.py+++ b/api/core/app/entities/task_entities.py@@ -367,7 +367,7 @@ class IterationNodeNextStreamResponse(StreamResponse):class IterationNodeCompletedStreamResponse(StreamResponse):"""- NodeStartStreamResponse entity+ NodeCompletedStreamResponse entity"""class Data(BaseModel):"""@@ -385,6 +385,7 @@ class IterationNodeCompletedStreamResponse(StreamResponse):error: Optional[str] = Noneelapsed_time: floattotal_tokens: int+ execution_metadata: Optional[dict] = Nonefinished_at: intsteps: int@@ -545,4 +546,4 @@ class WorkflowIterationState(BaseModel):total_tokens: int = 0node_data: BaseNodeData- current_iterations: dict[str, Data] = None\ No newline at end of file+ current_iterations: dict[str, Data] = Nonediff --git a/api/core/app/task_pipeline/workflow_iteration_cycle_manage.py b/api/core/app/task_pipeline/workflow_iteration_cycle_manage.pyindex 19bb7788c9e..69af81d0269 100644--- a/api/core/app/task_pipeline/workflow_iteration_cycle_manage.py+++ b/api/core/app/task_pipeline/workflow_iteration_cycle_manage.py@@ -95,6 +95,9 @@ class WorkflowIterationCycleManage(WorkflowCycleStateManager):error=None,elapsed_time=time.perf_counter() - current_iteration.started_at,total_tokens=current_iteration.total_tokens,+ execution_metadata={+ 'total_tokens': current_iteration.total_tokens,+ },finished_at=int(time.time()),steps=current_iteration.current_index)@@ -276,7 +279,10 @@ class WorkflowIterationCycleManage(WorkflowCycleStateManager):error=error,elapsed_time=time.perf_counter() - current_iteration.started_at,total_tokens=current_iteration.total_tokens,+ execution_metadata={+ 'total_tokens': current_iteration.total_tokens,+ },finished_at=int(time.time()),steps=current_iteration.current_index)- )\ No newline at end of file+ )