Components: tool.tsx (ToolInput), code-block.tsx (CodeBlockContent)
What happens
While a tool part is in input-streaming, part.input is undefined. ToolInput renders <CodeBlock code={JSON.stringify(input, null, 2)} /> (tool.tsx:125); JSON.stringify(undefined) returns undefined, and createRawTokens calls code.split("\n") on it (code-block.tsx:171, from the useMemo at :384):
TypeError: Cannot read properties of undefined (reading 'split')
createRawTokens src/components/ai-elements/code-block.tsx:171
CodeBlockContent src/components/ai-elements/code-block.tsx:384
React unmounts the tree, so the whole chat stops rendering, not just the tool card. The props type allows it: ToolPart["input"] is unknown.
Repro
Render a tool part in every state:
<Tool>
<ToolHeader type="dynamic-tool" state={part.state} toolName={part.toolName} />
<ToolContent>
<ToolInput input={part.input} />
<ToolOutput output={part.output} errorText={part.errorText} />
</ToolContent>
</Tool>
and stream a tool call whose input arrives in deltas. Observed stream: tool-input-start → tool-input-delta → tool-input-available; the crash happens on the render between the first two.
Observed with @ai-sdk/langchain 3.0.99, ai 7.0.99, @ai-sdk/react 4.0.102, React 19.3.0, Vite 8.3.0, components added from the @ai-elements registry on 2026-09-13. The same code is on main today. The throw is in render code, so the framework should not matter.
Workaround
Render ToolInput only once the input exists: {part.input !== undefined && <ToolInput input={part.input} />}.
Possible fix
Return null (or a pending placeholder) from ToolInput when input === undefined, or make CodeBlock tolerate a non-string code.
Components:
tool.tsx(ToolInput),code-block.tsx(CodeBlockContent)What happens
While a tool part is in
input-streaming,part.inputisundefined.ToolInputrenders<CodeBlock code={JSON.stringify(input, null, 2)} />(tool.tsx:125);JSON.stringify(undefined)returnsundefined, andcreateRawTokenscallscode.split("\n")on it (code-block.tsx:171, from theuseMemoat:384):React unmounts the tree, so the whole chat stops rendering, not just the tool card. The props type allows it:
ToolPart["input"]isunknown.Repro
Render a tool part in every state:
and stream a tool call whose input arrives in deltas. Observed stream:
tool-input-start→tool-input-delta→tool-input-available; the crash happens on the render between the first two.Observed with
@ai-sdk/langchain3.0.99,ai7.0.99,@ai-sdk/react4.0.102, React 19.3.0, Vite 8.3.0, components added from the@ai-elementsregistry on 2026-09-13. The same code is onmaintoday. The throw is in render code, so the framework should not matter.Workaround
Render
ToolInputonly once the input exists:{part.input !== undefined && <ToolInput input={part.input} />}.Possible fix
Return
null(or a pending placeholder) fromToolInputwheninput === undefined, or makeCodeBlocktolerate a non-stringcode.