Skip to content

aea.context.base

This module contains the agent context class.

AgentContext Objects

class AgentContext()

Provide read access to relevant objects of the agent for the skills.

__init__

 | __init__(identity: Identity, connection_status: MultiplexerStatus, outbox: OutBox, decision_maker_message_queue: Queue, decision_maker_handler_context: SimpleNamespace, task_manager: TaskManager, default_ledger_id: str, currency_denominations: Dict[str, str], default_connection: Optional[PublicId], default_routing: Dict[PublicId, PublicId], search_service_address: Address, decision_maker_address: Address, data_dir: str, storage_callable: Callable[[], Optional[Storage]] = lambda: None, send_to_skill: Optional[Callable] = None, **kwargs: Any) -> None

Initialize an agent context.

Arguments:

  • identity: the identity object
  • connection_status: the connection status of the multiplexer
  • outbox: the outbox
  • decision_maker_message_queue: the (in) queue of the decision maker
  • decision_maker_handler_context: the decision maker's name space
  • task_manager: the task manager
  • default_ledger_id: the default ledger id
  • currency_denominations: mapping from ledger ids to currency denominations
  • default_connection: the default connection
  • default_routing: the default routing
  • search_service_address: the address of the search service
  • decision_maker_address: the address of the decision maker
  • data_dir: directory where to put local files.
  • storage_callable: function that returns optional storage attached to agent.
  • send_to_skill: callable for sending envelopes to skills.
  • kwargs: keyword arguments to be attached in the agent context namespace.

send_to_skill

 | send_to_skill(message_or_envelope: Union[Message, Envelope], context: Optional[EnvelopeContext] = None) -> None

Send message or envelope to another skill.

If message passed it will be wrapped into envelope with optional envelope context.

Arguments:

  • message_or_envelope: envelope to send to another skill.
  • context: the optional envelope context

storage

 | @property
 | storage() -> Optional[Storage]

Return storage instance if enabled in AEA.

data_dir

 | @property
 | data_dir() -> str

Return assets directory.

shared_state

 | @property
 | shared_state() -> Dict[str, Any]

Get the shared state dictionary.

The shared state is the only object which skills can use to exchange state directly. It is accessible (read and write) from all skills.

Returns:

dictionary of the shared state.

identity

 | @property
 | identity() -> Identity

Get the identity.

agent_name

 | @property
 | agent_name() -> str

Get agent name.

addresses

 | @property
 | addresses() -> Dict[str, Address]

Get addresses.

address

 | @property
 | address() -> Address

Get the default address.

connection_status

 | @property
 | connection_status() -> MultiplexerStatus

Get connection status of the multiplexer.

outbox

 | @property
 | outbox() -> OutBox

Get outbox.

decision_maker_message_queue

 | @property
 | decision_maker_message_queue() -> Queue

Get decision maker queue.

decision_maker_handler_context

 | @property
 | decision_maker_handler_context() -> SimpleNamespace

Get the decision maker handler context.

task_manager

 | @property
 | task_manager() -> TaskManager

Get the task manager.

search_service_address

 | @property
 | search_service_address() -> Address

Get the address of the search service.

decision_maker_address

 | @property
 | decision_maker_address() -> Address

Get the address of the decision maker.

default_ledger_id

 | @property
 | default_ledger_id() -> str

Get the default ledger id.

currency_denominations

 | @property
 | currency_denominations() -> Dict[str, str]

Get a dictionary mapping ledger ids to currency denominations.

default_connection

 | @property
 | default_connection() -> Optional[PublicId]

Get the default connection.

default_routing

 | @property
 | default_routing() -> Dict[PublicId, PublicId]

Get the default routing.

namespace

 | @property
 | namespace() -> SimpleNamespace

Get the agent context namespace.