mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-24 12:44:18 +08:00
ea95f39adf
Strict OpenAI-compatible upstreams (vLLM, enterprise gateways) reject requests that carry tool_choice or parallel_tool_calls without a non-empty tools array, returning 503/400 with: "When using `tool_choice`, `tools` must be set." The Responses→Chat Completions converter unconditionally forwarded tool_choice and parallel_tool_calls even when tools ended up absent or empty after conversion. This commit adds a guard that removes both fields when the resulting tools array is missing or empty. Added 9 regression tests covering: - tool_choice dropped when tools absent - tool_choice dropped when tools is empty array - parallel_tool_calls dropped when tools absent - tool_choice dropped when all tools filtered (e.g., missing name) - tool_choice preserved when tools present (auto + function type) - clean output when neither tool_choice nor tools present - tool_choice 'none' dropped when no tools - tool_search_output providing tools keeps tool_choice Refs #3557 Co-authored-by: yueqi.guo <guo_yueqi@qq.com>