Skip to content

[v5.0] reproduction: @ai-sdk/anthropic: messagestart for a different message while the - #18492

Draft
ai-sdk-factory[bot] wants to merge 1 commit into
release-v5.0from
bug-reproduction-18331-20260805213927611763
Draft

[v5.0] reproduction: @ai-sdk/anthropic: messagestart for a different message while the#18492
ai-sdk-factory[bot] wants to merge 1 commit into
release-v5.0from
bug-reproduction-18331-20260805213927611763

Conversation

@ai-sdk-factory

@ai-sdk-factory ai-sdk-factory Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Bug

@ai-sdk/anthropic: message_start for a different message while the previous message is still open is silently merged into one generation, corrupting thinking blocks and failing all subsequent requests

Reproduction

  • On release-v5.0, ai 5.0.228 and @ai-sdk/anthropic 2.0.93 accept msg_second while msg_first remains open without emitting InvalidResponseDataError.
  • examples/ai-functions/src/reproduction/issue-18331-anthropic-spliced-message-start.ts observed both signed reasoning blocks in one completed streamText step, dropped unfinished toolu_first, and completed only toolu_second; expected behavior is an explicit stream error with no completed corrupted step.
  • The same-ID duplicate emitted two response-metadata parts and replaced input-token usage from 10 with 99 instead of being ignored.
  • Sequential message_stop followed by message_start remained valid, producing two finishes without errors.
  • packages/anthropic/src/issue-18331.test.ts and fixtures under packages/anthropic/src/__fixtures__/issue-18331-*.chunks.txt preserve failing Node and Edge coverage for the malformed streams and passing coverage for sequential messages.
  • The exact Google Vertex live splice and subsequent provider 400 were not exercised because Google Vertex live-service checks are skipped by policy; Anthropic documentation confirms tool-loop thinking blocks must remain complete and unmodified and that modified blocks receive HTTP 400.

Relevant Documentation

Related Issues

Reproduces #18331

Co-authored-by: Gregor Martynus <39992+gr2m@users.noreply.github.com>
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