Repository navigation
fix(ai): treat whitespace-only tool text as empty - #462
Merged
Merged
Conversation
Blank tool text, error values, and content items now match an empty string. Anthropic success tool results drop that text and keep non-blank text unchanged.
PR 461 landed on the base while this branch was open. Keep that error-result filter and the whitespace-only success path from this branch. # Conflicts: # packages/ai/src/protocols/anthropic-messages.ts
3 of 6 tasks
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.
Issue for this PR
No tracked issue.
Type of change
What does this PR do?
Whitespace-only tool text was kept, while an empty string was replaced with
(no tool output).normalizeToolResulttreats.trim() === ""as empty for text results and error values. Non-blank text, including surrounding spaces, is unchanged.For content arrays, exact
""items are removed because they cannot separate joined text. The(no tool output)fallback applies only when every remaining item is blank and there is no media. Whitespace such as"\n"stays, so Mistral's empty-string join of["foo", "\n", "bar"]stays"foo\nbar".Anthropic and Bedrock drop remaining blank text, including
" ", while lowering a tool result. A Bedrock result of[{text:" "}, image]sends only the image.Head
60ac11e8c2.How did you verify your code works?
env -u RECORD CI=true bun test --timeout 30000inpackages/aion60ac11e8c2: 1963 pass, 28 skip, 0 fail. The skips are recorded cases whose cassettes are not on disk. Recorded fixtures that have cassettes passed.Visual
No UI change.
Screenshots / recordings
None.
Checklist