ai 4.3.6 → 4.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # ai
2
2
 
3
+ ## 4.3.7
4
+
5
+ ### Patch Changes
6
+
7
+ - f4f3945: fix (ai/core): refactor `toResponseMessages` to filter out empty string/content
8
+
3
9
  ## 4.3.6
4
10
 
5
11
  ### Patch Changes
package/dist/index.js CHANGED
@@ -4077,23 +4077,36 @@ function toResponseMessages({
4077
4077
  generateMessageId
4078
4078
  }) {
4079
4079
  const responseMessages = [];
4080
- responseMessages.push({
4081
- role: "assistant",
4082
- content: [
4080
+ const content = [];
4081
+ if (reasoning.length > 0) {
4082
+ content.push(
4083
4083
  ...reasoning.map(
4084
4084
  (part) => part.type === "text" ? { ...part, type: "reasoning" } : { ...part, type: "redacted-reasoning" }
4085
- ),
4086
- // TODO language model v2: switch to order response content (instead of type-based ordering)
4085
+ )
4086
+ );
4087
+ }
4088
+ if (files.length > 0) {
4089
+ content.push(
4087
4090
  ...files.map((file) => ({
4088
4091
  type: "file",
4089
4092
  data: file.base64,
4090
4093
  mimeType: file.mimeType
4091
- })),
4092
- { type: "text", text: text2 },
4093
- ...toolCalls
4094
- ],
4095
- id: messageId
4096
- });
4094
+ }))
4095
+ );
4096
+ }
4097
+ if (text2.length > 0) {
4098
+ content.push({ type: "text", text: text2 });
4099
+ }
4100
+ if (toolCalls.length > 0) {
4101
+ content.push(...toolCalls);
4102
+ }
4103
+ if (content.length > 0) {
4104
+ responseMessages.push({
4105
+ role: "assistant",
4106
+ content,
4107
+ id: messageId
4108
+ });
4109
+ }
4097
4110
  if (toolResults.length > 0) {
4098
4111
  responseMessages.push({
4099
4112
  role: "tool",