aea.agent

This module contains the implementation of a generic agent.

AgentState

class AgentState(Enum)

Enumeration for an agent state.

In particular, it can be one of the following states:

  • AgentState.INITIATED: when the Agent object has been created.
  • AgentState.CONNECTED: when the agent is connected.
  • AgentState.RUNNING: when the agent is running.

Liveness

class Liveness()

Determines the liveness of the agent.

__init__

 | __init__()

Instantiate the liveness.

is_stopped

 | @property
 | is_stopped() -> bool

Check whether the liveness is stopped.

start

 | start() -> None

Start the liveness.

stop

 | stop() -> None

Stop the liveness.

Agent

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, is_debug: bool = False, loop_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
  • is_debug: if True, run the agent in debug mode (does not connect the multiplexer).
  • loop_mode: loop_mode to choose agent run loop.

Returns:

None

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.

liveness

 | @property
 | liveness() -> Liveness

Get the liveness.

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.

agent_state

 | @property
 | agent_state() -> AgentState

Get the state of the agent.

Raises:

  • ValueError: if the state does not satisfy any of the foreseen conditions.

Returns:

None

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().

Arguments:

  • loop_mode: loop mode to choose agent run loop. if not specified default one will be used

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