@ai-sdk/anthropic 2.0.91 → 2.0.93

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,18 @@
1
1
  # @ai-sdk/anthropic
2
2
 
3
+ ## 2.0.93
4
+
5
+ ### Patch Changes
6
+
7
+ - 950eec8: Preserve Anthropic prompt-cache matches by replaying complete code-execution transcripts in their original wire shape.
8
+
9
+ ## 2.0.92
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies [7a6bdbc]
14
+ - @ai-sdk/provider-utils@3.0.31
15
+
3
16
  ## 2.0.91
4
17
 
5
18
  ### Patch Changes
package/dist/index.js CHANGED
@@ -31,7 +31,7 @@ var import_provider4 = require("@ai-sdk/provider");
31
31
  var import_provider_utils20 = require("@ai-sdk/provider-utils");
32
32
 
33
33
  // src/version.ts
34
- var VERSION = true ? "2.0.91" : "0.0.0-test";
34
+ var VERSION = true ? "2.0.93" : "0.0.0-test";
35
35
 
36
36
  // src/anthropic-messages-language-model.ts
37
37
  var import_provider3 = require("@ai-sdk/provider");
@@ -1826,12 +1826,13 @@ async function convertToAnthropicMessagesPrompt({
1826
1826
  case "tool-call": {
1827
1827
  if (part.providerExecuted) {
1828
1828
  if (part.toolName === "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")) {
1829
+ const { type: type2, ...input } = part.input;
1829
1830
  anthropicContent.push({
1830
1831
  type: "server_tool_use",
1831
1832
  id: part.toolCallId,
1832
- name: part.input.type,
1833
+ name: type2,
1833
1834
  // map back to subtool name
1834
- input: part.input,
1835
+ input,
1835
1836
  cache_control: cacheControl
1836
1837
  });
1837
1838
  } else if (part.toolName === "code_execution" || // code execution 20250522
@@ -1903,7 +1904,15 @@ async function convertToAnthropicMessagesPrompt({
1903
1904
  type: "bash_code_execution_tool_result",
1904
1905
  tool_use_id: part.toolCallId,
1905
1906
  cache_control: cacheControl,
1906
- content: codeExecutionOutput
1907
+ // Prompt caching requires stable key ordering:
1908
+ // https://platform.claude.com/docs/en/build-with-claude/prompt-caching#troubleshooting-common-issues
1909
+ content: codeExecutionOutput.type === "bash_code_execution_result" ? {
1910
+ type: codeExecutionOutput.type,
1911
+ stdout: codeExecutionOutput.stdout,
1912
+ stderr: codeExecutionOutput.stderr,
1913
+ return_code: codeExecutionOutput.return_code,
1914
+ content: codeExecutionOutput.content
1915
+ } : codeExecutionOutput
1907
1916
  } : {
1908
1917
  type: "text_editor_code_execution_tool_result",
1909
1918
  tool_use_id: part.toolCallId,