pig/run
Transient, caller-owned event streams for one complete agent run.
Types
Events emitted for one accepted run.
Deltas are transient and only appear here. Every started inference and tool
operation has one matching finished event, and every run has one terminal
Completed, Failed, or Cancelled event.
pub type RunEvent {
RunStarted
InferenceStarted(round: Int)
InferenceDelta(round: Int, delta: inference.InferenceDelta)
InferenceFinished(
round: Int,
result: Result(inference.InferenceResult, error.AiError),
)
ToolStarted(round: Int, call: message.ToolCall)
ToolFinished(
round: Int,
call: message.ToolCall,
result: Result(json.Json, tool.ToolError),
)
ToolBlocked(round: Int, call: message.ToolCall, reason: String)
Completed(result: inference.InferenceResult)
Failed(error: run_error.RunError)
Cancelled(reason: run_error.CancelReason)
}
Constructors
-
RunStarted -
InferenceStarted(round: Int) -
InferenceDelta(round: Int, delta: inference.InferenceDelta) -
InferenceFinished( round: Int, result: Result(inference.InferenceResult, error.AiError), ) -
ToolStarted(round: Int, call: message.ToolCall) -
ToolFinished( round: Int, call: message.ToolCall, result: Result(json.Json, tool.ToolError), ) -
ToolBlocked(round: Int, call: message.ToolCall, reason: String) -
Completed(result: inference.InferenceResult) -
Failed(error: run_error.RunError) -
Cancelled(reason: run_error.CancelReason)
Values
pub fn cancel(run: Run, reason: run_error.CancelReason) -> Nil
Cancel a run. Repeated calls and calls after terminality are harmless.
pub fn runtime_owner(run: Run) -> process.Pid
pub fn watch_client(run: Run, owner: process.Pid) -> Nil
Replace the process watched as this run’s client owner.
If that process exits while the run is active, the runtime cancels the run
with ClientDisconnected.