@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.
@@ -1820,12 +1820,13 @@ async function convertToAnthropicMessagesPrompt({
1820
1820
  case "tool-call": {
1821
1821
  if (part.providerExecuted) {
1822
1822
  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")) {
1823
+ const { type: type2, ...input } = part.input;
1823
1824
  anthropicContent.push({
1824
1825
  type: "server_tool_use",
1825
1826
  id: part.toolCallId,
1826
- name: part.input.type,
1827
+ name: type2,
1827
1828
  // map back to subtool name
1828
- input: part.input,
1829
+ input,
1829
1830
  cache_control: cacheControl
1830
1831
  });
1831
1832
  } else if (part.toolName === "code_execution" || // code execution 20250522
@@ -1897,7 +1898,15 @@ async function convertToAnthropicMessagesPrompt({
1897
1898
  type: "bash_code_execution_tool_result",
1898
1899
  tool_use_id: part.toolCallId,
1899
1900
  cache_control: cacheControl,
1900
- content: codeExecutionOutput
1901
+ // Prompt caching requires stable key ordering:
1902
+ // https://platform.claude.com/docs/en/build-with-claude/prompt-caching#troubleshooting-common-issues
1903
+ content: codeExecutionOutput.type === "bash_code_execution_result" ? {
1904
+ type: codeExecutionOutput.type,
1905
+ stdout: codeExecutionOutput.stdout,
1906
+ stderr: codeExecutionOutput.stderr,
1907
+ return_code: codeExecutionOutput.return_code,
1908
+ content: codeExecutionOutput.content
1909
+ } : codeExecutionOutput
1901
1910
  } : {
1902
1911
  type: "text_editor_code_execution_tool_result",
1903
1912
  tool_use_id: part.toolCallId,