@ai-sdk/anthropic 4.0.0-beta.67 → 4.0.0-beta.69

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,19 @@
1
1
  # @ai-sdk/anthropic
2
2
 
3
+ ## 4.0.0-beta.69
4
+
5
+ ### Patch Changes
6
+
7
+ - 19c5ee2: fix(anthropic): reorder assistant content b/w client and provider tool use
8
+
9
+ ## 4.0.0-beta.68
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies [0416e3e]
14
+ - @ai-sdk/provider@4.0.0-beta.20
15
+ - @ai-sdk/provider-utils@5.0.0-beta.50
16
+
3
17
  ## 4.0.0-beta.67
4
18
 
5
19
  ### Patch Changes
package/dist/index.js CHANGED
@@ -3205,7 +3205,10 @@ async function convertToAnthropicPrompt({
3205
3205
  }
3206
3206
  }
3207
3207
  }
3208
- messages.push({ role: "assistant", content: anthropicContent });
3208
+ messages.push({
3209
+ role: "assistant",
3210
+ content: moveToolUseBlocksToEnd(anthropicContent)
3211
+ });
3209
3212
  break;
3210
3213
  }
3211
3214
  default: {
@@ -3265,6 +3268,27 @@ function groupIntoBlocks(prompt) {
3265
3268
  }
3266
3269
  return blocks;
3267
3270
  }
3271
+ function moveToolUseBlocksToEnd(content) {
3272
+ const result = [];
3273
+ let segment = [];
3274
+ function flushSegment() {
3275
+ result.push(
3276
+ ...segment.filter((part) => part.type !== "tool_use"),
3277
+ ...segment.filter((part) => part.type === "tool_use")
3278
+ );
3279
+ segment = [];
3280
+ }
3281
+ for (const part of content) {
3282
+ if (part.type === "thinking" || part.type === "redacted_thinking") {
3283
+ flushSegment();
3284
+ result.push(part);
3285
+ } else {
3286
+ segment.push(part);
3287
+ }
3288
+ }
3289
+ flushSegment();
3290
+ return result;
3291
+ }
3268
3292
 
3269
3293
  // src/map-anthropic-stop-reason.ts
3270
3294
  function mapAnthropicStopReason({
@@ -6263,7 +6287,7 @@ var AnthropicSkills = class {
6263
6287
  };
6264
6288
 
6265
6289
  // src/version.ts
6266
- var VERSION = true ? "4.0.0-beta.67" : "0.0.0-test";
6290
+ var VERSION = true ? "4.0.0-beta.69" : "0.0.0-test";
6267
6291
 
6268
6292
  // src/anthropic-provider.ts
6269
6293
  function createAnthropic(options = {}) {