Function: fileCheckpoints()
@providerprotocol/agents / checkpoint / fileCheckpoints
Function: fileCheckpoints()
Section titled “Function: fileCheckpoints()”fileCheckpoints(
options):CheckpointStore
Defined in: src/checkpoint/file.ts:105
Creates a file-based checkpoint store for persisting agent state.
This is the reference implementation of CheckpointStore that uses the local filesystem for storage. Each session gets its own subdirectory containing the checkpoint and metadata files.
Parameters
Section titled “Parameters”options
Section titled “options”Configuration options for the store.
Returns
Section titled “Returns”A CheckpointStore implementation backed by the filesystem.
Remarks
Section titled “Remarks”Directory structure:
{dir}/ {sessionId}/ checkpoint.json # Full serialized AgentState metadata.json # Lightweight session metadataThe store automatically creates directories as needed. Files are written with pretty-printed JSON (2-space indent) for debuggability.
Examples
Section titled “Examples”import { fileCheckpoints } from '@providerprotocol/agents/checkpoint';import { agent, AgentState } from '@providerprotocol/agents';import { anthropic } from '@providerprotocol/ai/anthropic';
const store = fileCheckpoints({ dir: './my-checkpoints' });
// Create agent with checkpoint supportconst coder = agent({ model: anthropic('claude-sonnet-4-20250514'), tools: [Bash, Read], checkpoints: store, sessionId: 'task-123',});
// Agent automatically checkpoints after each stepconst { turn, state } = await coder.generate('Fix the bug', initialState);const store = fileCheckpoints({ dir: './checkpoints' });
// Try to resume existing sessionconst saved = await store.load('my-session');const initialState = saved ? AgentState.fromJSON(saved) : AgentState.initial();
// Continue execution from restored or fresh stateconst { turn, state } = await coder.generate('Continue working', initialState);const store = fileCheckpoints();
// List all saved sessionsconst sessions = await store.list();
// Get metadata without loading full statefor (const sessionId of sessions) { const meta = await store.loadMetadata(sessionId); console.log(`${sessionId}: step ${meta?.step}, saved ${meta?.timestamp}`);}
// Clean up completed sessionawait store.delete('completed-session');