ai 5.0.279 → 5.0.280
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 +8 -0
- package/dist/index.js +44 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +44 -13
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.mjs +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# ai
|
|
2
2
|
|
|
3
|
+
## 5.0.280
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 1e4ab85: fix(ai): remove orphaned reasoning, including consecutive summary parts, when pruning tool calls
|
|
8
|
+
- Updated dependencies [bd02a79]
|
|
9
|
+
- @ai-sdk/gateway@2.0.171
|
|
10
|
+
|
|
3
11
|
## 5.0.279
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -817,7 +817,7 @@ function detectMediaType({
|
|
|
817
817
|
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
818
818
|
|
|
819
819
|
// src/version.ts
|
|
820
|
-
var VERSION = true ? "5.0.
|
|
820
|
+
var VERSION = true ? "5.0.280" : "0.0.0-test";
|
|
821
821
|
|
|
822
822
|
// src/util/download/download.ts
|
|
823
823
|
var download = async ({
|
|
@@ -8924,21 +8924,52 @@ function pruneMessages({
|
|
|
8924
8924
|
if (message.role !== "assistant" && message.role !== "tool" || typeof message.content === "string" || keepLastMessagesCount && messageIndex >= messages.length - keepLastMessagesCount) {
|
|
8925
8925
|
return message;
|
|
8926
8926
|
}
|
|
8927
|
-
const
|
|
8928
|
-
|
|
8929
|
-
|
|
8930
|
-
|
|
8931
|
-
|
|
8932
|
-
|
|
8927
|
+
const keepParts = message.content.map((part) => {
|
|
8928
|
+
if (part.type !== "tool-call" && part.type !== "tool-result") {
|
|
8929
|
+
return true;
|
|
8930
|
+
}
|
|
8931
|
+
if ((part.type === "tool-call" || part.type === "tool-result") && keptToolCallIds.has(part.toolCallId)) {
|
|
8932
|
+
return true;
|
|
8933
|
+
}
|
|
8934
|
+
return toolCall.tools != null && !toolCall.tools.includes(part.toolName);
|
|
8935
|
+
});
|
|
8936
|
+
if (message.role === "assistant") {
|
|
8937
|
+
for (let reasoningIndex = 0; reasoningIndex < message.content.length; reasoningIndex++) {
|
|
8938
|
+
const part = message.content[reasoningIndex];
|
|
8939
|
+
if (part.type !== "reasoning") {
|
|
8940
|
+
continue;
|
|
8933
8941
|
}
|
|
8934
|
-
|
|
8935
|
-
|
|
8942
|
+
let reasoningEndIndex = reasoningIndex + 1;
|
|
8943
|
+
while (reasoningEndIndex < message.content.length) {
|
|
8944
|
+
const nextPart = message.content[reasoningEndIndex];
|
|
8945
|
+
if (nextPart.type !== "reasoning") {
|
|
8946
|
+
break;
|
|
8947
|
+
}
|
|
8948
|
+
reasoningEndIndex++;
|
|
8936
8949
|
}
|
|
8937
|
-
|
|
8938
|
-
|
|
8950
|
+
let followingPartIndex = reasoningEndIndex;
|
|
8951
|
+
let hasFollowingPart = false;
|
|
8952
|
+
let hasKeptFollowingPart = false;
|
|
8953
|
+
while (followingPartIndex < message.content.length) {
|
|
8954
|
+
const followingPart = message.content[followingPartIndex];
|
|
8955
|
+
if (followingPart.type === "reasoning") {
|
|
8956
|
+
break;
|
|
8957
|
+
}
|
|
8958
|
+
hasFollowingPart = true;
|
|
8959
|
+
hasKeptFollowingPart || (hasKeptFollowingPart = keepParts[followingPartIndex]);
|
|
8960
|
+
followingPartIndex++;
|
|
8939
8961
|
}
|
|
8940
|
-
|
|
8941
|
-
|
|
8962
|
+
if (hasFollowingPart && !hasKeptFollowingPart) {
|
|
8963
|
+
for (let index = reasoningIndex; index < reasoningEndIndex; index++) {
|
|
8964
|
+
keepParts[index] = false;
|
|
8965
|
+
}
|
|
8966
|
+
}
|
|
8967
|
+
reasoningIndex = followingPartIndex - 1;
|
|
8968
|
+
}
|
|
8969
|
+
}
|
|
8970
|
+
return {
|
|
8971
|
+
...message,
|
|
8972
|
+
content: message.content.filter((_, index) => keepParts[index])
|
|
8942
8973
|
};
|
|
8943
8974
|
});
|
|
8944
8975
|
}
|