Repository navigation
Conversation
🦋 Changeset detectedLatest commit: 79e20fe 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #698.
Problem
A streamed tool-call delta with an
indexbut noid, nonameand emptyarguments, such as{ index: 0, function: { arguments: "" } }, ends the call.streamTextthen reports atool-errorfor the empty input, and the call's real arguments arrive astool-input-deltaaftertool-call.Root cause
isNullFinalizationChunkinsrc/streaming.tsdidn't checkindex, so an empty fragment of the current call matched the null-finalization sentinel from #494.Change
The sentinel now also requires
tc.index == null. That's the same ruleopenAIStreamParseruses inagents/models/ai-sdk, where the comment notes that some vLLM tool parsers send empty argument fragments between real ones.Safety and compatibility
{ id: null, type: null, function: { name: null, arguments: "" } }has noindex.index, the call is closed inflush()at the end of the stream instead of eagerly. That's the behavior from before fix: emit tool-input-end eagerly for sequential tool calls #494, not a lost call.createAIdrops them. I left that out to keep this change to the one rule.Verification
should not treat an empty-arguments continuation delta as the finalization chunk. Before the fix it fails withtool-input-start, tool-input-end, tool-call, tool-error, tool-input-delta, tool-input-delta. After the fix it getsstart, delta, delta, end, tool-callwith input{ location: "London" }.pnpm --filter workers-ai-provider exec vitest --watch=false: 22 files, 455 tests passed.tsc --noEmitin the package: no errors.oxfmt --checkpasses on the changed files, andoxlintreports no errors (one existing warning attest/stream-text.test.ts:1947, not from this change).dist/, now printstool-call input="{\"city\":\"Paris\"}"for the empty-fragment case.Not verified: a live Workers AI stream. I don't have one that sends an empty fragment.
Documentation and release
Patch changeset for
workers-ai-provider.