Skip to main content

Module loop_checkpoint

Module loop_checkpoint 

Source
Expand description

Per-tool-round loop checkpoints for crash-tolerant runs (P3 cut 1).

The agent loop persists a LoopCheckpoint after each completed tool round. The checkpoint captures the minimum state needed to recreate the loop’s position so a future process — typically on a different node, dispatched by 书安OS after a crash or planned migration — can resume from the last consistent boundary.

Boundary policy: checkpoints are taken only between tool rounds, never mid-tool. If a process dies while a tool is executing, the work of that round is lost on resume; the LLM re-deliberates from the previous checkpoint. This trades retry cost for correctness — re-executing a non-idempotent tool (write, bash) on the wrong side of the boundary is worse than re-asking the LLM.

Resume API (cut 2 follow-up): not part of this cut. This module lands the data contract + persistence wiring; an AgentSession::resume_run(run_id) entry point will live on top.

Structs§

LoopCheckpoint
Snapshot of the agent loop at the boundary between tool rounds.
SessionStoreCheckpointSink
Default adapter that forwards checkpoints to a SessionStore. Construct via SessionStoreCheckpointSink::new.

Constants§

LOOP_CHECKPOINT_SCHEMA_VERSION
Schema version. Bumped on incompatible format changes; impls of LoopCheckpointSink should reject loads from a future version.

Traits§

LoopCheckpointSink
Receiver of per-tool-round checkpoints.