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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this change correctly filters out
thoughtparts forContentobjects, the fix is incomplete. Other paths within thetoContentfunction can still processthoughtparts, leading to the same contamination issue.Specifically:
toContentreceives aPartUnion[](theArray.isArray(content)case on line 207),toPartsis called without filtering, allowingthoughtparts to be converted to text bytoPart.toContentreceives a singlePartwith a thought (the final case starting on line 230),toPartis called directly, again causing the unwanted conversion.To fully resolve the issue, the
thoughtfiltering logic needs to be applied to all paths that process parts within this file. A more robust solution might be to centralize the filtering logic.Additionally, this change will cause existing tests that check for thought-to-text conversion (e.g.,
should convert thought parts to text parts for API compatibility) to fail. The tests should be updated to reflect the new behavior of filtering out thoughts.