class LittleGhost::CodeMode::Session

Lifecycle contract for one Engine’s active program.

LittleGhost’s Agent runtime serializes execute, wait, and stop for a Session. Direct callers must also avoid overlap; built-in Sessions reject concurrent control operations. An implementation applies the supplied limits, observes RunContext cancellation, keeps model-written execution inside its Sandbox, and routes Tool calls through the parent-process Broker.

Each control operation returns a ProgramResult. Built-in engines use :completed when execution ended successfully, :still_working when an observation interval elapsed, :terminated after requested termination, and :error for a model-program error. wait observes an active program without pausing, resuming, or restarting it. Lifecycle, host, and cleanup failures raise rather than becoming a result.

ProgramResult.new(
  output: "",
  value: nil,
  status: :completed,
  error: nil
)