Merge remote-tracking branch 'origin/dev' into feat/norms-and-goals-program

This commit is contained in:
Twirre Meulenbelt
2025-11-25 11:29:27 +01:00
10 changed files with 26 additions and 59 deletions

View File

@@ -1,6 +1,7 @@
import asyncio
import logging
from abc import ABC, abstractmethod
from asyncio import Task
from collections.abc import Coroutine
import zmq
@@ -75,8 +76,8 @@ class BaseAgent(ABC):
await self.setup()
# Start processing inbox and ZMQ messages
await self.add_behavior(self._process_inbox())
await self.add_behavior(self._receive_internal_zmq_loop())
self.add_behavior(self._process_inbox())
self.add_behavior(self._receive_internal_zmq_loop())
async def stop(self):
"""Stops the agent."""
@@ -128,7 +129,7 @@ class BaseAgent(ABC):
"""Override this to handle incoming messages."""
raise NotImplementedError
async def add_behavior(self, coro: Coroutine):
def add_behavior(self, coro: Coroutine) -> Task:
"""
Helper to add a behavior to the agent. To add asynchronous behavior to an agent, define
an `async` function and add it to the task list by calling :func:`add_behavior`
@@ -138,3 +139,4 @@ class BaseAgent(ABC):
task = asyncio.create_task(coro)
self._tasks.add(task)
task.add_done_callback(self._tasks.discard)
return task