All Agent Engineering

OpenCode V2 snapshots: inspect rollback before rewriting or restoring

Stage undo in a stopped session, inspect restored paths and diffs, then choose an edited prompt or redo before submission.

AINavWritten / Updated
On this page

At a glance

OpenCode V2 /undo stages a rollback, restores attributed files and puts the removed prompt back in the composer. /redo can cancel it before submission; submitting an edited prompt commits the staged rollback. This task creates a decision sheet for a synthetic edit: confirm scope and backup, inspect affected files, then choose rewrite or restoration. Capture can fail; snapshots are not a transaction or backup. No OpenCode run, file edit or rollback was performed.

Runtime and applicability

Article type
Engineering practice
Verified
Applies to
  • OpenCode V2 staged conversation and file rollback

Execution locations and responsibilities

  • Stopped OpenCode V2 session Stage, inspect and choose rewrite or cancellation.
  • Session active directory in a Git worktree Back up important work and inspect paths and diffs without concurrent writes.

When to use

  • A stopped V2 session needs recent conversation and attributed file changes revised, with important work independently backed up.

When not to use

  • Snapshots do not reverse databases, processes, network resources or Git commits. Ignored, uncaptured or out-of-directory files are not covered.
  • Do not roll back while external editors can modify affected paths, backups are unconfirmed or the session is still running.

Establish directory and backup scope

Start with an ended V2 session and its active directory, such as packages/app inside a Git worktree. Record git status --short, identify work to preserve and commit or back up important changes through your own process. Tracked files in the active directory are captured. Non-ignored untracked files up to 2 MiB each are eligible; ignored files, larger untracked files, outside paths and Git metadata are excluded. Outside Git, undo can revise conversation but cannot restore files.

Synthetic scope
Path or objectCoverage in this example
packages/app/src/api.tsTracked active-directory file is eligible
packages/app/notes.txtEligible if non-ignored and at most 2 MiB
packages/server/src/api.tsOutside the active directory
Database, process or commitNot a filesystem restore object

Check that usable capture exists

OpenCode attempts snapshots before each model step and at its recorded success or failure; assistant messages attribute changed paths between them. Capture can fail. If either snapshot is unavailable, conversation continues but file restoration for that step may be unavailable. A model edit alone does not prove a complete restore point. Stop and use an existing backup plan if recoverability cannot be established.

Stage rollback and inspect affected paths

Once the session stops, use /undo, or Revert on an earlier message to select a boundary. Attributed paths from later assistant steps return to their state before the first reverted step. A file created by those steps is removed if it did not exist then. Unattributed paths remain, but current manual edits to an affected path may be overwritten. Back up first and inspect the restored summary and diff afterward.

Example: inspect changes in an owned worktree
Shell
git diff --stat
git diff
git status --short

Choose one exit before submission

Rollback decisions
ConclusionNext actionMeaning
Correct scope, ready to rewriteEdit the restored prompt and submitCommit rollback and start a new request
Rollback is unwantedRun /redo before submittingCancel it and restore prior conversation and files
Unknown overwrite or unclear scopeStop edits and requests; retain recordsResolve through backups and diffs before continuing

Imagine an assistant changed api.ts from A to B and created helper.ts. Rolling back before those steps should restore A and remove helper.ts if it was previously absent. This is an expectation from the documented rules, not an observed result. A revised prompt could request input validation without changing the public API; submit only after choosing rewrite. Choose redo before submission if restoration is intended. Do not take both exits.

Cancellation can overwrite later edits too

External editors can still modify the worktree after staging. /redo can overwrite those later edits, so avoid concurrent writes to affected paths until the decision ends. Rejecting rollback during a running OpenCode session does not prevent external processes. If concurrent changes occur, preserve current content and diagnostics before selecting recovery; redo is not an unconditional safe undo.

Deliver a scope and decision record

  • Record V2, active directory, conversation boundary, backup and usable capture.
  • Check restored and removed paths, especially existing manual changes.
  • Choose only one exit and record whether the action preceded submission.
  • Track external side effects separately; file restoration does not prove a full task rollback.
  • Failures and stops retain available diffs and causes without inventing recovery.

Storage and verification scope

Snapshots live in a separate internal Git object database in OpenCode’s data directory. Capture does not create repository commits or move branches. Objects may contain complete tracked and eligible untracked contents and need sensitive-data handling. Disabling snapshots stops future captures without deleting old ones. Committed rollback changes the active conversation view, not durable history or storage, and is not secure erasure. The current V2 page was read fully. No installation, login, capture or restore was performed, and no V1 custom-tool API is used.

Sources

All links are official pages; verification dates are listed per source, and links point to the version checked.

  1. OpenCode · Snapshots — OpenCode V2

Found an error? Tell us →