How to stop a coding agent from writing retired model IDs
Updated November 26, 2026
On this page
Why do coding agents write retired model IDs?
Because they write from memory, and their memory stops at a training cutoff while models keep retiring after it. An ID that was everywhere in the code an agent learned from is the ID it reaches for first.
The dates make the gap concrete. The Claude models overview lists a training data cutoff of June 2026 for the current Claude models (Claude docs, checked Nov 26, 2026). OpenAI shut down gpt-4-0613 and gpt-4 on October 23, 2026 (OpenAI deprecations), and the Claude API retires claude-sonnet-4-5-20250929 on November 30, 2026 (Claude model deprecations). An agent trained before those notices has no reason to think the old IDs are a problem.
The second source is your own repo. Agents copy patterns from the files they read, so one old ID in a test fixture, a README or a dead script gets copied into new code. And the cost is real: the Claude docs say plainly that requests to retired models fail (Claude model deprecations).
What's the fastest way to stop it?
Put five guardrails in place, cheapest first. The first two tell the agent what to do; the last three check that it did. Instructions alone don't hold over a long session, so I wouldn't stop at step 2.
- Keep every model ID in one file, such as src/models.ts, and import it everywhere else.
- List the current IDs and that rule in AGENTS.md or CLAUDE.md.
- Give the agent a tool that looks an ID up before it writes one.
- Block a write that puts an ID outside the models file, with a hook.
- Fail CI when an ID appears outside that file, or when an ID inside it has retired or retires soon.
| Guardrail | What it stops | What it misses |
|---|---|---|
| One models file | IDs scattered across the codebase | Nothing by itself; the checks rely on it |
| AGENTS.md or CLAUDE.md | Most guesses, at the moment of writing | An agent that ignores or forgets it |
| MCP lookup | A retired or retiring ID, with its replacement | Calls the agent never makes |
| Claude Code hook | Any ID written outside the models file | Edits made by hand or by other tools |
| CI check | Everything that reaches a pull request | Nothing that reaches review, but it fires last |
Where should model IDs live in your code?
In one file that nothing else duplicates. It gives you one place to change an ID, one place for the agent to read, and one place for every check below to look:
// src/models.ts
// Every model ID the app calls. Nothing else.
export const MODELS = {
chat: "claude-sonnet-5-5",
fast: "claude-haiku-5-5",
} as const// src/summarize.ts
import { MODELS } from "./models"
export const model = MODELS.fastBoth IDs are the current ones on the Claude models overview, which also notes that every Claude model ID is a pinned snapshot, including the dateless IDs used from the 4.6 generation on (Claude docs). So a dateless ID can still retire. I pin snapshots in production and change them on purpose, in this one file, with tests.
If you need to switch models per environment, read an environment variable inside this file and fall back to the constant. Don't let model IDs leak into config files all over the repo, or the checks below have nothing reliable to read.
What should AGENTS.md or CLAUDE.md say about model IDs?
Say where IDs live, which IDs are current with the date you checked, how to look one up, and not to copy old ones. Short and exact beats a paragraph of advice. This is the block I used in the test repo:
## AI model IDs
- Every model ID lives in src/models.ts.
Import MODELS from there. Never type an
ID in any other file.
- Current IDs, checked 2026-11-26:
claude-sonnet-5-5 and claude-haiku-5-5.
- Before you add or change an ID, look it
up with the check_code tool.
- Never copy an ID from old code, tests or
docs. It may have retired.Put it in the file your agent actually reads. They don't all read the same one:
- Claude Code reads AGENTS.md when there's no CLAUDE.md in your working directory or above it. If both exist, it reads only CLAUDE.md, unless CLAUDE.md imports AGENTS.md. Reading AGENTS.md directly needs Claude Code v2.1.277 or later (Claude Code docs).
- Codex reads AGENTS.md, and in each directory it checks for AGENTS.override.md first (Codex docs).
- Cursor reads an AGENTS.md in the project root as a plain alternative to rules in .cursor/rules, where a rule file needs the .mdc extension (Cursor docs).
Date the list and refresh it when you change models. A list of current IDs that nobody updates becomes the next list of retired IDs.
How can the agent check a model ID before it writes one?
Connect an MCP server that knows model retirement dates, and tell the agent to call it before writing an ID. The agent then asks instead of guessing, and gets the replacement in the same answer.
Since.dev's MCP server has a check_code tool that takes a model ID. On Nov 26, 2026 I asked it about claude-sonnet-4-5-20250929. It answered affected, retirement 2026-11-30 on the Claude API, replacement claude-sonnet-5-5, and listed 12 things that work differently on the replacement, the first being that thinking runs by default on requests that send no thinking field. That last part matters: a new ID is often more than a find and replace. The Claude Code quickstart has the one-line setup.
LLMIntel runs another one, with a check_model tool and four others, no key and no account, per its own page (llmintel.ai, read Nov 26, 2026). Whichever you use, test it once with an ID you know has retired, and make sure an error from the server doesn't read as "fine" to your agent.
A lookup only helps when the agent calls it. That's why the next two steps don't depend on the agent's cooperation.
How do you block a retired model ID with a Claude Code hook?
Add a PreToolUse hook on Write and Edit that exits with code 2 when the new text holds a model ID outside src/models.ts. PreToolUse runs before the tool call, exit code 2 blocks it, and your stderr becomes the message Claude sees (Claude Code hooks reference). Register it in .claude/settings.json:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Write|Edit",
"hooks": [
{
"type": "command",
"command":
"$CLAUDE_PROJECT_DIR/.claude/hooks/model-ids.sh"
}
]
}
]
}
}The script reads the tool input from stdin. For Write the new text is in tool_input.content, and for Edit it's in tool_input.new_string (same reference):
#!/bin/sh
# Block a Write or Edit that puts a model ID in
# any code file except src/models.ts.
input=$(cat)
file=$(printf '%s' "$input" \
| jq -r '.tool_input.file_path // ""')
case "$file" in
*/src/models.ts) exit 0 ;;
*.ts|*.tsx|*.js|*.py|*.go) ;;
*) exit 0 ;;
esac
text=$(printf '%s' "$input" | jq -r \
'.tool_input.content // .tool_input.new_string')
pat='(gpt-[0-9]|claude-[0-9a-z]|gemini-[0-9]|o[1-4]-mini)'
if printf '%s' "$text" | grep -qE "$pat"; then
echo "Model IDs live in src/models.ts." >&2
echo "Import MODELS from there instead." >&2
exit 2
fi
exit 0I tested it by feeding it the JSON shape the hooks reference documents, once for a Write that types a retired ID and once for an Edit that imports from the models file:
$ .claude/hooks/model-ids.sh < write.json
Model IDs live in src/models.ts.
Import MODELS from there instead.
$ echo $?
2
$ .claude/hooks/model-ids.sh < edit.json
$ echo $?
0write.json held a Write to src/chat.ts with gpt-4o-2024-08-06 in its content; edit.json held an Edit whose new text was MODELS.chat. Tune the pattern to the providers you call. It's deliberately simple, so it also catches an ID that's current; that's the point, since the only file allowed to hold one is src/models.ts. Cursor has hooks too, including preToolUse, where exit code 2 blocks the action (Cursor hooks docs), but its input differs, so adapt the script rather than copying it.
How do you fail CI when a retired model ID gets in?
Run two scripts in CI: one fails on any ID outside the models file, the other fails when an ID inside it has retired or retires soon. Together they catch what the hook can't see, like edits from other tools or other people. The first one uses git grep:
#!/bin/sh
# Fail when a model ID appears outside src/models.ts.
pat='(gpt-[0-9]|claude-[0-9a-z]|gemini-[0-9]|o[1-4]-mini)'
hits=$(git grep -nE "$pat" -- 'src/*' ':!src/models.ts')
if [ -n "$hits" ]; then
echo "Model IDs outside src/models.ts:"
echo "$hits"
exit 1
fi
echo "OK: model IDs only in src/models.ts"$ ./scripts/check-model-ids.sh
Model IDs outside src/models.ts:
src/legacy.ts:1:export const model = "gpt-4-0613"
$ echo $?
1The second reads Since.dev's free calendar API, which needs no key (API docs), and fails on any ID in src/models.ts that the calendar lists as retired, or as retiring within 90 days. The 90 days is a suggestion; raise it if your releases are slow. It writes the feed to a file and uses set -e, so an unreachable API fails the job instead of passing it:
#!/bin/sh
# Fail when an ID in src/models.ts retired in the
# last 90 days or retires in the next 90.
set -e
curl -sf https://api.since.dev/v1/calendar \
-G -d kind=model -d limit=500 > calendar.json
grep -oE '"[A-Za-z0-9.:@/-]+"' src/models.ts \
| jq -s . > ids.json
jq -r --slurpfile ids ids.json '
.entries[]
| select(.daysLeft <= 90)
| select(.modelId as $m
| $ids[0] | any(.[]; . == $m))
| "\(.modelId) \(.date) \(.platformName // "API")"
' calendar.json > hits.txt
if [ -s hits.txt ]; then
echo "Retired or retiring model IDs:"
cat hits.txt
exit 1
fi
echo "OK: no retiring model IDs"With the current IDs it printed OK: no retiring model IDs. Then I put an OpenAI ID that has shut down and a Claude ID four days from retirement in src/models.ts:
$ ./scripts/check-retiring.sh
Retired or retiring model IDs:
gpt-4-0613 2026-10-23 API
claude-sonnet-4-5-20250929 2026-11-30 API
$ echo $?
1One limit to know: on Nov 26, 2026 the calendar's model entries started at 2026-08-28, so an ID retired before that won't show up in the second script, and the first script allows any ID inside src/models.ts. Look up each ID once when you add it to that file, by hand or with the lookup above. For the dates themselves, the OpenAI calendar and Claude calendar list each model by platform.
Can ESLint or Ruff catch model IDs?
ESLint can; Ruff's banned-api rule can't. ESLint's no-restricted-syntax takes AST selectors with a custom message (ESLint docs), so a selector on string literals flags IDs right in the editor, where the agent sees it as a lint error:
// eslint.config.js
const ID = /^(gpt-|claude-|gemini-|o[1-4]-)/
export default [
{
files: ["src/**/*.js"],
ignores: ["src/models.js"],
rules: {
"no-restricted-syntax": [
"error",
{
selector: `Literal[value=${ID}]`,
message: "Import model IDs from src/models.js.",
},
],
},
},
]I ran it with ESLint 10.15.0 on a file that imports one ID and types two (gpt-4-0613 on line 4, o3-mini on line 5), with the JSON output trimmed by jq:
$ npx eslint src -f json \
| jq -r '.[].messages[]
| "\(.line):\(.column) \(.message)"'
4:18 Import model IDs from src/models.js.
5:18 Import model IDs from src/models.js.This selector checks plain string literals only. An ID inside a template literal needs a second selector on TemplateElement.
For Python, Google's AI Overview for this query suggests Ruff's banned-api rule (TID251). Ruff's own docs describe that rule as checking for banned imports (Ruff docs), so it won't flag a model ID in a string. Use the git grep script above for Python, Go and anything else.
Where Since.dev fits
Since.dev covers steps 3 and 5: the check_code lookup your agent calls, and the free calendar API the CI script reads. To find the model IDs already in a codebase, scan a public repository with no account, or paste code into the model retirement checker. From the command line, npx since-dev owner/repo does the same for a public GitHub repository (CLI quickstart). On Nov 26, 2026 it found gpt-3.5-turbo, retired on the OpenAI API on 2026-10-23, at examples/assistant-basic/assistant.py:14 in openai/openai-quickstart-python. A local folder with no public GitHub remote gets only its manifests and lockfiles checked. Connect the repository and you hear when an ID it calls is about to retire, and you can get a fix pull request that moves it to the replacement. It reports and opens pull requests for your review; nothing merges or deploys.
Questions
Why does my coding agent keep using old model names?
It writes model IDs from its training data, which stops at a cutoff, and providers retire models after that. Old IDs in your own repo, in tests, docs or old scripts, also get copied into new code. Give it the current IDs in AGENTS.md or CLAUDE.md and a lookup tool, then check what it writes.
Does putting model IDs in CLAUDE.md or AGENTS.md work?
It helps, and it's the cheapest step, but it's advice the agent can ignore or lose over a long session. Keep the list short, dated and next to the rule that IDs live in one file. Then enforce that rule with a hook, a lint rule or a CI check.
What happens when code calls a retired model?
The request fails. The Claude model deprecations page says requests to retired models fail (Claude docs), and OpenAI lists shut-down models with their replacements on its deprecations page. Nothing falls back for you, so the feature that called the model stops working.
Can a Claude Code hook block a model ID?
Yes. A PreToolUse hook on Write and Edit reads the new text from tool_input.content or tool_input.new_string, and exiting with code 2 blocks the tool call. Claude sees your stderr as the reason, so tell it where IDs belong, such as src/models.ts.
Should I use a model alias or a pinned model ID?
Pin the ID in production and change it on purpose, in one file, with tests. On the Claude API every model ID, including the dateless ones from the 4.6 generation on, is a pinned snapshot, so a dateless ID can still retire. Either way, a check that reads your models file tells you before it does.
Related guides
Free tools
- AI model retirement checker: paste code, get datesFind code that uses retiring AI models: paste code or model IDs and see when each shuts down on OpenAI, Claude, Gemini, Azure, Bedrock and Vertex. Free.
Quickstarts
- Claude Code quickstart: check what changed in your codeAdd Since.dev to Claude Code with the plugin or one command, sign in with OAuth, and ask what changed in your packages, AI models and runtimes.
- CLI quickstart: find what is about to stop workingRun npx since-dev in any repository to see every AI model ID, runtime and dependency with an end date: the file, the line, the days left and the replacement.
Comparisons
- How to know when an AI model you use is retiringAI model deprecation calendars and feeds compared: provider pages, platform schedules, free trackers, scripts, and how to find model IDs in your code.
- Context7 alternatives: which docs MCP server should your agent use?Context7 alternatives for coding agents: GitMCP, DeepWiki MCP, Ref and mcpdoc on price, keys and private docs, each asked the same upgrade question.

Put your code on continuous maintenance.
Scan a public repository now, or give your agent one line.
See how out of date your code is.
Tell your agent what changed since it was trained.
claude mcp add --transport http since https://api.since.dev/mcpCodex, Cursor and any MCP client use https://api.since.dev/mcp.