# Overview

Canonical URL: https://developers.iagenify.com/sdk/agent/checkpoints/
Language: en

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.

Status: on by default · needs a session · 20 kept

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 {#using}

```javascript
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
```

## A point is a message, not a step {#numbering}

`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 {#returns}

```javascript
{
  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 }
}
```

> **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 {#requirements}

| Requirement | Otherwise |
| --- | --- |
| `memory: true` | `session_required` — there is no session to attach points to. |
| Not currently answering | `agent_running` — call `stop()` first. |
| `checkpoints` not turned off | `checkpoints_disabled`. |
| Not a subagent | A subagent keeps none: it has no conversation of its own to cut. |

## Turning it off {#turning-off}

```javascript
api.agents.create({ runtime: "local", machine: pc, 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.

- [How snapshots work](/sdk/agent/checkpoints/snapshots): Deduplication, heavy folders, what is skipped.
- [What a rewind cannot undo](/sdk/agent/checkpoints/limits): The honest list.
- [rewind()](/sdk/ref/local-agent/rewind): The method.

```python
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
```

```python
{
    "n": 2,
    "files": {"restored": [...], "recreated": [...], "deleted": [...], "skipped": [...]},
    "kept": [],                          # what left the machine and stays done
    "credits": {"spent": 0, "refunded": 0},
}
```

```python
api.agents.create(runtime="local", machine=pc, model=model, memory=True, checkpoints=False)
```
