Skip to content

@ai-sdk/anthropic 3.0.71 rejects usage.iterations[].type: "fallback_message" — turn fails with AI_TypeValidationError #31579

Closed

Description

@moynzzz

Description

The bundled @ai-sdk/anthropic@3.0.71 validates usage.iterations[].type as "compaction" | "message". Anthropic now emits "fallback_message" when a response is served by a fallback model (new fallbacks API parameter, e.g. claude-fable-5 → opus). The whole message_delta fails validation and the turn errors out — the assistant can't continue while fallbacks occur.

AI_TypeValidationError: Type validation failed
path: ["usage","iterations",1,"type"]
expected "compaction" | "message", received "fallback_message"
"iterations": [
  { "type": "message", "model": "claude-fable-5", ... },
  { "type": "fallback_message", "model": "claude-opus-4-8", ... }
]

Fixed upstream in vercel/ai#15928, released in @ai-sdk/anthropic@3.0.82 — bumping the pin resolves it.

OpenCode version

1.16.2

Steps to reproduce

  1. Use the Anthropic provider with a model where the API serves a fallback (claude-fable-5 with opus fallback)
  2. Response usage.iterations contains an entry with type: "fallback_message"
  3. Stream fails validation; error repeats on retry while the fallback persists

Operating System

Ubuntu 24.04 (WSL2)

Activity

  1. moynzzz commented on Jun 10, 2026

    @moynzzz
    Author

    A few findings for whoever picks this up:

    • Timing: bunfig.toml sets minimumReleaseAge = 259200 (3 days) and @ai-sdk/anthropic is not in minimumReleaseAgeExcludes. 3.0.82 was published 2026-06-09 17:24 UTC, so it can't resolve before 2026-06-12 ~17:25 UTC. Verified locally that the gate also fires with an already-updated lockfile, so a bump PR before that date fails bun install.
    • Pins live in three workspaces: packages/opencode (3.0.71), packages/core (3.0.71), packages/console/function (3.0.64). Both packages/opencode/src/provider/provider.ts and packages/core/src/plugin/provider/anthropic.ts import the provider, so the CLI path needs at least those two bumped.
    • Pre-validation: with the age gate locally overridden, bumping packages/opencode to 3.0.82 regenerates the lockfile cleanly and tsgo --noEmit passes.

    Happy to send the bump PR once the release-age window opens on the 12th.

  2. kagura-chen commented on Jun 10, 2026

    @kagura-chen
    Contributor

    I can take this — straightforward bump of @ai-sdk/anthropic from 3.0.71 to 3.0.82 which includes the fallback_message iteration type fix (vercel/ai#15928).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions