---
title: "Roll back to the previous version in a second, with while.sh"
url: https://while.sh/en/guides/rollback/
author: "Aloïs Oddon, co-founder of Nextmap"
updated: 2026-11-02
---

# Roll back to the previous version in a second, from your AI agent

A new version breaks your app: ask your AI agent to roll back, and the previous version takes the traffic again in a second. Then your agent reads the error, fixes it and deploys again.

## Prerequisites

- An app deployed on while.
- Your AI agent, connected to while over MCP.

## Step 1: Ask for the rollback

> You, to your agent: Go back to the previous version.

In the 30 minutes after a deployment, the previous version takes the traffic again in a second. After that, it takes a few seconds.

## Step 2: The fixed version follows

Your agent reads the error and the logs in while, fixes the problem and deploys the fixed version.

## What your agent does

Every version is frozen, and the previous one stays ready for 30 minutes after a deployment: going back only switches the traffic back to it. A version that fails its health check, or whose error rate climbs, is withdrawn automatically, without waiting for you to ask. And a version whose tests fail is never deployed. Going back fast matters: it's one of DORA's four key metrics (source 1).

## Go back to an older version

> You, to your agent: Go back to Monday's version.

Your agent lists the versions, with their dates, and deploys Monday's version again, in a few seconds.

## Understand what broke

> You, to your agent: Why is the new version crashing?

Your agent reads the error, the logs and the grouped errors in while, and finds the line responsible.

## Roll back the data too

> You, to your agent: Also restore the database to how it was before the migration.

The code and the database go back separately. Your agent restores the database to the moment before the migration, once you approve it in production.

## See a new version before you deploy it

> You, to your agent: Show me the new version before you deploy it.

Your agent opens a preview, at its own address, with its own data. You look at it, then your agent puts it into production.

## Next steps

- [Restore your database to a precise moment](/en/guides/restore-postgresql/)
- [Track errors with a Sentry SDK](/en/guides/track-errors-sentry/)
- [See every version before production](/en/guides/preview-environments/)

## Sources

1. [DORA, the four key metrics of software delivery](https://dora.dev/guides/dora-metrics/), 2026-11-02

## Questions

### Does a rollback touch my database?

No, it only changes the code. The database is restored separately, to a precise moment.

### Can a broken version stay live?

No. A version that fails its health check, or whose error rate climbs, is withdrawn automatically.

### What about an app that's asleep?

The previous version comes back right away, and its first request wakes it up.
