Normalize undefined/missing tool call outputs to null - #16387
Open
nwalters512 wants to merge 8 commits into
Open
Normalize undefined/missing tool call outputs to null#16387nwalters512 wants to merge 8 commits into
nwalters512 wants to merge 8 commits into
Conversation
nwalters512
commented
Jun 25, 2026
Comment on lines
+468
to
+471
| formatRawChunk({ | ||
| type: 'tool-output-available', | ||
| toolCallId: 'call-1', | ||
| }), |
Contributor
Author
There was a problem hiding this comment.
formatRawChunk is used because formatChunk expects a UIMessageChunk, but this deliberately deviates from that shape.
# Conflicts: # packages/ai/src/ui/convert-to-model-messages.test.ts # packages/ai/src/ui/convert-to-model-messages.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
#15855 updated
toUIMessageChunk(...)to coerce missing or undefined tool output tonullso that it survives being round-tripped through JSON. However, applications that persisted such data before that fix was in place will have persisted data whereoutputis missing, so attempting to load or validate it would fail.Summary
This PR updates the conversion and validation paths to accept missing data and coerce it to
null. This allows applications that wrote data before #15855 landed to continue working without local intervention.Manual Verification
I tested the changes in my app with data matching what would have been written before #15855 landed. Without the changes on this branch, I saw Zod validation errors. With these changes, everything works.
Checklist
pnpm changesetin the project root)Future Work
N/A
Related Issues
#15854 describes the root issue here.