The AEA framework consists of several core elements, some which are required to run an AEA and others which are optional.
The elements each AEA uses
AEAs communicate asynchronously via envelopes.
Envelope is the core object with which agents communicate. It is a vehicle for messages with five attribute parameters:
to: defines the destination address.
sender: defines the sender address.
protocol_id: defines the id of the protocol.
message: is a bytes field which holds the message in serialized form.
Optional[context]: an optional field to specify routing information in a URI.
Messages must adhere to a protocol.
Protocols define agent to agent interactions, which include:
messages, which define the representation;
serialization logic, which define how a message is encoded for transport; and, optionally
dialogues, which define rules over message sequences.
The framework provides one default protocol, called
default. This protocol provides a bare bones implementation for an AEA protocol which includes a
DefaultMessage class and associated
Protocol specific messages, wrapped in envelopes, are sent and received to other agents and services via connections.
Connection wraps an SDK or API and provides an interface to network, ledgers and other services. Where necessary, a connection is responsible for translating between the framework specific
Envelope with its contained
Message and the external service or third-party protocol (e.g.
The framework provides one default connection, called
stub. It implements an I/O reader and writer to send messages to the agent from a local file.
Additional connections can be added as packages. For more details on connections also read the connection guide here.
An AEA can run connections via a multiplexer.
Multiplexer is responsible for maintaining potentially multiple connections.
Skills are the core focus of the framework's extensibility as they implement business logic to deliver economic value for the AEA. They are self-contained capabilities that AEAs can dynamically take on board, in order to expand their effectiveness in different situations.
A skill encapsulates implementations of the three abstract base classes
Model, and is closely related with the abstract base class
Handler: each skill has none, one or more
Handlerobjects, each responsible for the registered messaging protocol. Handlers implement AEAs' reactive behaviour. If the AEA understands the protocol referenced in a received
Handlerreacts appropriately to the corresponding message. Each
Handleris responsible for only one protocol. A
Handleris also capable of dealing with internal messages (see next section).
Behaviour: none, one or more
Behavioursencapsulate actions which futher the AEAs goal and are initiated by internals of the AEA, rather than external events. Behaviours implement AEAs' pro-activeness. The framework provides a number of abstract base classes implementing different types of behaviours (e.g. cyclic/one-shot/finite-state-machine/etc.).
Model: none, one or more
Modelsthat inherit from the
Modelcan be accessed via the
Task: none, one or more
Tasksencapsulate background work internal to the AEA.
Taskdiffers from the other three in that it is not a part of skills, but
Tasks are declared in or from skills if a packaging approach for AEA creation is used.
A skill can read (parts of) the state of the the AEA (as summarised in the
AgentContext), and suggest actions to the AEA according to its specific logic. As such, more than one skill could exist per protocol, competing with each other in suggesting to the AEA the best course of actions to take. In technical terms this means skills are horizontally arranged.
For instance, an AEA who is trading goods, could subscribe to more than one skill, where each skill corresponds to a different trading strategy. The skills could then read the preference and ownership state of the AEA, and independently suggest profitable transactions.
The framework places no limits on the complexity of skills. They can implement simple (e.g.
if-this-then-that) or complex (e.g. a deep learning model or reinforcement learning agent).
The framework provides one default skill, called
error. Additional skills can be added as packages. For more details on skills also read the skill guide here.
The main agent loop performs a series of activities while the
Agent state is not stopped.
act(): this function calls the
act()function of all active registered Behaviours.
react(): this function grabs all Envelopes waiting in the
InBoxqueue and calls the
handle()function for the Handlers currently registered against the protocol of the
update(): this function dispatches the internal messages from the decision maker (described below) to the handler in the relevant skill.
We recommend you continue with the next step in the 'Getting Started' series:
Most AEA development focuses on developing the skills and protocols necessary for an AEA to deliver against its economic objectives.
Understanding protocols is core to developing your own agent. You can learn more about the protocols agents use to communicate with each other and how they are created in the following section:
Most of an AEA developer's time is spent on skill development. Skills are the core business logic commponents of an AEA. Check out the following guide to learn more:
In most cases, one of the available connection packages can be used. Occassionally, you might develop your own connection: