Magus.AgentExecutor (Magus v0.1.0)

Summary

Functions

The AgentExecutor is a GenServer for executing an agent and managing/storing its state. This includes agent state as well as state about the execution (current node, status, errors, etc)

Returns the execution state of the given AgentExecutor process

Create a new AgentExecutor process responsible for running an agent.

Starts the agent execution for the given AgentExecutor process.

Subscribe to logs coming from the agent execution. This includes info about steps and the streamed content from the LLM.

Subscribe to new agents being started.

Subscribe to agent execution state changes.

Types

@type t() :: %Magus.AgentExecutor{
  agent: term(),
  created_at: term(),
  cur_agent_state: term(),
  cur_node: term(),
  error_message: term(),
  id: term(),
  pid: term(),
  status: term(),
  steps: term()
}

Functions

Link to this function

child_spec(init_arg)

The AgentExecutor is a GenServer for executing an agent and managing/storing its state. This includes agent state as well as state about the execution (current node, status, errors, etc)

For each node in the agent graph, a new Task will be started to run the function for the current node. If the node function succeeds, the current agent state will be updated and the executor traverses the agent's graph to find the next node to execute. If the node function fails, it is retrieved 3 times with an expotential backoff.

Once created, the AgentExecutor process can be subscribed to in order to get to state and log updates.

Link to this function

get_agent_log_topic(id)

Link to this function

get_agent_state_topic(id)

@spec get_state(atom() | pid() | {atom(), any()} | {:via, atom(), any()}) :: any()

Returns the execution state of the given AgentExecutor process

@spec new(agent: Magus.GraphAgent.t(), id: String.t()) ::
  {:ok, pid()} | {:error, any()}

Create a new AgentExecutor process responsible for running an agent.

Options

  • :agent - The Magus.GraphAgent definition of the agent for the executor.
  • :id - A string to use for the id of the execution.
Link to this function

notify_with_log(id, msg)

@spec run(atom() | pid() | {atom(), any()} | {:via, atom(), any()}) :: :ok

Starts the agent execution for the given AgentExecutor process.

Link to this function

subscribe_to_logs(pid)

@spec subscribe_to_logs(atom() | pid() | {atom(), any()} | {:via, atom(), any()}) ::
  :ok | {:error, {:already_registered, pid()}}

Subscribe to logs coming from the agent execution. This includes info about steps and the streamed content from the LLM.

Link to this function

subscribe_to_new_agents()

@spec subscribe_to_new_agents() :: :ok | {:error, {:already_registered, pid()}}

Subscribe to new agents being started.

Link to this function

subscribe_to_state(pid)

@spec subscribe_to_state(atom() | pid() | {atom(), any()} | {:via, atom(), any()}) ::
  :ok | {:error, {:already_registered, pid()}}

Subscribe to agent execution state changes.