Conversation
There was a problem hiding this comment.
This PR is being reviewed by Cursor Bugbot
Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
| argsTextDelta: toolCallDelta.function.arguments ?? "", | ||
| type: "tool-input-delta", | ||
| id: toolCall.id, | ||
| delta: toolCallDelta.function.arguments ?? "", |
There was a problem hiding this comment.
Bug: Tool input events emitted with empty delta
For existing tool calls, tool-input-start and tool-input-delta are emitted unconditionally, even when the current chunk has no arguments (toolCallDelta.function.arguments is null/undefined). This creates inconsistency with the initial tool call handling (lines 771-784) which only emits these events when arguments.length > 0. The code emits tool-input-delta with an empty string when arguments are missing, and starts input tracking prematurely before any actual input arrives.
BREAKING CHANGE: This version requires @ai-sdk/provider v2.0.0 and @ai-sdk/provider-utils v3.0.1. Previous versions of Vercel AI SDK (v4) are no longer supported.
| type: "text-delta", | ||
| delta: delta.content, | ||
| id: textId!, | ||
| }) |
There was a problem hiding this comment.
Bug: Missing text-end event before tool calls start
When tool calls begin in the stream, there's no logic to emit text-end if text streaming was active. The code ends reasoning before text starts (lines 695-700), but doesn't end text before tool calls start. This breaks the V2 stream protocol which requires properly paired start/end events. Text streaming will remain "open" until the flush handler runs, causing protocol violations when tools are called after text content.
Note
Migrates to Vercel AI SDK v5 (provider v2) with a refactored V2 language model, updated message/tool handling, and comprehensive tests; drops v4 support.
@ai-sdk/provider@2.0.0,@ai-sdk/provider-utils@3.0.1, andai@^5.1.0.0.vercel-ai/langtail-language-model.tsto V2 API (stream parts, usage fields, tool I/O, reasoning preservation/signatures).convert-to-openai-chat-messages.tsfor V2 prompt/content (file->image handling, tool results, cache control).openai-prepare-tools.tsandmap-langtail-finish-reason.tsfor v5 formats.map-openai-chat-logprobs.ts.zod/v4; adjust records and schemas inschemas.ts,dataSchema.ts,reasoning-details-schema.ts.playground/openrouter.ts; updateplayground/vercel.tsto v5 tools/content mapping.Written by Cursor Bugbot for commit e1ff550. This will update automatically on new commits. Configure here.