aea.agent

This module contains the implementation of a generic agent.

Agent Objects

class Agent(ABC)

This class provides an abstract base class for a generic agent.

__init__

 | __init__(identity: Identity, connections: List[Connection], loop: Optional[AbstractEventLoop] = None, timeout: float = 1.0, loop_mode: Optional[str] = None, runtime_mode: Optional[str] = None) -> None

Instantiate the agent.

Arguments:

  • identity: the identity of the agent.
  • connections: the list of connections of the agent.
  • loop: the event loop to run the connections.
  • timeout: the time in (fractions of) seconds to time out an agent between act and react
  • loop_mode: loop_mode to choose agent run loop.
  • runtime_mode: runtime mode to up agent.

Returns:

None

is_running

 | @property
 | is_running()

Get running state of the runtime and agent.

is_stopped

 | @property
 | is_stopped()

Get running state of the runtime and agent.

identity

 | @property
 | identity() -> Identity

Get the identity.

multiplexer

 | @property
 | multiplexer() -> Multiplexer

Get the multiplexer.

inbox

 | @property
 | inbox() -> InBox

Get the inbox.

The inbox contains Envelopes from the Multiplexer. The agent can pick these messages for processing.

outbox

 | @property
 | outbox() -> OutBox

Get the outbox.

The outbox contains Envelopes for the Multiplexer. Envelopes placed in the Outbox are processed by the Multiplexer.

name

 | @property
 | name() -> str

Get the agent name.

tick

 | @property
 | tick() -> int

Get the tick or agent loop count.

Each agent loop (one call to each one of act(), react(), update()) increments the tick.

timeout

 | @property
 | timeout() -> float

Get the time in (fractions of) seconds to time out an agent between act and react.

loop_mode

 | @property
 | loop_mode() -> str

Get the agent loop mode.

main_loop

 | @property
 | main_loop() -> BaseAgentLoop

Get the main agent loop.

runtime

 | @property
 | runtime() -> BaseRuntime

Get the runtime.

setup_multiplexer

 | setup_multiplexer() -> None

Set up the multiplexer.

start

 | start() -> None

Start the agent.

Performs the following:

  • calls connect() on the multiplexer (unless in debug mode), and
  • calls setup(), and
  • calls start() on the liveness, and
  • enters the agent main loop.

While the liveness of the agent is not stopped it continues to loop over:

  • increment the tick,
  • call to act(),
  • sleep for specified timeout,
  • call to react(),
  • call to update().

Returns:

None

start_setup

 | start_setup() -> None

Set up Agent on start.

  • connect Multiplexer
  • call agent.setup
  • set liveness to started

Returns:

None

stop

 | stop() -> None

Stop the agent.

Performs the following:

  • calls stop() on the liveness, and
  • calls teardown(), and
  • calls disconnect() on the multiplexer.

Returns:

None

setup

 | @abstractmethod
 | setup() -> None

Set up the agent.

Returns:

None

act

 | @abstractmethod
 | act() -> None

Perform actions.

Returns:

None

react

 | @abstractmethod
 | react() -> None

React to events.

Returns:

None

update

 | @abstractmethod
 | update() -> None

Update the internals of the agent which are not exposed to the skills.

:return None

teardown

 | @abstractmethod
 | teardown() -> None

Tear down the agent.

Returns:

None

state

 | @property
 | state() -> RuntimeStates

Get state of the agent's runtime.

Returns:

RuntimeStates