Skip to content

Add test coverage for StreamModelWithTools and review round 3 gaps

f5b2290
Select commit
Loading
Failed to load commit list.
Open

Fix Vercel AI SDK adapter bugs from code review #132

Add test coverage for StreamModelWithTools and review round 3 gaps
f5b2290
Select commit
Loading
Failed to load commit list.
Claude / Claude Code Review completed May 11, 2026 in 11m 34s

Code review found 1 important issue

Found 6 candidates, confirmed 2. See review comments for details.

Details

Severity Count
🔴 Important 1
🟡 Nit 0
🟣 Pre-existing 1
Severity File:Line Issue
🔴 Important adapter/vercelaisdk/uimessagestream/handler.go:497-500 Early-return guard leaves stream unterminated on StreamEndEvent.Error
🟣 Pre-existing adapter/vercelaisdk/uimessagestream/handler.go:516 Assistant text/reasoning lost between tool turns

Annotations

Check failure on line 500 in adapter/vercelaisdk/uimessagestream/handler.go

See this annotation in the file changed.

@claude claude / Claude Code Review

Early-return guard leaves stream unterminated on StreamEndEvent.Error

The new early-return guard at handler.go:497-500 ('streamToolTurn already wrote finish+[DONE] on error') over-triggers: it correctly catches the iterator-error path in streamToolTurn (which does write the full terminal sequence), but it also catches StreamEndEvent.Error, where writeToolTurnEnd only writes 'error' + 'finish-step' and returns 'error'. Result: when any provider emits StreamEndEvent{Error: err} during tool-calling, the SSE stream ends with no 'finish' chunk and no '[DONE]' sentinel,

Check notice on line 516 in adapter/vercelaisdk/uimessagestream/handler.go

See this annotation in the file changed.

@claude claude / Claude Code Review

Assistant text/reasoning lost between tool turns

🟡 **Pre-existing bug** (from #131, not introduced by this PR): In `StreamModelWithTools`, text and reasoning emitted alongside a tool call in the same model turn are streamed to the client but **not** preserved in the conversation history passed to the next model turn. The assistant message at handler.go:509-514 is built solely from `toolRequests` — any preamble like "Let me check the weather..." or reasoning the model just generated is invisible to it on the next call. Fix: accumulate text/reas