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
Functions
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.
get_agent_log_topic(id)
get_agent_state_topic(id)
get_state(pid)
Returns the execution state of the given AgentExecutor process
new(opts)
@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
- TheMagus.GraphAgent
definition of the agent for the executor.:id
- A string to use for the id of the execution.
notify_with_log(id, msg)
run(pid)
Starts the agent execution for the given AgentExecutor process.
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.
subscribe_to_new_agents()
@spec subscribe_to_new_agents() :: :ok | {:error, {:already_registered, pid()}}
Subscribe to new agents being started.
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.