# Fork and rollback for AI agent workspaces

Give an AI agent a fork of your drive, review what it changed, and roll back a file, a run or everything since a checkpoint. Every write is a version.

**Every change an agent makes is a version. Every run can be taken back.**

Orbit drives are versioned file storage. An AI agent, connected over MCP or S3, can work in a fork of a drive instead of the original. When it is done, you see what it added, changed and removed, and merge only what you approve. If something wrong already landed, you roll back one file, one run, or everything since a checkpoint, and nothing is erased on the way back.

This page explains the pieces and when to use each. For the click-by-click workflow, see [Review and undo what your AI agent changed](https://docs.orbitfs.io/guides/review-and-undo).

## How fork and rollback work

- **Every write adds a version.** An upload, a save from Finder, an in-place edit, a write from an agent: each one adds an immutable version. Nothing you do later alters a version.
- **A fork is an instant copy of a drive.** It starts with every file, folder and version the source held at that moment. No file data is copied, so forking a large drive takes about as long as forking a small one. After that the two drives are independent. Nothing written to one appears in the other.
- **A merge brings a fork back as one change.** Orbit compares the fork point, the fork now and the original now, and applies what only the fork changed. The original takes over the fork's stored blocks, so nothing is copied.
- **Rollback adds a change. It never rewinds.** Restoring a version, undoing a run or returning to a checkpoint writes a new change with the earlier contents. The versions in between stay, so a rollback can itself be undone.

```text
v1  upload
v2  edit by agent
v3  edit by agent   <- you restore v1
v4  restore of v1   <- current
```

## Pick the right rollback

| What went wrong | Roll back with | Web app | MCP tool |
| --- | --- | --- | --- |
| An agent run you have not merged | Discard the fork | Delete the fork | — |
| Part of a fork is good | Merge only that part | **Review changes** on the fork | `compare_fork`, then `merge_fork` with `paths` |
| A merge you regret | Undo the merge | **Activity** on the original, **Undo** | `undo_changes` with the merge's run |
| An agent changed the original in place | Undo that run | **Activity**, **Undo** on the run | `list_activity`, then `undo_changes` |
| Everything since a known good moment | Return to a checkpoint | **Return to this checkpoint** | `undo_changes` with `checkpoint_id` |
| One file is wrong | Restore a version | **Version history**, **Restore** | `list_versions`, then `restore_version` |
| A file was deleted | Bring it back | **Deleted files** in the drive's **⋯** menu | `list_deleted_files`, `list_versions`, then `restore_version` with `if_absent: true` |

An undo leaves alone any file someone changed after the run you are undoing, and lists it. **Undo** shows the files it would change before it changes them.

## Before the agent starts

1. **Connect the agent with the right access.** Follow [Connect an agent](https://docs.orbitfs.io/guides/agents) for Claude Code, Codex, Cursor or VS Code. On the consent page choose **Can edit**, **Only these drives**, and **May create and copy drives** so the agent can fork. Leave **May delete drives** off. Without permission to create and copy drives, `fork_drive` is not in the agent's tool list.
2. **Ask for a fork in the prompt**, or fork the drive yourself: in the web app open the drive's menu and choose **Fork**; in the Mac app choose **Fork…** from the drive's **…** menu. Forking needs the owner or admin role.
3. **Working in place instead?** Create a checkpoint first: **Create checkpoint** in Activity, or have the agent call `create_checkpoint`. It copies nothing and takes no storage. For broad changes, a fork is still safer.

## Fork, review and merge over MCP

The agent works through these tools:

1. `fork_drive` creates the fork and returns its `drive_id`. The agent works only in the fork.
2. `compare_fork` lists every path the fork changed. Each entry is `clean` (merges as is), `same` (the original already has it) or `conflict` (both sides changed it differently), plus `fork_seq` and `source_seq`.
3. `merge_fork` with `dry_run: true` shows what would happen. Then `merge_fork` with the same `fork_seq` and `source_seq` applies it as one change. Clean changes are applied and conflicts are skipped unless you decide them. If either drive changed since the comparison, nothing merges. The fork itself is not changed or deleted.
4. If you don't want the result, delete the fork. The original is untouched.

In the web app, the same comparison is **Review changes** on the fork, marked **Ready to merge**, **Already in the original** or **Conflicts**.

:::note
Orbit does not combine two edits to the same file. A file both sides changed is a conflict, whatever its format. You choose which version wins, and the other stays in history.
:::

## Undo AI agent file changes over MCP

- `list_activity` lists recent runs on a drive, newest first. A run is one connection's saves with no long pause between them, from an agent connection, an access key, or a person's session. Each run has its `session`, `since_seq` and `until_seq`. Merges and undos are runs of their own.
- `undo_changes` takes exactly one of `mine: true` (this connection's own changes), `session` with `since_seq` and `until_seq` (one run, by anyone), or `checkpoint_id` (everything after a checkpoint). Call it with `dry_run: true` first.
- `list_versions` and `restore_version` bring back one file. `restore_version` makes an older version current as a new version.

## Fork and roll back from a script (S3)

A drive is an S3 bucket. Fork with a full-control key by naming the source in `x-uls-fork-source`:

```http
PUT /<new-drive>
x-uls-fork-source: <source drive name or ID>
```

The response carries `x-uls-drive-id` (the fork), `x-uls-fork-source-id` and `x-uls-fork-point`. Give the job a [child key](https://docs.orbitfs.io/start/access-keys#child-keys) that reaches only the fork:

```json
{ "drives": ["<fork_id>"], "access": "write", "label": "agent-run-42" }
```

To roll back one file over S3, restore a version. Add `If-Match: <etag>` to restore only if nobody changed the file since you looked:

```http
POST /<drive>/<key>?x-uls-restore&versionId=<version ID>
```

To read a file as it was at a moment, send `x-uls-as-of` with an RFC 3339 timestamp. See [History and restore](https://docs.orbitfs.io/guides/history) and [S3 for agents](https://docs.orbitfs.io/guides/s3-for-agents).

:::note
**Coming soon.** Orbit does not ship a command-line tool. Review in the web app, or have the agent call `compare_fork` and `merge_fork`.
:::

## Limits and what this does not do

- A workspace can have up to 50 forks at a time, up to 8 levels deep. Forks don't count toward the Individual plan's one-drive limit.
- A fork uses no storage when created. It is billed only for data written to it afterwards. Earlier versions and deleted files count toward storage, though a version shares the data it has in common with its neighbors.
- You can't delete a single version. `DeleteObject` with a `versionId` returns `501`.
- History is not a backup. It lives in the same drive. Keep an independent copy of data you can't afford to lose.
- Revoking an agent connection takes effect within 30 seconds.

## FAQ

### What is versioned file storage with fork and rollback?

Storage where every write adds a version you can return to, and a whole drive can be copied instantly as a fork. In Orbit, an AI agent works in a fork, you review and merge what you approve, and you can roll back a file, a run or everything since a checkpoint.

### How do I undo an AI agent's file changes?

Open **Activity** on the drive and choose **Undo** on the agent's run. It shows the files it would change first. From the agent itself, `undo_changes` does the same. The undo is a new change, so it can be undone too.

### Does forking a drive copy all the data?

No. A fork shares stored data with its source until one of them changes, so it uses no storage when created and takes about as long for a large drive as a small one.

### Is my original drive safe while an agent works in a fork?

Yes. Nothing written to the fork appears in the original until you merge, and you can delete the fork to throw the work away.

### Which agents can fork and roll back?

Any MCP client connected to Orbit with **Can edit** and **May create and copy drives**, including Claude Code, Codex, Cursor and VS Code. Scripts and workers can do the same over S3 with a key limited to the fork.

### What happens when the agent and a person changed the same file?

The comparison marks it as a conflict and the merge skips it unless you choose the fork's version. The original's version stays in history either way.

### How much does it cost?

Plans are priced per member and include storage. The billing catalog does not list a separate charge for an agent connection, and it does not say a connection uses a seat. Free includes 5 GB, Individual 500 GB, and Teams 1 TB per member. A fork costs nothing when created and grows only as it diverges. Earlier versions and recoverable deleted files count toward storage. See [Plans and storage](https://docs.orbitfs.io/web/plans).

## Related

- [Review and undo what your AI agent changed](https://docs.orbitfs.io/guides/review-and-undo)
- [Connect an agent over MCP](https://docs.orbitfs.io/guides/agents)
- [S3-compatible storage for AI agents](https://docs.orbitfs.io/guides/s3-for-agents)
- [Fork a drive](https://docs.orbitfs.io/guides/forks)
- [History and restore](https://docs.orbitfs.io/guides/history)
- [Activity](https://docs.orbitfs.io/guides/activity)
- [Orbit vs FlashDrive](https://orbitfs.io/blog/orbit-vs-flashdrive)
- [Pricing](https://orbitfs.io/pricing)
