Skip to content

Commit f4826d8

Browse files
committed
fix(anthropic): preserve disabled parallel tool calls
1 parent cd2760c commit f4826d8

2 files changed

Lines changed: 33 additions & 2 deletions

File tree

‎src/api/providers/__tests__/anthropic.spec.ts‎

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,17 @@ describe("AnthropicHandler", () => {
10131013
// Explicitly disable tool use while preserving the available tool definitions.
10141014
expect(mockCreate).toHaveBeenCalledWith(
10151015
expect.objectContaining({
1016-
tools: expect.any(Array),
1016+
tools: [
1017+
{
1018+
name: "get_weather",
1019+
description: "Get the current weather",
1020+
input_schema: {
1021+
type: "object",
1022+
properties: { location: { type: "string" } },
1023+
required: ["location"],
1024+
},
1025+
},
1026+
],
10171027
tool_choice: { type: "none" },
10181028
}),
10191029
expect.anything(),
@@ -1104,6 +1114,27 @@ describe("AnthropicHandler", () => {
11041114
)
11051115
})
11061116

1117+
it("should disable parallel tool calls when tool_choice is omitted for Claude Fable 5.1", async () => {
1118+
const fableHandler = new AnthropicHandler({
1119+
apiKey: "test-api-key",
1120+
apiModelId: "claude-fable-5-1",
1121+
})
1122+
const stream = fableHandler.createMessage(systemPrompt, messages, {
1123+
taskId: "test-task",
1124+
tools: mockTools,
1125+
parallelToolCalls: false,
1126+
})
1127+
1128+
await collectStream(stream)
1129+
1130+
expect(mockCreate).toHaveBeenCalledWith(
1131+
expect.objectContaining({
1132+
tool_choice: { type: "auto", disable_parallel_tool_use: true },
1133+
}),
1134+
expect.anything(),
1135+
)
1136+
})
1137+
11071138
it("should preserve an explicit none tool_choice for Claude Fable 5.1", async () => {
11081139
const fableHandler = new AnthropicHandler({
11091140
apiKey: "test-api-key",

‎src/api/providers/anthropic.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export class AnthropicHandler extends BaseProvider implements SingleCompletionHa
9999
)
100100
let toolChoice = convertedToolChoice
101101
if (modelId === "claude-fable-5-1") {
102-
if (metadata?.tool_choice === undefined) {
102+
if (metadata?.tool_choice === undefined && metadata?.parallelToolCalls !== false) {
103103
toolChoice = undefined
104104
} else if (metadata.tool_choice === "required" || typeof metadata.tool_choice === "object") {
105105
toolChoice = {

0 commit comments

Comments
 (0)