Skip to content

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.

Merge branch 'master' into dev

Reinier van der Leer6e0af09c3dd6
diff --cc autogpt_platform/backend/backend/blocks/agent.py
index cd63b6d6ac,f278d039a2..c2b600dd4c
--- a/autogpt_platform/backend/backend/blocks/agent.py
+++ b/autogpt_platform/backend/backend/blocks/agent.py
@@@ -90,9 -88,15 +90,11 @@@ class AgentExecutorBlock(Block)
logger.info(f"Starting execution of {log_id}")
for event in event_bus.listen(
- graph_id=graph_exec.graph_id, graph_exec_id=graph_exec.graph_exec_id
+ user_id=graph_exec.user_id,
+ graph_id=graph_exec.graph_id,
+ graph_exec_id=graph_exec.graph_exec_id,
):
- logger.info(
- f"Execution {log_id} produced input {event.input_data} output {event.output_data}"
- )
-
- if not event.node_id:
+ if event.event_type == ExecutionEventType.GRAPH_EXEC_UPDATE:
if event.status in [
ExecutionStatus.COMPLETED,
ExecutionStatus.TERMINATED,
diff --cc autogpt_platform/backend/backend/data/execution.py
index a76d130f96,e4db2c94f7..a3780d8df4
--- a/autogpt_platform/backend/backend/data/execution.py
+++ b/autogpt_platform/backend/backend/data/execution.py
@@@ -800,24 -578,13 +800,24 @@@ class RedisExecutionEventBus(RedisEvent
def event_bus_name(self) -> str:
return config.execution_event_bus_name
- def publish(self, res: ExecutionResult):
- self.publish_event(res, f"{res.user_id}/{res.graph_id}/{res.graph_exec_id}")
+ def publish(self, res: GraphExecutionMeta | NodeExecutionResult):
+ if isinstance(res, GraphExecutionMeta):
+ self.publish_graph_exec_update(res)
+ else:
+ self.publish_node_exec_update(res)
+
+ def publish_node_exec_update(self, res: NodeExecutionResult):
+ event = NodeExecutionEvent.model_validate(res.model_dump())
- self.publish_event(event, f"{res.graph_id}/{res.graph_exec_id}")
++ self.publish_event(event, f"{res.user_id}/{res.graph_id}/{res.graph_exec_id}")
+
+ def publish_graph_exec_update(self, res: GraphExecutionMeta):
+ event = GraphExecutionEvent.model_validate(res.model_dump())
- self.publish_event(event, f"{res.graph_id}/{res.id}")
++ self.publish_event(event, f"{res.user_id}/{res.graph_id}/{res.id}")
def listen(
- self, graph_id: str = "*", graph_exec_id: str = "*"
+ self, user_id: str, graph_id: str = "*", graph_exec_id: str = "*"
- ) -> Generator[ExecutionResult, None, None]:
+ ) -> Generator[ExecutionEvent, None, None]:
- for event in self.listen_events(f"{graph_id}/{graph_exec_id}"):
+ for event in self.listen_events(f"{user_id}/{graph_id}/{graph_exec_id}"):
yield event
@@@ -828,22 -595,13 +828,24 @@@ class AsyncRedisExecutionEventBus(Async
def event_bus_name(self) -> str:
return config.execution_event_bus_name
- async def publish(self, res: ExecutionResult):
+ async def publish(self, res: GraphExecutionMeta | NodeExecutionResult):
+ if isinstance(res, GraphExecutionMeta):
+ await self.publish_graph_exec_update(res)
+ else:
+ await self.publish_node_exec_update(res)
+
+ async def publish_node_exec_update(self, res: NodeExecutionResult):
+ event = NodeExecutionEvent.model_validate(res.model_dump())
- await self.publish_event(event, f"{res.graph_id}/{res.graph_exec_id}")
+ await self.publish_event(
- res, f"{res.user_id}/{res.graph_id}/{res.graph_exec_id}"
++ event, f"{res.user_id}/{res.graph_id}/{res.graph_exec_id}"
+ )
+ async def publish_graph_exec_update(self, res: GraphExecutionMeta):
+ event = GraphExecutionEvent.model_validate(res.model_dump())
- await self.publish_event(event, f"{res.graph_id}/{res.id}")
++ await self.publish_event(event, f"{res.user_id}/{res.graph_id}/{res.id}")
+
async def listen(
- self, graph_id: str = "*", graph_exec_id: str = "*"
+ self, user_id: str, graph_id: str = "*", graph_exec_id: str = "*"
- ) -> AsyncGenerator[ExecutionResult, None]:
+ ) -> AsyncGenerator[ExecutionEvent, None]:
- async for event in self.listen_events(f"{graph_id}/{graph_exec_id}"):
+ async for event in self.listen_events(f"{user_id}/{graph_id}/{graph_exec_id}"):
yield event
diff --cc autogpt_platform/backend/backend/server/ws_api.py
index e1ff471ed3,2bb3af7a2c..e1314003b9
--- a/autogpt_platform/backend/backend/server/ws_api.py
+++ b/autogpt_platform/backend/backend/server/ws_api.py
@@@ -51,8 -51,8 +51,8 @@@ async def event_broadcaster(manager: Co
try:
redis.connect()
event_queue = AsyncRedisExecutionEventBus()
- async for event in event_queue.listen():
+ async for event in event_queue.listen("*"):
- await manager.send_execution_result(event)
+ await manager.send_execution_update(event)
except Exception as e:
logger.exception(f"Event broadcaster error: {e}")
raise