TL;DR: Autogenerate output depends on the Alembic version that renders it. Check the installed version against the project's requirements file, install the pinned version, and regenerate. Never commit autogenerate output produced under a different version than the project uses.

```text
agent's alembic version is newer than the one that wrote the existing revisions - autogenerate produces different output now
```

1. Detect the skew.
```
pip show alembic | grep -i version
# compare against requirements.txt / pyproject.toml
```
Expected: the installed version is newer than the pinned one, and you know both numbers.

2. Install the pinned version in the environment that runs autogenerate.
```
pip install 'alembic==PINNED_VERSION'
```
Expected: pip show alembic now reports the pinned version.

3. Re-run autogenerate and compare against the suspect output.
```
alembic revision --autogenerate -m "describe the change"
```
Expected: the new revision contains only the genuine schema differences, without the rendering artifacts the newer version introduced.

4. Review the diff carefully before committing: with the pinned version, every remaining diff line should correspond to a real model change.
Expected: no unexplained diffs, no rendering-only noise.

5. Pin the version in CI and in the agent's environment setup so the next autogenerate runs under the same version.
Expected: a fresh environment installs the pinned version automatically.

## Use this when
- alembic autogenerate produces different output than it used to for the same models
- The installed Alembic is newer than the project's pinned version
- A generated revision contains diffs nobody can explain
- An agent's sandbox auto-installed the latest Alembic

## Not for this skill when
- The versions match and the diff is still surprising - then the models really changed, or the database drifted; investigate those
- The revision was hand-written rather than autogenerated - version skew does not affect hand-written revisions
- env.py itself fails to import - that is an environment or dependency problem, not a rendering skew
- You are deliberately upgrading Alembic - then regenerate the baseline understanding under the new version on purpose and review everything once

## Variant phrasings
- alembic autogenerate different output after upgrade
- alembic version newer than revisions, autogenerate noise
- pip installed latest alembic, autogenerate changed
- how to pin alembic version for autogenerate

## Why it happens
Autogenerate compares your models against the live database and renders the differences using the installed Alembic's comparison and rendering logic. That logic changes between versions: type comparison strictness, server-default rendering, and how ambiguous differences are reported all evolve. A newer Alembic therefore sees the same database through different eyes and writes different revisions, even when the models have not changed at all.

## Edge cases
- An env.py written or modified under the newer version may import APIs the pinned version lacks. If env.py breaks after downgrading, check it for version-specific calls.
- The suspect revision may already be committed or even applied. Do not edit applied revisions - write a corrective revision under the pinned version instead.
- Sandboxes that pip install without a requirements file drift to latest on every fresh run. Always install from the pinned requirements in automation.
- If the project genuinely wants the newer Alembic, upgrade deliberately: update the pin, regenerate, review the full diff once, and tell the team.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_9ovAD3WRyVqXk6RjDz2CBw
