Skip to content

fix: drop retired Claude models and validate model server-side - #250

Open
travismarceau wants to merge 1 commit into
mainfrom
fix/retired-claude-models
Open

travismarceau wants to merge 1 commit into
mainfrom
fix/retired-claude-models

Conversation

@travismarceau

Copy link
Copy Markdown

Why

Anthropic reports that the artifacts.e2b.dev key is still sending requests to claude-3-7-sonnet-latest, which was retired on 2026-02-19. These requests fail with not_found_error; there were 3 on 2026-09-27.

The ID was removed from lib/models.json in 86b5f52, but /api/chat and /api/morph-chat use the model object sent by the client without checking it. The client resets a saved model only when the page loads, so stale tabs, cached pages, and scripts calling the API directly still reach retired models.

What

  • Server-side validation: resolveModel() in lib/models.ts looks up the requested ID in models.json and falls back to the default model (with a console.warn) when the ID isn't listed. Both API routes now use it.
  • One alias per Anthropic family: claude-opus-4-6, claude-sonnet-4-6, claude-haiku-4-5. These aliases pick up new snapshots within their family.
    • Removed as retired: claude-3-5-haiku-latest (2026-02-19) and claude-opus-4-1-20250805 (2026-08-05).
    • Removed as deprecated: claude-opus-4-20250514 and claude-sonnet-4-20250514.
    • Replaced by the aliases above: the dated Opus 4.5, Sonnet 4.5, and Haiku 4.5 IDs.
  • Single default: the default model is defined once in lib/default-model.ts. It's a separate file so the client page doesn't bundle every provider SDK.

Non-Anthropic entries are unchanged.

Why not Sonnet 5 / 5.5

[email protected] + @ai-sdk/[email protected] always send temperature: 0 and tool_choice: {type: "tool", name: "json"} for streamObject / generateObject (confirmed by capturing the request body). Sonnet 5 and Opus 5 reject temperature, and the 5.5 models also reject forced tool_choice. Moving to the 5.x models needs an AI SDK upgrade, which should be a separate PR.

Verification

  • tsc --noEmit, next lint, and next build pass. Lint warnings are unchanged from main.
  • Offline harness with a mocked fetch:
    • claude-3-7-sonnet-latest, claude-3-5-haiku-latest, claude-opus-4-1-20250805, and a missing ID resolve to claude-sonnet-4-6.
    • claude-opus-4-6, claude-haiku-4-5, and gpt-4o pass through unchanged.
    • The captured Anthropic request for claude-3-7-sonnet-latest sends model: "claude-sonnet-4-6".
  • Not yet verified: a live call against the Anthropic API. Please try one prompt on each of the three Claude models in the preview deployment.

🤖 Generated with Claude Code

Anthropic reports requests from Fragments to claude-3-7-sonnet-latest,
retired 2026-02-19. The ID was removed from models.json in 86b5f52, but
/api/chat and /api/morph-chat trust the model object sent by the client,
so stale tabs and scripts still reach retired models.

- Resolve the requested model against models.json on the server and fall
  back to the default when it is not listed.
- Replace the Anthropic entries with one alias per family:
  claude-opus-4-6, claude-sonnet-4-6, claude-haiku-4-5. Removes retired
  claude-3-5-haiku-latest and claude-opus-4-1, and deprecated Opus 4 /
  Sonnet 4.
- Define the default model once (lib/default-model.ts).

Sonnet 5+ is not included: ai@3 always sends temperature: 0 and a forced
tool_choice for streamObject/generateObject, which those models reject.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@vercel

vercel Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
fragments Ready Ready Preview Sep 28, 2026 7:20pm UTC

Request Review

This branch was successfully deployed

1 active deployment
Preview — ea06efcd Deployed Sep 28, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant