Repository navigation
fix(server-utils): Keep Workers AI streamed tool calls that have no index - #25835
Open
pcbeingused333 wants to merge 1 commit into
Open
pcbeingused333 wants to merge 1 commit into
pcbeingused333 wants to merge 1 commit into
Conversation
…ndex Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
pcbeingused333
requested review from
isaacs and
mydea
and removed request for
a team
October 28, 2026 15:41
RulaKhaled
self-requested a review
October 29, 2026 13:33
This branch has not been deployed
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.
Why: The Workers AI streaming instrumentation (
accumulateStreamingToolCalls) keyed every tool-call delta bytoolCall.index ?? 0. OpenAI-compatible endpoints that omitindexand send each parallel call whole in its own chunk therefore ended up as a single call: the first call's id and name, with the arguments of every call concatenated, and the other calls missing fromgen_ai.response.tool_callsandgen_ai.output.messages. Same situation #25622 fixed for the OpenAI instrumentation.Tool calls with a numeric
indexare grouped by it exactly as before. A delta without a usableindex(missing ornull) is kept in a separate list, in arrival order, so it can never collide with a real index: a delta whoseidis already known continues that call, a newid(or a function name without anid) starts a new call, and anything else, such as an arguments fragment with neither, continues the latest one. Native and indexed streams (including the top-levelname/argumentsshape) behave as before.How to review:
getUnindexedToolCalland theToolCallAccumulatorsplit inpackages/server-utils/src/ai/workers-ai/streaming.ts; the three new cases inworkers-ai-streaming.test.ts(two parallel calls without an index stay separate, argument fragments of one unindexed call are merged, an unindexed call does not merge into an indexed call atindex: 0). The first and third fail without the change; the wholetest/ai/lib/tracingfolder passes.Unsure about: whether an unindexed delta with neither
idnor name should continue the latest call (chosen here, mirrors #25622) or be dropped.Closes: no linked issue; same class of bug as #25622.
This change was prepared with the assistance of an AI coding agent (Claude).