@prestyj/ai 5.24.0 → 5.25.0

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.js CHANGED
@@ -1017,9 +1017,13 @@ function toAnthropicTools(tools, options) {
1017
1017
  return anthropicTool;
1018
1018
  });
1019
1019
  }
1020
- function toAnthropicToolChoice(choice) {
1020
+ function rejectsForcedToolUse(model) {
1021
+ return /opus-5-5|fable-5|mythos-5/.test(model);
1022
+ }
1023
+ function toAnthropicToolChoice(choice, model) {
1021
1024
  if (choice === "auto") return { type: "auto" };
1022
1025
  if (choice === "none") return { type: "none" };
1026
+ if (model && rejectsForcedToolUse(model)) return { type: "auto" };
1023
1027
  if (choice === "required") return { type: "any" };
1024
1028
  return { type: "tool", name: choice.name };
1025
1029
  }
@@ -1435,7 +1439,7 @@ async function* runStream(options) {
1435
1439
  ]
1436
1440
  };
1437
1441
  })() : {},
1438
- ...options.toolChoice && options.tools?.length ? { tool_choice: toAnthropicToolChoice(options.toolChoice) } : {},
1442
+ ...options.toolChoice && options.tools?.length ? { tool_choice: toAnthropicToolChoice(options.toolChoice, options.model) } : {},
1439
1443
  ...(() => {
1440
1444
  const contextEdits = [
1441
1445
  ...options.compaction ? [{ type: "compact_20260112" }] : [],