Repository navigation
fix(ai-anthropic): decode replies a fallback model took over - #8971
Merged
Merged
Conversation
With server-side fallback (the `fallbacks` request field), the API can hand a refused reply to a fallback model. It then returns a `fallback` content block (from, to, trigger) and reports usage with `fallback_message` iterations and a `model` on each iteration. None of these were in the generated schemas, so such replies failed to decode. - Generated.ts (by hand, mirroring @anthropic-ai/sdk beta/messages): BetaResponseFallbackBlock (in BetaContentBlock and content_block_start), BetaFallbackMessageIterationUsage, optional `model` on BetaMessageIterationUsage. - The fallback block becomes a response-metadata part naming the fallback model, with the block in metadata.anthropic.fallback (streamed and non-streamed).
🦋 Changeset detectedLatest commit: 5db9e93 The changes in this PR will be included in the next version bump. This PR includes changesets to release 32 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|
1 of 5 tasks
This branch had an error being deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type
Description
With server-side fallback, the Messages API can hand a refused reply to a fallback model.
@effect/ai-anthropicfailed to decode those responses in bothgenerateTextandstreamText.fallbackcontent block andfallback_messageusage iterations to the response schemas.response-metadatapart, with the fallback model inmodelIdand the block inmetadata.anthropic.fallback.modelfield on usage iterations. It is required onfallback_messageiterations and optional onmessageiterations, because older responses and gateways may omit it. Acodegen.ymlpatch keeps it optional on regeneration.The schemas follow the last published upstream spec (2026-09-02). In that spec the fallback
triggeris required and itstypeisrefusal.Scope and limitations
Request-side
fallbacksconfiguration is not supported. History replay across a fallback boundary is not supported either. Assistant history drops the fallback block but keeps the content that came before it, so multi-turn conversations that went through a fallback are not safe to replay.Upstream spec discovery is still broken:
.stats.ymlno longer hasopenapi_spec_url. Fixing discovery and doing a full regeneration are separate work.Validation
test/AnthropicLanguageModel.test.ts: 46 pass. Both new tests fail without the decoding changes.oxlint,dprint check, andpnpm jsdocs --checkpass.test/AnthropicClient.test.tsstill fails to load because./internal/errorsis not exported. It fails the same way onmain.Closes EFF-1902