Skip to content

Checkpoint API

Thin ReAct-loop bookmarks persisted under an agent session. See Checkpoints for usage and resume semantics.

python
from elsai.checkpoint import Checkpoint, CheckpointConfig, CheckpointException

Deprecated import path

from elsai.experimental.checkpoint import ... still works but emits a deprecation warning. Use elsai.checkpoint.


CheckpointConfig

python
from elsai.checkpoint import CheckpointConfig

Selects which loop boundaries write a bookmark. Pass on AgentConfig.checkpoint (requires a session_manager).

python
from elsai.agent import AgentConfig
from elsai.checkpoint import CheckpointConfig
from elsai.session import FileSessionManager

config = AgentConfig(
    agent_id="worker",
    session_manager=FileSessionManager(session_id="job-1", storage_dir="./sessions"),
    checkpoint=CheckpointConfig(position="both"),
)
FieldTypeDefaultDescription
position"after_tools" | "after_model" | "both""after_tools"Boundaries at which to save

Methods

MethodReturnsDescription
saves_after_tools()boolTrue when position is "after_tools" or "both"
saves_after_model()boolTrue when position is "after_model" or "both"

TIP

Pass CheckpointConfig, not a Checkpoint instance. Wrong types raise TypeError at Agent construction.


Checkpoint

python
from elsai.checkpoint import Checkpoint

Frozen, JSON-serializable bookmark written to checkpoint.json. Schema version: 1.0.

Users normally do not construct this for day-to-day usage — the event loop writes it. Treat it as a read model when inspecting disk or writing tests.

FieldTypeDescription
position"after_model" | "after_tools"Boundary just completed (never "both")
cycle_indexint ≥ 00-based ReAct cycle index at save
schema_versionstrMust match SDK version on load
created_atstrISO-8601 UTC (...Z); auto-filled if empty
message_countint | Nonelen(messages) at save (used by resume gate)
agent_idstr | NoneDisambiguation / consistency
execution_status"active" | "completed"Auto-resume only if "active"

Methods

MethodDescription
validate()Raises CheckpointException if invalid
to_dict()JSON-compatible dict
Checkpoint.from_dict(data)Reconstruct and validate

CheckpointException

python
from elsai.types.exceptions import CheckpointException
# or
from elsai.checkpoint import CheckpointException

Raised for schema, I/O, or validation failures on checkpoint load/serialize. Distinct from SessionException.


Session manager methods

FileSessionManager and S3SessionManager (via the repository façade) expose:

MethodDescription
write_checkpoint(agent, checkpoint)Persist / overwrite checkpoint.json
read_checkpoint(agent)Load bookmark or None if missing
delete_checkpoint(agent)Remove the bookmark file

Prefer letting the agent loop manage writes. Manual writes are mainly for tests or crash simulation.


AgentResult resume fields

Set when an invoke acts on an allowed loaded bookmark (not merely loads one):

FieldTypeDescription
resumed_from_checkpointboolTrue if this invoke resumed from a checkpoint
resume_position"after_model" | "after_tools" | NoneBoundary that was resumed

Copyright © 2026 elsai foundry.