AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
fix(backend/executor): Avoid stopping agent node evaluation when stopping graph (#10542)
Zamil Majdy1e6bd8d2a63b
diff --git a/autogpt_platform/backend/backend/executor/manager.py b/autogpt_platform/backend/backend/executor/manager.pyindex c4ab811e85..4713b7d066 100644--- a/autogpt_platform/backend/backend/executor/manager.py+++ b/autogpt_platform/backend/backend/executor/manager.py@@ -443,18 +443,16 @@ class Executor:if node_error and not isinstance(node_error, str):node_stats["error"] = str(node_error) or node_stats.__class__.__name__- await asyncio.gather(- async_update_node_execution_status(- db_client=db_client,- exec_id=node_exec.node_exec_id,- status=status,- stats=node_stats,- ),- async_update_graph_execution_state(- db_client=db_client,- graph_exec_id=node_exec.graph_exec_id,- stats=graph_stats,- ),+ await async_update_node_execution_status(+ db_client=db_client,+ exec_id=node_exec.node_exec_id,+ status=status,+ stats=node_stats,+ )+ await async_update_graph_execution_state(+ db_client=db_client,+ graph_exec_id=node_exec.graph_exec_id,+ stats=graph_stats,)return execution_stats@@ -941,22 +939,6 @@ class Executor:This method is decorated with @error_logged(swallow=True) to ensure cleanupnever fails in the finally block."""- # Cancel and wait for all node evaluations to complete- for node_id, inflight_eval in running_node_evaluation.items():- if inflight_eval.done():- continue- log_metadata.info(f"Stopping node evaluation {node_id}")- inflight_eval.cancel()-- for node_id, inflight_eval in running_node_evaluation.items():- try:- inflight_eval.result(timeout=3600.0)- except TimeoutError:- log_metadata.exception(- f"Node evaluation #{node_id} did not stop in time, "- "it may be stuck or taking too long."- )-# Cancel and wait for all node executions to completefor node_id, inflight_exec in running_node_execution.items():if inflight_exec.is_done():@@ -973,6 +955,16 @@ class Executor:"it may be stuck or taking too long.")+ # Wait the remaining inflight evaluations to finish+ for node_id, inflight_eval in running_node_evaluation.items():+ try:+ inflight_eval.result(timeout=3600.0)+ except TimeoutError:+ log_metadata.exception(+ f"Node evaluation #{node_id} did not stop in time, "+ "it may be stuck or taking too long."+ )+while queued_execution := execution_queue.get_or_none():update_node_execution_status(db_client=db_client,