Checkpoints

Overview

The workspace is photographed before each of your messages. Going back to one puts every file exactly as it was — and says plainly what it could not undo.

on by defaultneeds a session20 kept
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

Undo logs do not work for an agent. A file written by a command has no previous version, a file created after the fact has no « before », a rename has no inverse. So the engine keeps a snapshot instead of a list of reversals.

Using it

const agent = api.agents.create({
  runtime: "local", machine: pc, model: "gemini-3.5-flash",
  memory: true,                        // checkpoints need a session
  mode: "auto",
});

await agent.run({ inputs: "Rename every component to PascalCase." });
await agent.run({ inputs: "Now update the imports." });

const points = await agent.checkpoints();
// [{ n: 1, at, text: "Rename every component…", files: 184, partial: false, outside: [] },
//  { n: 2, at, text: "Now update the imports.",  files: 184, partial: false, outside: [] }]

await agent.rewind(2);     // back to just before the second message
agent = api.agents.create(
    runtime="local", machine=pc, model="gemini-3.5-flash",
    memory=True,                         # checkpoints need a session
    mode="auto",
)

agent.run(inputs="Rename every component to PascalCase.")
agent.run(inputs="Now update the imports.")

points = agent.checkpoints()
# [{"n": 1, "at", "text": "Rename every component…", "files": 184, "partial": False},
#  {"n": 2, "at", "text": "Now update the imports.",  "files": 184, "partial": False}]

agent.rewind(2)     # back to just before the second message

A point is a message, not a step

n counts your messages in the session. Rewinding to n restores the files as they were before that message and removes the message and everything after it from the conversation, the device journal and the account.

What rewind reports

{
  n: 2,
  removed: { messages: 11, turns: 5 },
  files: { restored: [...], recreated: [...], deleted: [...], skipped: [...] },
  kept: ["send_mail", "deploy"],           // what left the machine and stays done
  credits: { spent: 24, refunded: 0 }
}
{
    "n": 2,
    "files": {"restored": [...], "recreated": [...], "deleted": [...], "skipped": [...]},
    "kept": [],                          # what left the machine and stays done
    "credits": {"spent": 0, "refunded": 0},
}
kept and refunded: 0 are the honest part

A message that was sent is sent. A site that was published is online. Credits that were spent are spent. The answer names them rather than letting « rewind » suggest the world was put back.

What it needs

RequirementOtherwise
memory: truesession_required — there is no session to attach points to.
Not currently answeringagent_running — call stop() first.
checkpoints not turned offcheckpoints_disabled.
Not a subagentA subagent keeps none: it has no conversation of its own to cut.

Turning it off

api.agents.create({ runtime: "local", machine: pc, model, memory: true, checkpoints: false });
api.agents.create(runtime="local", machine=pc, model=model, memory=True, checkpoints=False)

Reasonable on a huge workspace, or where the storage quota matters more than going back. A snapshot that cannot be taken never blocks an answer — it is skipped and the run continues.