fix: incorrect use of node execution id

This commit is contained in:
Yeuoly 2024-12-13 00:05:57 +08:00
parent 9a6f120e5c
commit 63206a7967
No known key found for this signature in database
GPG Key ID: A66E7E320FB19F61
2 changed files with 14 additions and 15 deletions

View File

@ -287,12 +287,12 @@ class WorkflowCycleManage:
process_data = WorkflowEntry.handle_special_values(event.process_data) process_data = WorkflowEntry.handle_special_values(event.process_data)
outputs = WorkflowEntry.handle_special_values(event.outputs) outputs = WorkflowEntry.handle_special_values(event.outputs)
execution_metadata_dict = event.execution_metadata 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: if not execution_metadata_dict:
execution_metadata_dict = {} execution_metadata_dict = {}
execution_metadata_dict[NodeRunMetadataKey.AGENT_LOG] = self._wip_workflow_agent_logs.get( 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 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) finished_at = datetime.now(UTC).replace(tzinfo=None)
elapsed_time = (finished_at - event.start_at).total_seconds() elapsed_time = (finished_at - event.start_at).total_seconds()
execution_metadata_dict = event.execution_metadata 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: if not execution_metadata_dict:
execution_metadata_dict = {} execution_metadata_dict = {}
execution_metadata_dict[NodeRunMetadataKey.AGENT_LOG] = self._wip_workflow_agent_logs.get( 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 execution_metadata = json.dumps(jsonable_encoder(execution_metadata_dict)) if execution_metadata_dict else None

View File

@ -56,17 +56,6 @@ class ToolNode(BaseNode[ToolNodeData]):
"plugin_unique_identifier": node_data.plugin_unique_identifier, "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 # get tool runtime
try: try:
tool_runtime = ToolManager.get_workflow_tool_runtime( tool_runtime = ToolManager.get_workflow_tool_runtime(
@ -289,6 +278,16 @@ class ToolNode(BaseNode[ToolNodeData]):
elif message.type == ToolInvokeMessage.MessageType.FILE: elif message.type == ToolInvokeMessage.MessageType.FILE:
assert message.meta is not None assert message.meta is not None
files.append(message.meta["file"]) 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( yield RunCompletedEvent(
run_result=NodeRunResult( run_result=NodeRunResult(