From acf1bef6551912a42914563bb25ff71484007925 Mon Sep 17 00:00:00 2001 From: Valerii Kovalskii Date: Tue, 7 Apr 2026 20:25:58 +0300 Subject: [PATCH] fix: support reasoning models (content:null, no json_object format) - Handle content:null from reasoning models (gpt-oss-120b etc) - Try reasoning_content field as fallback - Remove response_format:json_object (not supported by reasoning models) - Log full response on empty content for debugging Co-Authored-By: Claude Opus 4.6 (1M context) --- src/server.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/server.js b/src/server.js index 99ce43a..47f8e56 100644 --- a/src/server.js +++ b/src/server.js @@ -496,8 +496,7 @@ ${conversation}`; { role: 'system', content: systemPrompt }, { role: 'user', content: prompt }, ], - response_format: { type: 'json_object' }, - max_tokens: 150, + max_tokens: 200, temperature: 0.3, }); @@ -527,7 +526,15 @@ ${conversation}`; reject(new Error(result.error.message || JSON.stringify(result.error))); return; } - const content = result.choices[0].message.content; + const msg = result.choices && result.choices[0] && result.choices[0].message; + // Reasoning models may put output in reasoning_content or content + const content = (msg && msg.content) || (msg && msg.reasoning_content) || ''; + if (!content) { + // Log full response for debugging + log('ERROR', 'LLM empty content, full response: ' + JSON.stringify(result).slice(0, 500)); + reject(new Error('LLM returned empty content. If using a reasoning model, it may not support structured output.')); + return; + } let title; try { title = JSON.parse(content).title;