pub async fn run_session(
backend: &dyn AgentBackend,
spec: SessionSpec,
log: &mut EventLog,
paths: &MissionPaths,
run_meta: RunMeta,
cancel: Option<Arc<Notify>>,
) -> Result<RunOutcome>Expand description
Spawn one session and stream it to completion.
Emits worker.spawned before the session starts and worker.completed
after it ends. Result events are aggregated: usage is summed across all
of them (streaming sessions emit one per turn), text/is_error come from
the last, and cost is the last one reported.
Result mapping: Fail if the last result is_error or the session exit
is Failed; Partial if the exit is Aborted (budget/interrupt — forced
even when a report parses); otherwise the role’s report decides (Pass
only downgradeable by the report; a missing/unparseable report for a
worker or validator is Partial, plan §4.6).
cancel: when the notify fires the session is aborted (exit: Aborted).
This is the LogTarget::Live convenience form: the caller passes the
shared single-writer log and every event kind is appended to it as it
arrives. run_session_to is the same logic over an arbitrary
LogTarget, used by the buffered concurrent path (roadmap M3).