@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.
package/dist/index.mjs CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  } from "@ai-sdk/provider-utils";
13
13
 
14
14
  // src/version.ts
15
- var VERSION = true ? "3.0.103" : "0.0.0-test";
15
+ var VERSION = true ? "3.0.105" : "0.0.0-test";
16
16
 
17
17
  // src/anthropic-messages-language-model.ts
18
18
  import {
@@ -2737,12 +2737,13 @@ async function convertToAnthropicMessagesPrompt({
2737
2737
  // code execution 20250825:
2738
2738
  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")
2739
2739
  ) {
2740
+ const { type: subtoolName, ...input } = part.input;
2740
2741
  anthropicContent.push({
2741
2742
  type: "server_tool_use",
2742
2743
  id: part.toolCallId,
2743
- name: part.input.type,
2744
+ name: subtoolName,
2744
2745
  // map back to subtool name
2745
- input: part.input,
2746
+ input,
2746
2747
  cache_control: cacheControl
2747
2748
  });
2748
2749
  } else if (
@@ -2936,7 +2937,15 @@ async function convertToAnthropicMessagesPrompt({
2936
2937
  type: "bash_code_execution_tool_result",
2937
2938
  tool_use_id: part.toolCallId,
2938
2939
  cache_control: cacheControl,
2939
- content: codeExecutionOutput
2940
+ // Prompt caching requires stable key ordering:
2941
+ // https://platform.claude.com/docs/en/build-with-claude/prompt-caching#troubleshooting-common-issues
2942
+ content: codeExecutionOutput.type === "bash_code_execution_result" ? {
2943
+ type: codeExecutionOutput.type,
2944
+ stdout: codeExecutionOutput.stdout,
2945
+ stderr: codeExecutionOutput.stderr,
2946
+ return_code: codeExecutionOutput.return_code,
2947
+ content: codeExecutionOutput.content
2948
+ } : codeExecutionOutput
2940
2949
  });
2941
2950
  } else {
2942
2951
  anthropicContent.push({