AgentManager

AgentManager is a utility to assist in spawning agents and keeping genome files in a centralized location.

This class also persists agent configuration information between instantiations, so that previously used genomes can be referenced from the genome store. Will automatically provide an AgentClient object when agent is spawned using manager.

Note

Requires access to the Docker Daemon running on the user’s computer, and access to Intelligent Artifact’s GAIuS Docker images.

Quickstart

from ia.gaius.manager import AgentManager

am = AgentManager()
am.kill_all_agents()
agent = am.start_agent(genome_file='simple.genome', agent_id='pvt', connect_jia=True, api_key='SECRET1234')
agent_client = agent.get_agent_client()
class ia.gaius.manager.AgentManager(genome_dir: str | None = None, agents_dir: str | None = None)

Bases: object

__init__(genome_dir: str | None = None, agents_dir: str | None = None)

Initialize AgentManager object (setup dirs, etc.)

This object can be used to spawn Agents using the start_agent() method.

agent_context(genome_file=None, genome_name=None, user_id: str = 'jia', agent_id: str = '1', agent_name=None, connect_jia=True, api_key='ABCD-1234')
delete_agent(agent_name)

Stop/Delete agent & remove config file from agents_dir

Parameters:

agent_name (str) – name of agent to stop

Returns:

string depicting deletion status

Return type:

str

delete_genome(genome_name)

Delete genome from centralized genome_dir

Parameters:

genome_name (str) – genome name to delete

get_all_agent_status()

Get the status of all agents in current_agents dict

Returns:

{ agent_name : alive? }

Return type:

dict

get_genome(genome_name)

Get genome by name, return as dict

Parameters:

genome_name (str) – filename for genome in genome_dir

Raises:

Exception – When genome not found

Returns:

contents of genome file

Return type:

dict

kill_all_agents()

Kill all agents known to AgentManager

list_genomes()

List the genomes present in the localized genome store

Returns:

list of genome files

Return type:

list

remediate_dead_agents()

Remove all agents that cannot be pinged.

start_agent(genome_file=None, genome_name=None, user_id: str = 'jia', agent_id: str = '1', agent_name=None, connect_jia=True, api_key='ABCD-1234')

Spawn an agent and save its information in the localized agents dir

Note

If you wish to use a genome that has not been used by the AgentManager before, pass it in the genome_file field. This will retrieve the genome from the specified path, and save it in the localized genome dir for future use.

Parameters:
  • genome_file (str, optional) – Path to outside genome file. Defaults to None.

  • genome_name (str, optional) – Name of genome in the localized genome dir. Defaults to None.

  • user_id (str, optional) – user id for naming docker containers. Defaults to ‘jia’.

  • agent_id (str, optional) – agent id for naming docker containers. Defaults to ‘1’.

  • agent_name (_type_, optional) – descriptive name “alias” for agent. Defaults to None.

  • connect_jia (bool, optional) – Whether to attempt to connect agent to Jia docker container. Defaults to True.

  • api_key (str, optional) – Control the api key used to access agent. Defaults to ‘ABCD-1234’.

Raises:

Exception – If there is a conflicting agent with user_id and agent_id already present/alive

Returns:

AgentInfo object corresponding to started agent. can be used to retrieve AgentClient object using AgentInfo.get_agent_client()

Return type:

AgentInfo

start_hoster()
stop_hoster()
update_current_agents()

Update the current_agents_dict