@ai-sdk/anthropic 3.0.103 → 3.0.105

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.
@@ -2680,12 +2680,13 @@ async function convertToAnthropicMessagesPrompt({
2680
2680
  // code execution 20250825:
2681
2681
  providerToolName === "code_execution" && part.input != null && typeof part.input === "object" && "type" in part.input && typeof part.input.type === "string" && (part.input.type === "bash_code_execution" || part.input.type === "text_editor_code_execution")
2682
2682
  ) {
2683
+ const { type: subtoolName, ...input } = part.input;
2683
2684
  anthropicContent.push({
2684
2685
  type: "server_tool_use",
2685
2686
  id: part.toolCallId,
2686
- name: part.input.type,
2687
+ name: subtoolName,
2687
2688
  // map back to subtool name
2688
- input: part.input,
2689
+ input,
2689
2690
  cache_control: cacheControl
2690
2691
  });
2691
2692
  } else if (
@@ -2879,7 +2880,15 @@ async function convertToAnthropicMessagesPrompt({
2879
2880
  type: "bash_code_execution_tool_result",
2880
2881
  tool_use_id: part.toolCallId,
2881
2882
  cache_control: cacheControl,
2882
- content: codeExecutionOutput
2883
+ // Prompt caching requires stable key ordering:
2884
+ // https://platform.claude.com/docs/en/build-with-claude/prompt-caching#troubleshooting-common-issues
2885
+ content: codeExecutionOutput.type === "bash_code_execution_result" ? {
2886
+ type: codeExecutionOutput.type,
2887
+ stdout: codeExecutionOutput.stdout,
2888
+ stderr: codeExecutionOutput.stderr,
2889
+ return_code: codeExecutionOutput.return_code,
2890
+ content: codeExecutionOutput.content
2891
+ } : codeExecutionOutput
2883
2892
  });
2884
2893
  } else {
2885
2894
  anthropicContent.push({