pig/supervisor
Supervised agent — wraps agent in OTP static supervisor.
The easy path: start_supervised(config) gives you an agent
managed by a OneForOne supervisor. Advanced users can still
use pig.start(config) for standalone agents.
Types
Errors that can prevent a supervised agent from starting.
pub type StartError {
ActorStart(error: actor.StartError)
SessionLoad(error: session_store.SessionError)
}
Constructors
-
ActorStart(error: actor.StartError)The OTP supervision tree or one of its children could not start.
-
SessionLoad(error: session_store.SessionError)The durable session could not be loaded before the tree was started.
Handle to a supervised agent.
Wraps the agent’s Subject and the supervisor’s Pid.
Use run/run_with_timeout to send prompts, stop to
tear down the supervision tree.
pub type SupervisedAgent {
SupervisedAgent(
subject: process.Subject(runtime.RuntimeMsg),
sup_pid: process.Pid,
)
}
Constructors
-
SupervisedAgent( subject: process.Subject(runtime.RuntimeMsg), sup_pid: process.Pid, )
Values
pub fn run(
sup: SupervisedAgent,
prompt: String,
) -> Result(message.Message, run_error.RunError)
Run a prompt against the supervised agent with a 120-second timeout.
pub fn run_continue(
sup: SupervisedAgent,
) -> Result(message.Message, run_error.RunError)
Resume a supervised agent’s loaded or interrupted history.
pub fn run_continue_with_timeout(
sup: SupervisedAgent,
timeout_ms: Int,
) -> Result(message.Message, run_error.RunError)
Resume a supervised agent’s history with an explicit timeout.
pub fn run_with_timeout(
sup: SupervisedAgent,
prompt: String,
timeout_ms: Int,
) -> Result(message.Message, run_error.RunError)
Run a prompt against the supervised agent with an explicit timeout.
pub fn start_supervised(
agent_config: state.AgentConfig,
consumer_specs: List(consumer_spec.ConsumerSpec),
) -> Result(SupervisedAgent, StartError)
Start a supervised agent without durable session storage.
This convenience path starts with empty history and no durable session.
pub fn start_supervised_with_session_store(
agent_config: state.AgentConfig,
consumer_specs: List(consumer_spec.ConsumerSpec),
store: session_store.SessionStore,
) -> Result(SupervisedAgent, StartError)
Preflight a durable session, then start a supervised agent.
The preflight preserves a typed SessionLoad error without starting the
supervision tree. The runtime independently reloads the store every time
its worker starts, including after OTP child restarts.
pub fn stop(sup: SupervisedAgent) -> Nil
Stop the supervised agent.
Sends an exit signal to the supervisor process. OTP cascades shutdown to the agent child process.