Skip to content

Conversation

@petrbrzek
Copy link
Member

@petrbrzek petrbrzek commented Nov 26, 2025

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.

  • Breaking: Vercel AI SDK v5 migration
    • Requires @ai-sdk/provider@2.0.0, @ai-sdk/provider-utils@3.0.1, and ai@^5.
    • Drops SDK v4 support; version bumped to 1.0.0.
  • Vercel AI Provider
    • Refactor vercel-ai/langtail-language-model.ts to V2 API (stream parts, usage fields, tool I/O, reasoning preservation/signatures).
    • Update convert-to-openai-chat-messages.ts for V2 prompt/content (file->image handling, tool results, cache control).
    • Update openai-prepare-tools.ts and map-langtail-finish-reason.ts for v5 formats.
    • Remove deprecated map-openai-chat-logprobs.ts.
  • Schemas/Types
    • Switch to zod/v4; adjust records and schemas in schemas.ts, dataSchema.ts, reasoning-details-schema.ts.
  • Playground
    • Add playground/openrouter.ts; update playground/vercel.ts to v5 tools/content mapping.
  • Tests
    • Add extensive specs for message conversion and language model reasoning/streaming.

Written by Cursor Bugbot for commit e1ff550. This will update automatically on new commits. Configure here.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ?? "",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Fix in Cursor Fix in Web

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.
@petrbrzek petrbrzek merged commit 3a9d50c into main Nov 27, 2025
3 checks passed
type: "text-delta",
delta: delta.content,
id: textId!,
})
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Fix in Cursor Fix in Web

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