aea.agent
This module contains the implementation of a generic agent.
Agent Objects
This class provides an abstract base class for a generic agent.
__
init__
| __init__(identity: Identity, connections: List[Connection], loop: Optional[AbstractEventLoop] = None, period: float = 1.0, loop_mode: Optional[str] = None, runtime_mode: Optional[str] = None, storage_uri: Optional[str] = None, logger: Logger = _default_logger, task_manager_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.period
: period to call agent's actloop_mode
: loop_mode to choose agent run loop.runtime_mode
: runtime mode to up agent.storage_uri
: optional uri to set generic storagetask_manager_mode
: task manager mode.logger
: the logger.task_manager_mode
: mode of the task manager.
storage_
uri
Return storage uri.
is_
running
Get running state of the runtime and agent.
is_
stopped
Get running state of the runtime and agent.
identity
Get the identity.
inbox
Get the inbox.
The inbox contains Envelopes from the Multiplexer. The agent can pick these messages for processing.
Returns:
InBox instance
outbox
Get the outbox.
The outbox contains Envelopes for the Multiplexer. Envelopes placed in the Outbox are processed by the Multiplexer.
Returns:
OutBox instance
name
Get the agent name.
tick
Get the tick or agent loop count.
Each agent loop (one call to each one of act(), react(), update()) increments the tick.
Returns:
tick count
state
Get state of the agent's runtime.
Returns:
RuntimeStates
period
Get a period to call act.
runtime
Get the runtime.
setup
Set up the agent.
start
Start the agent.
Performs the following:
- calls start() on runtime.
- waits for runtime to complete running (blocking)
handle_
envelope
Handle an envelope.
Arguments:
envelope
: the envelope to handle.
act
Perform actions on period.
stop
Stop the agent.
Performs the following:
- calls stop() on runtime
- waits for runtime to stop (blocking)
teardown
Tear down the agent.
get_
periodic_
tasks
Get all periodic tasks for agent.
Returns:
dict of callable with period specified
get_
message_
handlers
Get handlers with message getters.
Returns:
List of tuples of callables: handler and coroutine to get a message
exception_
handler
Handle exception raised during agent main loop execution.
Arguments:
exception
: exception raisedfunction
: a callable exception raised in.
Returns:
bool, propagate exception if True otherwise skip it.