Repository: Significant-Gravitas/Auto-GPT
File: autogpt_platform/backend/backend/executor/manager.py (Python)

Code before:
            user_id=user_id,
            preset_id=preset_id,
        )
        self.db_client.send_execution_update(graph_exec)

        graph_exec_entry = GraphExecutionEntry(
            user_id=user_id,
            graph_id=graph_id,
            graph_version=graph_version or 0,
            graph_exec_id=graph_exec.id,
            start_node_execs=[
                NodeExecutionEntry(
                    user_id=user_id,
                    graph_exec_id=node_exec.graph_exec_id,
                    graph_id=node_exec.graph_id,
                    node_exec_id=node_exec.node_exec_id,
                    node_id=node_exec.node_id,
                    block_id=node_exec.block_id,
                    data=node_exec.input_data,
                )
                for node_exec in graph_exec.node_executions
            ],
        )
        self.rabbitmq_service.publish_message(
            routing_key=GRAPH_EXECUTION_ROUTING_KEY,
            message=json.dumps(graph_exec_entry),
            exchange=GRAPH_EXECUTION_EXCHANGE,
        )
        return graph_exec_entry

    @expose
    def cancel_execution(self, graph_exec_id: str) -> None:
        """
        Mechanism:
        1. Set the cancel event
        2. Graph executor's cancel handler thread detects the event, terminates workers,
           reinitializes worker pool, and returns.
        3. Update execution statuses in DB and set `error` outputs to `"TERMINATED"`.
        """
        self.rabbitmq_service.publish_message(
            routing_key="",
            message=CancelExecutionEvent(graph_exec_id=graph_exec_id).model_dump_json(),
            exchange=GRAPH_EXECUTION_CANCEL_EXCHANGE,
        )

        # Update the status of the graph & node executions
        self.db_client.update_graph_execution_stats(
            graph_exec_id,
            ExecutionStatus.TERMINATED,
        )
        node_execs = self.db_client.get_node_execution_results(

Review comment (suggestion):
```suggestion
            message=graph_exec_entry.model_dump_json(),
```

Code after:
            )

        graph_exec = self.db_client.create_graph_execution(
            graph_id=graph_id,
            graph_version=graph.version,
            nodes_input=nodes_input,
            user_id=user_id,
            preset_id=preset_id,
        )
        self.db_client.send_execution_update(graph_exec)

        graph_exec_entry = GraphExecutionEntry(
            user_id=user_id,
            graph_id=graph_id,
            graph_version=graph_version or 0,
            graph_exec_id=graph_exec.id,
            start_node_execs=[
                NodeExecutionEntry(
                    user_id=user_id,
                    graph_exec_id=node_exec.graph_exec_id,
                    graph_id=node_exec.graph_id,
                    node_exec_id=node_exec.node_exec_id,
                    node_id=node_exec.node_id,
                    block_id=node_exec.block_id,
                    data=node_exec.input_data,
                )
                for node_exec in graph_exec.node_executions
            ],
        )
        self.rabbitmq_service.publish_message(
            routing_key=GRAPH_EXECUTION_ROUTING_KEY,
            message=graph_exec_entry.model_dump_json(),
            exchange=GRAPH_EXECUTION_EXCHANGE,
        )
        return graph_exec_entry

    @expose
    def cancel_execution(self, graph_exec_id: str) -> None:
        """
        Mechanism:
        1. Set the cancel event
        2. Graph executor's cancel handler thread detects the event, terminates workers,
           reinitializes worker pool, and returns.
        3. Update execution statuses in DB and set `error` outputs to `"TERMINATED"`.
        """
        self.rabbitmq_service.publish_message(
            routing_key="",
            message=CancelExecutionEvent(graph_exec_id=graph_exec_id).model_dump_json(),
            exchange=GRAPH_EXECUTION_CANCEL_EXCHANGE,
        )