Skip to content
stacks

Why AI agents install outdated packages

Coding agents pin old versions and call renamed APIs because they write from training data. Four fixes, and a project brief that stops pinning from memory.

Published 5 min read

AI coding agent outdated packages come from training data. The agent writes the versions and APIs it learned, and every model's training stops before the newest releases. The reliable fix is to make the project the source of truth for versions. Let the package manager choose them, have the agent read the installed types and current docs before it calls an API, and add a check that fails when a recorded fact and the installed version disagree.

Why do AI coding agents install outdated packages?

A model has no way to see the registry unless it is given a tool that does. It remembers package versions and API shapes from the code it was trained on, in proportion to how often they appeared. A release from last month has almost no presence in that data, and the major version before it has years of examples. So the agent's default is the older, more familiar form.

This shows up as two separate failures that need different fixes. In the first, the agent writes a version number into package.json from memory: "tailwindcss": "^3.4.0" in a project started after Tailwind 4 shipped. The project works, but it begins on an old major version.

In the second, the version is right and the code is wrong for it. Tailwind 4 loads with one @import "tailwindcss" line, and its upgrade guide says the three @tailwind directives from version 3 are no longer used. An agent that remembers version 3 writes the directives anyway, in a project whose installed package is version 4. Renamed config keys, changed CLI flags and functions that moved between packages fail the same way.

A lockfile doesn't fix either one. It records what was installed, which keeps builds repeatable. It says nothing to the agent about which API that version has.

Fix 1: let the package manager choose the version

Tell the agent never to type a version number into a manifest. It runs the install command, and the package manager writes whatever the registry currently serves.

Terminal
npm install tailwindcss
npm ls tailwindcss
npm view tailwindcss version

npm ls prints the installed version and npm view prints the latest published one. If they differ right after an install, something is holding the old version back, often an overrides entry, a peer dependency range or an engines mismatch. Other ecosystems have the same checks: pnpm ls and pnpm view, pip list --outdated, and go list -m -u all.

Fix 2: read the installed types before calling an API

The type declarations in node_modules match the installed version exactly, which makes them the most reliable reference the agent has. A generator's --help output and the documentation for the major version in your lockfile work the same way. Ask for this directly: "Before writing config for a package, read its installed type declarations or its --help, and check its documentation for the installed major version."

If your agent supports MCP, a documentation server that fetches current docs on request gives it a third source. Tell the agent to look things up when it writes the code and not after a build fails.

Fix 3: record the version a note was verified against

Version-specific notes in AGENTS.md go stale quietly. "We use React 18" is wrong the day someone upgrades, and nothing tells the agent. A note that carries the version it was checked against can be tested. Put the version on the first line of the notes file, then fail CI when it no longer matches what is installed:

check-notes.sh
v=$(node -p "require('tailwindcss/package.json').version")
head -n 1 docs/tailwind-notes.md | grep -qxF "Verified against tailwindcss $v"

node -p reads the installed version, head -n 1 takes the file's first line, and grep -qxF demands an exact match. With Verified against tailwindcss 4.1.0 on the first line and 4.1.0 installed, the script exits 0. After an upgrade to 4.2.0 it exits 1 until someone rechecks the notes and updates the line.

stacks uses this pattern in its effect fragment. The brief has the agent write an API reference for the installed Effect release, and a verify step named effect-api-reference fails when the reference's first line names a different version than the one installed.

Fix 4: make upgrades a task of their own

Combining an upgrade with a feature hides both. A diff that adds a page and bumps a major version leaves you unable to tell which change broke the build. Run npm outdated to see what has moved, then give the agent one package at a time with a clear instruction: update it, read the release notes, fix what breaks, and run the full test suite. A bot such as Dependabot or Renovate can open the pull requests, and each one runs your CI if you have it set up for pull requests.

How does stacks keep agents from pinning versions?

A stack records the parts of a project that stay true for years, such as layout, test approach and the definition of done. It leaves out anything that changes every few months. stacks writes no version numbers into a stack. It names packages by role, and the generated brief tells the agent to install the current release. This is what the go-cli stack lists for dependencies:

stacks show go-cli
Dependencies (cli): github.com/spf13/cobra, github.com/spf13/viper, golang.org/x/term, go.yaml.in/yaml/v3
Dependencies (test): github.com/stretchr/testify

Two of the lines in the Versions section of a TypeScript CLI brief:

.stacks/BRIEF.md
- Nothing here pins a version, on purpose. Let the package manager resolve the latest stable versions that work together; don't pin from memory.
- Check current docs, `--help` and the installed types before writing config or calling an API; flags and config keys change between releases.

Then stacks verify runs the project's lint, typecheck and test steps, so an agent that wrote against an old API finds out when the build fails. That catches code that breaks. It doesn't catch a deprecated call that still compiles, so read the diff for those. stacks show <id> prints the packages, tools and checks a stack will ask for before you create anything.

Agent + stacks
Demo

You: Show me the build instructions and checks before we implement the log tool.

Agent: I’ll preview the composed brief first.

●Bash(stacks validate --brief go-cli --sandbox)
# Build project: Go CLI
## Your job
## Decisions
## Dependencies and tools
## Stack: Go CLI (`go-cli`)
## Fragment: AGENTS.md and agent guardrails (`agent-ops`)
## Fragment: GitHub Actions CI (`ci-github`)
## Fragment: Git hooks (lefthook) (`git-hooks`)
Output abbreviated

Agent: The brief includes stack guidance and each fragment’s instructions. Its definition of done lists the checks.

You: Where are those checks recorded for the project?

●Bash(cat log-scan/.stacks/BRIEF.md)
## Definition of done
| Step | Phase | Layer |
|---|---|---|
| `install` | setup | install |
| `build` | check | build |
| `lint` | check | lint |
| `test` | check | test |
Output abbreviated
●Bash(cat log-scan/.stacks/manifest.json)
"verify": [
"name": "install",
"run": "make install",
"phase": "setup",
"name": "lint",
"run": "make lint",
"name": "test",
"run": "make test",
Output abbreviated

Agent: The generated brief lists the steps; .stacks/manifest.json records their commands. I’ll implement against those checks and use stacks verify to run them.

Example agent conversation. Playback can be paused.

Previewing a Go CLI brief, then inspecting the verify steps and commands recorded for the same composition.