Skip to content

fix(elements): render empty-string tool output in ToolOutput - #481

Open
shoemoney wants to merge 1 commit into
vercel:mainfrom
shoemoney:fix/tool-output-empty-string
Open

fix(elements): render empty-string tool output in ToolOutput#481
shoemoney wants to merge 1 commit into
vercel:mainfrom
shoemoney:fix/tool-output-empty-string

Conversation

@shoemoney

Copy link
Copy Markdown

What

Closes #399.

ToolOutput hides any falsy output because its early return is if (!(output || errorText)) (packages/elements/src/tool.tsx:141). A tool that legitimately returns an empty string, like reading an empty file or a search with no matches, renders nothing at all, not even the "Result" header. 0 and false outputs are hidden the same way.

The guard now hides only when output is nullish (undefined or null) and there is no errorText. Empty string, 0, and false fall through to the normal rendering branches. Behavior for null/undefined output and for error text is unchanged.

How tested

Four new tests in packages/elements/__tests__/tool.test.tsx: empty-string, 0, and false outputs render the "Result" section, and null output still renders nothing (pinning the existing hide behavior). With the source change reverted and the tests kept in place, the three falsy-output tests fail and the other 24 pass; with the fix, all 27 pass. Full @repo/elements suite: 47 files, 962 tests, all passing. oxlint clean on both changed files.

Deliberately not changed: the errorText side of the guard still uses a truthiness check, so an empty-string errorText keeps its current hide behavior. Empty error text carries no information worth rendering, and changing it would widen the diff past the reported issue.

The ToolOutput guard !(output || errorText) treats every falsy
output as absent, so a tool that legitimately returns an empty
string (reading an empty file, a search with no matches) renders
nothing at all. Hide only when output is nullish and there is no
error text; empty string, 0, and false now render as results.
@vercel

vercel Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

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

A member of the Team first needs to authorize it.

@shoemoney

Copy link
Copy Markdown
Author

CI note: Vercel failure is pre-existing on main/trunk and unrelated to this PR's changed files. Vercel Authorization required to deploy reproduces identically on recent fork PRs 475, 476, 477, 478 and is unrelated to tool.tsx/tool.test.tsx; all code checks pass. No code fix required from this PR; rebase/label will clear it.

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.

ToolOutput component is wrongly hidden when the tool message result is a empty string

1 participant