You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Vercel AI: streamText with tools fails with "ReadableStream is locked" on ai >= 7.0.168 #26403
Since ai 7.0.168, Sentry breaks streamText calls that use tools. The call fails with TypeError: Invalid state: The ReadableStream is locked, and the caller gets no text. It happens with any tracesSampleRate, including 0, so it affects every app on these versions that has Sentry.init loaded, whether or not it traces.
Reported upstream in vercel/ai#24970. The reporter traced the failure to Sentry's ai:telemetry subscriber.
Cause:deferStreamedModelCallEnd in packages/server-utils/src/integrations/vercel-ai/vercel-ai-dc-subscriber.ts:339 replaces result.stream with a tapped stream. Since 7.0.168, ai publishes redactTelemetryCredentials(result) on the channel instead of the result itself. When that returns a copy, the copy shares the original ReadableStream. Our tapModelCallStream locks the original and assigns the tapped stream only to the copy. streamLanguageModelCall then calls pipeThrough on the original, which is locked.
vercel-ai-orchestrion-subscriber.ts:530 replaces value.stream on doStream results the same way. I haven't checked whether that path is affected.
Upstream fix:vercel/ai#24984 (open, awaiting maintainer review) makes the redacted copy forward stream to the real result. Applying its replaceProperties change to the built 7.0.173 fixes the repro with @sentry/node 11.12.0 at tracesSampleRate1 and 0.
Our v6_v7/scenario-stream-tools.mjs didn't catch this because it uses MockLanguageModelV3, whose result has no request body for ai to redact, so no copy is made.
changed the title [-]Vercel AI: streamText with tools fails with "ReadableStream is locked" on ai >= 7.0.169[/-][+]Vercel AI: streamText with tools fails with "ReadableStream is locked" on ai >= 7.0.168[/+]on Nov 16, 2026
Fixed upstream in vercel/ai#25135, which ships in ai 7.0.174 (pending release in vercel/ai#25061). Affected versions are ai 7.0.168 through 7.0.173. No Sentry SDK change is needed.
I applied the patch to 7.0.173 and reran the repro with @sentry/node 11.12.0. streamText with tools now returns the text at tracesSampleRate 0 and 1, and the model call span still records token usage.
I'll keep this open until 7.0.174 is on npm, then add a regression test that uses a real provider. Our current scenario uses MockLanguageModelV3, which sends no request body, so it never triggers the redaction copy.
Activity
linear-code commentedon Nov 16, 2026
JS-4104
[-]Vercel AI: streamText with tools fails with "ReadableStream is locked" on ai >= 7.0.169[/-][+]Vercel AI: streamText with tools fails with "ReadableStream is locked" on ai >= 7.0.168[/+]RulaKhaled commentedon Nov 17, 2026
Fixed upstream in vercel/ai#25135, which ships in
ai7.0.174 (pending release in vercel/ai#25061). Affected versions areai7.0.168 through 7.0.173. No Sentry SDK change is needed.I applied the patch to 7.0.173 and reran the repro with
@sentry/node11.12.0.streamTextwith tools now returns the text attracesSampleRate0 and 1, and the model call span still records token usage.I'll keep this open until 7.0.174 is on npm, then add a regression test that uses a real provider. Our current scenario uses
MockLanguageModelV3, which sends no request body, so it never triggers the redaction copy.test(vercel-ai): Cover streamText with tools on a real provider (#26440)
fix(sentry): assinatura do ChatGPT responde sem a instrumentação do A…
RulaKhaled commentedon Nov 19, 2026
Fixed upstream in vercel/ai#25135, released in
ai7.0.174. Upgrade to 7.0.174 or later if you're on 7.0.168 through 7.0.173.