现象
客户端传 tool_choice: none(Anthropic 的 {type:"none"} 或 OpenAI 的 "none")时,代理原样映射成 CC 的 {type:"none"},CC 返回 400:
Invalid request error. Often missing required parameters or typo. HINT: Validation error:
Invalid input: expected "auto" at "params.tool_choice.type" or Invalid input: expected "any" at
"params.tool_choice.type" or Invalid input: expected "tool" at "params.tool_choice.type";
Invalid input: expected string, received undefined at "params.tool_choice.name"
CC 的 tool_choice.type 枚举只有 auto / any / tool。
位置
convertAnthropicToOpenAI:tc.type === 'none' → openaiReq.tool_choice = 'none'
buildCcRequest:{ 'auto': 'auto', 'none': 'none', 'required': 'any' } → body.params.tool_choice = { type: 'none' }
两个入口(/v1/messages 和 /v1/chat/completions)都会踩到。
复现
curl -s http://127.0.0.1:3050/v1/chat/completions -H "Authorization: Bearer user_xxx" -H "Content-Type: application/json" \
-d '{"model":"deepseek/deepseek-v4-flash","messages":[{"role":"user","content":"hi"}],"tools":[{"type":"function","function":{"name":"noop","parameters":{"type":"object","properties":{}}}}],"tool_choice":"none"}'
建议
none 的语义是"本轮不允许调用工具",最接近的等价做法是:遇到 none 时不下发 tools、也不下发 tool_choice
(CC 信封里 tools: [] 是合法的)。退一步也可以映射成 auto,但会改变语义;不建议直接透传报错。
现象
客户端传
tool_choice: none(Anthropic 的{type:"none"}或 OpenAI 的"none")时,代理原样映射成 CC 的{type:"none"},CC 返回 400:Invalid request error. Often missing required parameters or typo. HINT: Validation error:
Invalid input: expected "auto" at "params.tool_choice.type" or Invalid input: expected "any" at
"params.tool_choice.type" or Invalid input: expected "tool" at "params.tool_choice.type";
Invalid input: expected string, received undefined at "params.tool_choice.name"
CC 的
tool_choice.type枚举只有auto/any/tool。位置
convertAnthropicToOpenAI:tc.type === 'none'→openaiReq.tool_choice = 'none'buildCcRequest:{ 'auto': 'auto', 'none': 'none', 'required': 'any' }→body.params.tool_choice = { type: 'none' }两个入口(
/v1/messages和/v1/chat/completions)都会踩到。复现