convert internal AI SDK stream events to UIMessageStreamPart format#678
convert internal AI SDK stream events to UIMessageStreamPart format#678whoiskatrin merged 2 commits intomainfrom
Conversation
…fix error handling in useAgentChat by wrapping controller.close() in try-catch
🦋 Changeset detectedLatest commit: 447088b The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Convert internal AI SDK stream events to UIMessageStreamPart format.
Claude Code ReviewSummary: This PR properly fixes the AI SDK v5 stream event incompatibility described in issue #677. The implementation is clean and addresses the root cause. Issues Found1. Type safety issue in event transformation (ai-chat-agent.ts:1232-1236) The destructuring assumes finishReason is a string, but the AI SDK defines it as a union type. While this works at runtime, the cast is misleading. Consider using 'finishReason: unknown' for accuracy. 2. Missing test coverage The existing test file (react-tests/use-agent-chat.test.tsx) does not cover:
This is a critical bug fix that should have tests to prevent regression. What Works Well
The PR is solid overall. The type safety issue is minor, but missing test coverage is a real gap for a bug fix. |
commit: |
Claude Code ReviewFix for AI SDK v5 stream event compatibility This PR correctly addresses the type mismatch between AI SDK internal LanguageModelV3StreamPart and the UIMessageStreamPart format expected by the frontend. Issues Found1. Potential data loss in event transformation (ai-chat-agent.ts:1233) The destructuring with type assertion may drop properties if data has additional fields beyond the assertion. Consider being more explicit about which properties to preserve. 2. Missing test coverage No tests added for the stream event transformation logic. Given this fixes issue 677, tests would prevent regression:
3. Silent error suppression (ai-react.tsx:260, 290) Empty catch blocks suppress all controller.close errors. Could hide unexpected issues worth logging for debugging. SummaryCore fix is sound. Main concerns: test coverage and error suppression breadth. |
No description provided.