Skip to content

fix(tool): handle undefined input while streaming - #491

Open
minwookshin wants to merge 1 commit into
vercel:mainfrom
minwookshin:codex/fix-tool-input-streaming-490
Open

minwookshin wants to merge 1 commit into
vercel:mainfrom
minwookshin:codex/fix-tool-input-streaming-490

Conversation

@minwookshin

Copy link
Copy Markdown

Closes #490.

Initial input-streaming input can be undefined, which makes JSON.stringify return undefined and crashes CodeBlock at code.split. Return null from ToolInput until input exists so the surrounding tool stays visible. Preserve JSON rendering for defined values, including null, false, 0, an empty string, and an empty object.

Add eight regression cases covering missing input, partial-to-available input, clearing previous parameters, and defined falsy values. Update the example and prop documentation to show the initial streaming state. No public API changes.

Validation:

  • Reproduced the original code.split crash in Chromium before applying the fix.
  • Full test suite: 47 files, 966 tests passed in Chromium on Node.js 22.14.0.
  • Production documentation build passed: pnpm build --filter ai-elements --filter docs.
  • Changed TSX files pass the formatter invoked by Ultracite and repository-pinned oxlint.
  • Desktop and mobile previews display the Pending header without parameters and render JSON when a populated tool is expanded.

Repository-wide checks have existing limitations: pnpm check flags nine untouched files; the Ultracite lint invocation fails to resolve import/no-unresolved. Standalone elements TypeScript checking reports the same 57 diagnostics with both HEAD and this patch, with none in changed files. The documentation preview also emits a React hydration warning on both Tool and the untouched Suggestion page.

@vercel

vercel Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

@minwookshin is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ToolInput crashes the tree while tool input is streaming (input is undefined, CodeBlock calls code.split)

1 participant