Repository navigation
Conversation
🦋 Changeset detectedLatest commit: 86283e6 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 |
Workers AI models can emit the same deterministic tool_call id for every call in a step (cloudflare#526/cloudflare#527). The streaming path already replaces provider ids with generated ones; the non-streaming fallback still forwarded tc.id raw, so multi-tool-call responses collided. Mirror the streaming path's generateId("chatcmpl-tool") replacement and add a regression test.
326645e to
86283e6
Compare
|
Rebased onto current @mattzcarey, I saw your structural truncation fix in cloudflare/agents#2224. Since you work on this corner of the tool-output handling, would you be up for a look at this one? Also, a side question if you don't mind: I'm talking with the Developer Tooling team soon. If you're close to that group, what are they spending most of their time on right now? |
The non-streaming fallback in
WorkersAiTextAdapter.chatStream(used when a model rejectsstream: true, e.g. GPT-OSS) forwards the provider's rawtc.idastoolCallId. Workers AI models can emit the same deterministic tool_call id for every call in a step, as documented in #526 and #527 and already fixed for the streaming path in this adapter and in workers-ai-provider. When the fallback response contains multiple tool calls, the duplicate ids collide downstream.This mirrors the streaming branch's existing pattern: replace the provider id with
generateId("chatcmpl-tool"), using the same id for the paired TOOL_CALL_START/TOOL_CALL_END events, with the same explanatory comment.Adds a regression test: a fallback response with two tool calls sharing one deterministic id must produce two unique generated toolCallIds, with START/END agreeing per call. Fails on main, passes with this change. Full suite: 309 passed. Changeset included (patch,
@cloudflare/tanstack-ai).