class LittleGhost::Run

Observe one top-level assembly execution from start to finish. A run records its response, outcome, usage, error, and owned resources.

run = CustomerSupportAgent.ask("Why is transfer 481 pending?")

run.completed? # => true
run.outcome    # => "completed"
run.response   # => "Transfer 481 is waiting for the receiving bank."

ask returns the Run after work finishes. stream_ask yields StreamEvent objects as work happens, then returns the same finished Run. A Run executes only once.

stream = CustomerSupportAgent.stream_ask("Where is transfer 481?")
run = stream.each do |event|
  publish(event) if event.type == :text_delta
end

run.completed? # => true
run.response

Outcomes

Completion, failure, deadline, and cancellation become the completed, failed, partial, and cancelled outcomes. Ordinary execution failures are available through error and the terminal stream event. Failures while closing resources, delivering events, or reporting instrumentation may still raise because LittleGhost cannot report a reliable ending.

Tool validation and ToolError failures return safe Tool results to the model, which may recover and complete the Run. Input, configuration, or resource construction can raise before a Run exists. Once execution begins, terminal events are run_stop, run_error, run_partial, and run_cancel.

Owned resources

The Run opens its workspace, sandbox, Session, and Assembly entrypoint, then closes registered resources in reverse order. register adds application resources to that cleanup sequence. Interjection is available only while one Agent entrypoint is active.

Nested Agent events

A composite Assembly stream observes every Agent that shares the Run. Each :agent_stream event carries an AgentStreamSource in data[:source] and a copied, frozen Agent StreamEvent in data[:event]. An inner :invocation_start also includes the copied, frozen Message sent to that Agent in data[:input]. Event consumers cannot change the running work.

Parallel Agents may interleave, but the Run invokes the stream consumer serially. Contextual events expose data from every participating Agent, so applications should enable include_agent_events only for destinations that may see every participant’s data.