Skip to content

Conversation

@sixlive
Copy link
Contributor

@sixlive sixlive commented Jan 28, 2026

Description

DataProtocolAdapter::handleArtifact() emitted artifact events with type: "artifact", which fails Zod validation in @ai-sdk/react v2's useChat. The AI SDK only accepts custom data parts with a data- prefix.

Changes

  • Changed artifact event type from artifact to data-artifact
  • Nested the payload (toolCallId, toolName, artifact) under a data key, matching the convention already used by handleDefault()
  • Updated Vercel AI SDK documentation example to reflect the new format
  • Added test verifying the data-artifact type and nested structure

Breaking Change

Consumers parsing the raw stream need to update artifact handling:

- if (data.type === 'artifact') {
-     artifacts.set(data.toolCallId, data.artifact);
+ if (data.type === 'data-artifact') {
+     artifacts.set(data.data.toolCallId, data.data.artifact);
  }

@sixlive sixlive merged commit 7ebf450 into main Jan 28, 2026
17 of 42 checks passed
@sixlive sixlive deleted the fix-artifact-broadcasting branch January 28, 2026 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants