@ai-sdk/anthropic 4.0.60 → 4.0.62

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.
@@ -524,7 +524,7 @@ declare const anthropicResponseSchema: _ai_sdk_provider_utils.LazySchema<{
524
524
  data: string;
525
525
  } | {
526
526
  type: "compaction";
527
- content: string;
527
+ content?: string | null | undefined;
528
528
  } | {
529
529
  type: "tool_use";
530
530
  id: string;
@@ -257,7 +257,7 @@ var anthropicResponseSchema = lazySchema3(
257
257
  }),
258
258
  z3.object({
259
259
  type: z3.literal("compaction"),
260
- content: z3.string()
260
+ content: z3.string().nullish()
261
261
  }),
262
262
  z3.object({
263
263
  type: z3.literal("tool_use"),
@@ -3228,6 +3228,9 @@ async function convertToAnthropicPrompt({
3228
3228
  case "text": {
3229
3229
  const textMetadata = (_k = part.providerOptions) == null ? void 0 : _k.anthropic;
3230
3230
  if ((textMetadata == null ? void 0 : textMetadata.type) === "compaction") {
3231
+ if (part.text === "") {
3232
+ break;
3233
+ }
3231
3234
  anthropicContent.push({
3232
3235
  type: "compaction",
3233
3236
  content: part.text,
@@ -3754,10 +3757,12 @@ async function convertToAnthropicPrompt({
3754
3757
  }
3755
3758
  }
3756
3759
  }
3757
- messages.push({
3758
- role: "assistant",
3759
- content: moveToolUseBlocksToEnd(anthropicContent)
3760
- });
3760
+ if (anthropicContent.length > 0) {
3761
+ messages.push({
3762
+ role: "assistant",
3763
+ content: moveToolUseBlocksToEnd(anthropicContent)
3764
+ });
3765
+ }
3761
3766
  break;
3762
3767
  }
3763
3768
  default: {
@@ -4878,6 +4883,9 @@ var AnthropicLanguageModel = class _AnthropicLanguageModel {
4878
4883
  break;
4879
4884
  }
4880
4885
  case "compaction": {
4886
+ if (!part.content) {
4887
+ break;
4888
+ }
4881
4889
  content.push({
4882
4890
  type: "text",
4883
4891
  text: part.content,