Review and revert agent changes

When you work with an agent in Visual Studio Code, it can change multiple files in your project. This article explains how to inspect, revise, integrate, or discard these AI-generated changes.

Note

You can review AI-generated changes in both the Chat view and the Agents window. The review experience follows the same concepts, but the user interface differs between the two surfaces.

Review agent changes

The agent applies and saves edits directly in the session's folder or isolated Git worktree. These edits don't have a pending approval state, so you don't need to keep or undo each edit before you continue.

Review the changes as you would other workspace or branch changes through the diff view, Source Control, or pull request workflow.

  1. Select a changed file in the agent's response to open its diff or select it from the Source Control view.

  2. To see a summary after each completed request, set chat.checkpoints.showFileChanges Open in VS Code Open in VS Code Insiders to true. Expand the changed-files summary to see the files and diff statistics, or select View All File Changes to open a multi-file diff.

  3. If you want to make further changes, send a follow-up prompt or edit the files directly. To revert a request and all later changes, restore a checkpoint.

  4. Run tests and use the debugger or other editor tools to validate the result.

  5. When you're satisfied with the changes:

    • For folder-isolated sessions, stage and commit the changes with Source Control.

    • For worktree-isolated sessions, apply or merge the worktree changes into your main workspace.

    • For cloud sessions, review the pull request or check out its branch locally.

Integrate worktree changes

A worktree session keeps the agent's branch and working files separate from your primary worktree. After you review and validate the result, choose how to continue:

  • Apply or migrate the changes: transfer the worktree changes into your current workspace for further editing and commit them with your existing work.
  • Commit or merge the branch: preserve the work on the session branch and merge it into the destination branch.
  • Check out the branch: open the session branch in an editor window to continue working on it manually.
  • Discard the changes: remove changes that you don't want to keep.

Before you apply or merge changes:

  1. Confirm the session's base branch and the destination branch in your primary workspace.
  2. Commit or stash unrelated changes in the destination workspace.
  3. Review all changed files, including untracked files, and run the relevant tests.
  4. Select the integration action and resolve any merge conflicts.
  5. Test the integrated result before you archive or delete the session.

The available actions and labels depend on the session harness and whether you use the Chat view or Agents window. Keep the session until you verify that the changes are present on the intended destination branch.

Edit requests and restore checkpoints

Use request editing and checkpoints to revise or undo a batch of changes:

  • Edit a previous request: modify a prompt you already sent. VS Code reverts changes made by that request and all subsequent requests, then resends the edited prompt.
  • Restore a checkpoint: roll back all file changes to a specific point in the conversation without changing the prompt.

Edit a previous chat request

Each request in your conversation history is editable. When you edit a previous request, VS Code reverts file changes made by the original request and subsequent requests, and then sends the updated request to the language model.

Select the request in the conversation, modify it, and resend it. Configure or turn off request editing with chat.editRequests Open in VS Code Open in VS Code Insiders .

Restore a checkpoint

When checkpoints are enabled, VS Code creates a snapshot of affected files before processing each request. Set chat.checkpoints.enabled Open in VS Code Open in VS Code Insiders to control checkpoints.

To restore your workspace to an earlier checkpoint:

  1. Navigate to a previous request in the conversation.

  2. Hover over the request and select Restore Checkpoint.

    Screenshot showing the Restore Checkpoint action in the Chat view.

  3. Confirm that you want to restore the checkpoint.

VS Code removes subsequent requests from the conversation history and restores the workspace files to their state at the checkpoint.

Redo after restoring

After restoring a checkpoint, select Redo to recover the changes that were undone.

Screenshot showing the Redo button after restoring a checkpoint.

View file changes in checkpoints

Set chat.checkpoints.showFileChanges Open in VS Code Open in VS Code Insiders to show the files changed by each request and the number of lines added or removed. Use this summary to understand the effect of a request before restoring its checkpoint.

Screenshot showing file changes associated with a chat checkpoint.

Fork from a checkpoint

Hover over a request and select Fork Conversation to create an independent session that includes the conversation up to that checkpoint. Learn more about forking agent sessions.

Note

Checkpoints are temporary and don't replace Git version control. Use Git for permanent version history and collaboration.

Review extension-host changes

If agent host is not enabled or you are working with an older session, the agent uses the extension host to make edits, which has a different workflow for reviewing changes.

After the agent edits and saves a file, VS Code marks the edits as pending. Files with pending edits have a squared-dot indicator in the Explorer view and editor tabs. The pending state is restored when you reopen VS Code.

Screenshot showing the Chat view, highlighting the changed files list and the indicator in the Explorer view and editor tabs.

To review pending edits:

  1. Open a file from the changed-files list in the Chat view or from the Explorer view.

    Screenshot showing the Editor with proposed changes, highlighting the review controls in the editor overlay controls.

  2. Use the Up and Down controls in the editor overlay to navigate between edits.

  3. For each edit, choose one of the following actions:

    • Select Keep to accept the edit.
    • Select Undo to reject the edit and revert the change.
    • Hover over an inline change to accept or reject that specific change without affecting other edits in the file.

You can also accept or reject all pending edits from the Chat view. When you resolve an edit, the editor automatically opens the next file with pending edits. To stay in the current file, set chat.editing.revealNextChangeOnResolve Open in VS Code Open in VS Code Insiders to false.

Source Control integration

If you stage your changes in the Source Control view, any pending edits are automatically accepted. If you discard your changes, any pending edits are also discarded.

Auto-accept edits

Use chat.editing.autoAcceptDelay Open in VS Code Open in VS Code Insiders to automatically accept pending edits after a configurable delay. Hover over the editor overlay controls to stop the countdown.

Important

If you automatically accept all edits, review the changes before you commit them in source control. Learn more about the security considerations of using AI in VS Code.

Edit sensitive files

Sensitive-file approval is separate from reviewing changes after the agent makes them. To prevent inadvertent edits to files such as workspace configuration or environment settings, VS Code can show a diff and ask you to approve or reject the edit before it is applied.

Use the chat.tools.edits.autoApprove Open in VS Code Open in VS Code Insiders setting to configure which files require approval. The setting uses glob patterns to match file paths in your workspace.

The following example configuration automatically allows edits to all files except for JSON files in the .vscode folder and files named .env, which you are prompted to approve:

"chat.tools.edits.autoApprove": {
  "**/*": true,
  "**/.vscode/*.json": false,
  "**/.env": false
}

Review changes from the sessions list

When a session completes and makes code changes to your project, the sessions list shows the file change statistics for that session. To review the changes, select the session from the list to open the session details.

Screenshot of the file changes diff editor in an agent session.

Depending on the agent harness and isolation mode, you can apply or merge changes into your local workspace, or check out the branch from a cloud session.