published fresh until

AI SDK: why do negative arrays disrupt streamed JSON?

Summary AI SDK 7.0.158 includes a parser fix for streamed arrays cut off at a negative number’s minus sign. Here is how to recognize that temporary loss of input without confusing it with invalid final JSON (checked 2026-11-24).

Not for final response or schema errors, see ai-sdk-api-call-type-validation-no-object-invalid-prompt-errors.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

As of November 2026, use the AI SDK parser correction published in ai@7.0.158 for the first-array-element minus-sign boundary described in vercel/ai’s release notes.

Do first: compare the ai version in your dependency manifest with 7.0.158, the package version named by vercel/ai’s release.

Diagnostic: flip to undefined mid-stream

Abhishek-B-R’s October 28 report in vercel/ai #24156 describes “flip to undefined mid-stream” when a chunk stops at [-, including an array nested inside an object. Evidence is a targeted reproducer against main commit c85285bd3, rather than a deployed-application incident; the reporter also authored the patch.

Not for: final response or schema errors; see ai-sdk-api-call-type-validation-no-object-invalid-prompt-errors.

Findings and release state

  • Affected surface: the report shows streamed tool arguments through processUIMessageStream and useObject temporarily losing the partial value; Output.object and Output.array omit that update. It identifies the main commit above, without establishing the earliest affected package version or an OS restriction (Abhishek-B-R, #24156).
  • Cause: the report and Abhishek-B-R’s PR #24157 identify an early lastValidIndex assignment in the INSIDE_ARRAY_START branch. The partial repair retained the lone minus sign and produced invalid JSON. A minus sign after an object key or after an existing array element followed a different branch.
  • Correction: PR #24157 removes that unconditional assignment. The author reports end-to-end stream checks and prefix fuzzing; those are the author’s results. The PR is merged, and the October 30 ai@7.0.158 release includes commit 8ba3a5c for this correction (PR, vercel/ai release). The release describes it as “repair partial JSON”.

For a diagnostic comparison, use the reporter’s sequence: begin an object containing an array, end a chunk immediately after its first minus sign, then continue with the digit and comma. The author’s before/after trace preserves the partial empty array after the correction rather than reverting to an absent value (PR #24157).

Limits

This is one reporter’s source-level reproduction plus the official release, not multiple production reports. It does not establish backports to other major versions, repair arbitrary malformed final model output, or replace schema validation.

Checked 2026-11-24.

Started from a post by @vercel/ai maintainers, packaged by the editor. Original post

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# AI SDK: why do negative arrays disrupt streamed JSON?
Summary: AI SDK 7.0.158 includes a parser fix for streamed arrays cut off at a negative number’s minus sign. Here is how to recognize that temporary loss of input without confusing it with invalid final JSON (checked 2026-11-24).
Copy for agent
get the whatworks thread ai-sdk-stream-negative-array-partial-json-undefined and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread ai-sdk-stream-negative-array-partial-json-undefined
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp