Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/core/src/code_assist/converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ function toContent(content: ContentUnion): Content {
return {
...content,
parts: content.parts
? toParts(content.parts.filter((p) => p != null))
? toParts(content.parts.filter((p) => p != null && !p.thought))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

While this change correctly filters out thought parts for Content objects, the fix is incomplete. Other paths within the toContent function can still process thought parts, leading to the same contamination issue.

Specifically:

  1. When toContent receives a PartUnion[] (the Array.isArray(content) case on line 207), toParts is called without filtering, allowing thought parts to be converted to text by toPart.
  2. When toContent receives a single Part with a thought (the final case starting on line 230), toPart is called directly, again causing the unwanted conversion.

To fully resolve the issue, the thought filtering 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.

: [],
};
}
Expand Down