Skip to content

Commit c6703dd

Browse files
authored
fix(backend): Skip updating status of already terminated graph (#9696)
When we are cancelling a running graph execution, it's possible that the graph is already terminated. We need to allow this process to proceed and update the rest of its node execution to terminate. ### Changes 🏗️ Instead of erroring out the graph execution status update, we proceed on updating the node execution status. ### Checklist 📋 #### For code changes: - [x] I have clearly listed my changes in the PR description - [x] I have made a test plan - [x] I have tested my changes according to the test plan: - [x] Stop an already terminated graph
1 parent 6e0af09 commit c6703dd

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

autogpt_platform/backend/backend/data/execution.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ async def update_graph_execution_stats(
406406
graph_exec_id: str,
407407
status: ExecutionStatus,
408408
stats: GraphExecutionStats | None = None,
409-
) -> GraphExecutionMeta:
409+
) -> GraphExecutionMeta | None:
410410
data = stats.model_dump() if stats else {}
411411
if isinstance(data.get("error"), Exception):
412412
data["error"] = str(data["error"])
@@ -423,10 +423,8 @@ async def update_graph_execution_stats(
423423
"stats": Json(data),
424424
},
425425
)
426-
if not res:
427-
raise ValueError(f"Graph execution #{graph_exec_id} not found")
428426

429-
return GraphExecutionMeta.from_db(res)
427+
return GraphExecutionMeta.from_db(res) if res else None
430428

431429

432430
async def update_node_execution_stats(node_exec_id: str, stats: NodeExecutionStats):

autogpt_platform/backend/backend/executor/manager.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -633,16 +633,14 @@ def on_graph_execution(
633633
)
634634
exec_stats.walltime = timing_info.wall_time
635635
exec_stats.cputime = timing_info.cpu_time
636-
exec_stats.error = error
636+
exec_stats.error = str(error)
637637

638-
if isinstance(exec_stats.error, Exception):
639-
exec_stats.error = str(exec_stats.error)
640-
result = cls.db_client.update_graph_execution_stats(
638+
if result := cls.db_client.update_graph_execution_stats(
641639
graph_exec_id=graph_exec.graph_exec_id,
642640
status=status,
643641
stats=exec_stats,
644-
)
645-
cls.db_client.send_execution_update(result)
642+
):
643+
cls.db_client.send_execution_update(result)
646644

647645
cls._handle_agent_run_notif(graph_exec, exec_stats)
648646

0 commit comments

Comments
 (0)