From 63206a7967c2b55e2e5e55518d42dcc4642fc6b9 Mon Sep 17 00:00:00 2001 From: Yeuoly Date: Fri, 13 Dec 2024 00:05:57 +0800 Subject: [PATCH] fix: incorrect use of node execution id --- .../task_pipeline/workflow_cycle_manage.py | 8 +++---- api/core/workflow/nodes/tool/tool_node.py | 21 +++++++++---------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/api/core/app/task_pipeline/workflow_cycle_manage.py b/api/core/app/task_pipeline/workflow_cycle_manage.py index 66bfe10d3e..3e3a5166aa 100644 --- a/api/core/app/task_pipeline/workflow_cycle_manage.py +++ b/api/core/app/task_pipeline/workflow_cycle_manage.py @@ -287,12 +287,12 @@ class WorkflowCycleManage: process_data = WorkflowEntry.handle_special_values(event.process_data) outputs = WorkflowEntry.handle_special_values(event.outputs) execution_metadata_dict = event.execution_metadata - if self._wip_workflow_agent_logs.get(event.node_execution_id): + if self._wip_workflow_agent_logs.get(workflow_node_execution.id): if not execution_metadata_dict: execution_metadata_dict = {} execution_metadata_dict[NodeRunMetadataKey.AGENT_LOG] = self._wip_workflow_agent_logs.get( - event.node_execution_id, [] + workflow_node_execution.id, [] ) execution_metadata = json.dumps(jsonable_encoder(execution_metadata_dict)) if execution_metadata_dict else None @@ -343,12 +343,12 @@ class WorkflowCycleManage: finished_at = datetime.now(UTC).replace(tzinfo=None) elapsed_time = (finished_at - event.start_at).total_seconds() execution_metadata_dict = event.execution_metadata - if self._wip_workflow_agent_logs.get(event.node_execution_id): + if self._wip_workflow_agent_logs.get(workflow_node_execution.id): if not execution_metadata_dict: execution_metadata_dict = {} execution_metadata_dict[NodeRunMetadataKey.AGENT_LOG] = self._wip_workflow_agent_logs.get( - event.node_execution_id, [] + workflow_node_execution.id, [] ) execution_metadata = json.dumps(jsonable_encoder(execution_metadata_dict)) if execution_metadata_dict else None diff --git a/api/core/workflow/nodes/tool/tool_node.py b/api/core/workflow/nodes/tool/tool_node.py index 05ffd90fc5..5c256cbac8 100644 --- a/api/core/workflow/nodes/tool/tool_node.py +++ b/api/core/workflow/nodes/tool/tool_node.py @@ -56,17 +56,6 @@ class ToolNode(BaseNode[ToolNodeData]): "plugin_unique_identifier": node_data.plugin_unique_identifier, } - yield AgentLogEvent( - id=self.node_id, - node_execution_id=self.id, - parent_id=None, - error=None, - status="running", - data={ - "tool_info": tool_info, - }, - ) - # get tool runtime try: tool_runtime = ToolManager.get_workflow_tool_runtime( @@ -289,6 +278,16 @@ class ToolNode(BaseNode[ToolNodeData]): elif message.type == ToolInvokeMessage.MessageType.FILE: assert message.meta is not None files.append(message.meta["file"]) + elif message.type == ToolInvokeMessage.MessageType.LOG: + assert isinstance(message.message, ToolInvokeMessage.LogMessage) + yield AgentLogEvent( + id=message.message.id, + node_execution_id=self.id, + parent_id=message.message.parent_id, + error=message.message.error, + status=message.message.status.value, + data=message.message.data, + ) yield RunCompletedEvent( run_result=NodeRunResult(