Skip to content


This module contains the implementation of an agent loop using asyncio.

AgentLoopException Objects

class AgentLoopException(AEAException)

Exception for agent loop runtime errors.

AgentLoopStates Objects

class AgentLoopStates(Enum)

Internal agent loop states.

BaseAgentLoop Objects

class BaseAgentLoop(Runnable,  WithLogger,  ABC)

Base abstract agent loop class.


 | __init__(agent: AbstractAgent, loop: Optional[AbstractEventLoop] = None, threaded=False) -> None

Init loop.

:params agent: Agent or AEA to run. :params loop: optional asyncio event loop. if not specified a new loop will be created.


 | @property
 | agent() -> AbstractAgent

Get agent.


 | set_loop(loop: AbstractEventLoop) -> None

Set event loop and all event loopp related objects.


 | async run() -> None

Run agent loop.


 | @property
 | state() -> AgentLoopStates

Get current main loop state.


 | @property
 | is_running() -> bool

Get running state of the loop.

AsyncAgentLoop Objects

class AsyncAgentLoop(BaseAgentLoop)

Asyncio based agent loop suitable only for AEA.


 | __init__(agent: AbstractAgent, loop: AbstractEventLoop = None, threaded=False)

Init agent loop.


  • agent: AEA instance
  • loop: asyncio loop to use. optional