Skip to content

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

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)

No activity

Activity on this issue will appear here.

Activity

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