fix(claude): read disable_parallel_tool_use from tool_choice

This commit is contained in:
Darley
2026-03-17 19:35:41 +08:00
parent 19e1a4447a
commit 9c6c3612a8
2 changed files with 5 additions and 5 deletions
@@ -271,9 +271,9 @@ func ConvertClaudeRequestToCodex(modelName string, inputRawJSON []byte, _ bool)
} }
} }
// Default to parallel tool calls unless the client explicitly disables them. // Default to parallel tool calls unless tool_choice explicitly disables them.
parallelToolCalls := true parallelToolCalls := true
if disableParallelToolUse := rootResult.Get("disable_parallel_tool_use"); disableParallelToolUse.Exists() { if disableParallelToolUse := rootResult.Get("tool_choice.disable_parallel_tool_use"); disableParallelToolUse.Exists() {
parallelToolCalls = !disableParallelToolUse.Bool() parallelToolCalls = !disableParallelToolUse.Bool()
} }
@@ -95,7 +95,7 @@ func TestConvertClaudeRequestToCodex_ParallelToolCalls(t *testing.T) {
wantParallelToolCalls bool wantParallelToolCalls bool
}{ }{
{ {
name: "Default to true when disable_parallel_tool_use is absent", name: "Default to true when tool_choice.disable_parallel_tool_use is absent",
inputJSON: `{ inputJSON: `{
"model": "claude-3-opus", "model": "claude-3-opus",
"messages": [{"role": "user", "content": "hello"}] "messages": [{"role": "user", "content": "hello"}]
@@ -106,7 +106,7 @@ func TestConvertClaudeRequestToCodex_ParallelToolCalls(t *testing.T) {
name: "Disable parallel tool calls when client opts out", name: "Disable parallel tool calls when client opts out",
inputJSON: `{ inputJSON: `{
"model": "claude-3-opus", "model": "claude-3-opus",
"disable_parallel_tool_use": true, "tool_choice": {"disable_parallel_tool_use": true},
"messages": [{"role": "user", "content": "hello"}] "messages": [{"role": "user", "content": "hello"}]
}`, }`,
wantParallelToolCalls: false, wantParallelToolCalls: false,
@@ -115,7 +115,7 @@ func TestConvertClaudeRequestToCodex_ParallelToolCalls(t *testing.T) {
name: "Keep parallel tool calls enabled when client explicitly allows them", name: "Keep parallel tool calls enabled when client explicitly allows them",
inputJSON: `{ inputJSON: `{
"model": "claude-3-opus", "model": "claude-3-opus",
"disable_parallel_tool_use": false, "tool_choice": {"disable_parallel_tool_use": false},
"messages": [{"role": "user", "content": "hello"}] "messages": [{"role": "user", "content": "hello"}]
}`, }`,
wantParallelToolCalls: true, wantParallelToolCalls: true,