Expand description
Agent-state persistence: turning a live ECS agent into the on-disk snapshot
the dashboard/API read (meta.json + context.json under the run directory).
This module holds the pure serialization core - components that carry an
agent’s run identity and running token totals, plus functions that build the
RunMeta/ContextSnapshot value types from an agent’s live components.
It does no I/O; the async write lane and the snapshot-dispatch system layer on
top of these.
Structs§
- RunMetadata
- Static per-agent run metadata (the parts of
RunMetathat don’t change as the agent runs). Set once when the agent is spawned; the dynamic fields are filled from the live components at snapshot time. - RunOutcome
Flags - Run-scoped productivity flags, mirrored into
meta.jsonso an empty run can be recognized (and explained) from disk. UnlikeStageProgress, this is never reset on a stage transition - it describes the whole run. - Token
Totals - Running token + tool-call totals accumulated across an agent’s inferences, for the snapshot. Updated by the inference-collect system.
Functions§
- build_
context_ snapshot - Build the full context snapshot (
context.json) from a window. Pure over the window - no engine/entity. (Ported from the CLI’sbuild_context_snapshot.) - build_
run_ meta - Build the run metadata (
meta.json) from an agent’s live components, stampingupdated_atwithnow_secs.stage_indexis the agent’s current stage position within its blueprint. - run_
status_ from - Map an agent’s ECS status to the on-disk
RunStatus. - stage_
status_ from - Map an agent’s ECS status to the on-disk per-stage
StageRunStatusfor the stage it is currently in.Cancelledhas no stage-level equivalent, so it surfaces asError(the stage stopped without completing).