@ai-sdk/anthropic 2.0.92 → 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.
@@ -1836,12 +1836,13 @@ async function convertToAnthropicMessagesPrompt({
1836
1836
  case "tool-call": {
1837
1837
  if (part.providerExecuted) {
1838
1838
  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")) {
1839
+ const { type: type2, ...input } = part.input;
1839
1840
  anthropicContent.push({
1840
1841
  type: "server_tool_use",
1841
1842
  id: part.toolCallId,
1842
- name: part.input.type,
1843
+ name: type2,
1843
1844
  // map back to subtool name
1844
- input: part.input,
1845
+ input,
1845
1846
  cache_control: cacheControl
1846
1847
  });
1847
1848
  } else if (part.toolName === "code_execution" || // code execution 20250522
@@ -1913,7 +1914,15 @@ async function convertToAnthropicMessagesPrompt({
1913
1914
  type: "bash_code_execution_tool_result",
1914
1915
  tool_use_id: part.toolCallId,
1915
1916
  cache_control: cacheControl,
1916
- content: codeExecutionOutput
1917
+ // Prompt caching requires stable key ordering:
1918
+ // https://platform.claude.com/docs/en/build-with-claude/prompt-caching#troubleshooting-common-issues
1919
+ content: codeExecutionOutput.type === "bash_code_execution_result" ? {
1920
+ type: codeExecutionOutput.type,
1921
+ stdout: codeExecutionOutput.stdout,
1922
+ stderr: codeExecutionOutput.stderr,
1923
+ return_code: codeExecutionOutput.return_code,
1924
+ content: codeExecutionOutput.content
1925
+ } : codeExecutionOutput
1917
1926
  } : {
1918
1927
  type: "text_editor_code_execution_tool_result",
1919
1928
  tool_use_id: part.toolCallId,