DeepSeek: don't send empty required arrays in tool definitions

596353389b2c090559eef340d8f33a120344f6ec

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +8 -0Ignore whitespace
src/endpoints/backends/chat-completions.js+8 -0
@@ -798,6 +798,14 @@ async function sendDeepSeekRequest(request, response) {
798798 if (Array.isArray(request.body.tools) && request.body.tools.length > 0) {
799799 bodyParams['tools'] = request.body.tools;
800800 bodyParams['tool_choice'] = request.body.tool_choice;
801+
802+ // DeepSeek doesn't permit empty required arrays
803+ bodyParams.tools.forEach(tool => {
804+ const required = tool?.function?.parameters?.required;
805+ if (Array.isArray(required) && required.length === 0) {
806+ delete tool.function.parameters.required;
807+ }
808+ });
801809 }
802810
803811 const postProcessType = String(request.body.model).endsWith('-reasoner') ? 'deepseek-reasoner' : 'deepseek';