From a8558d1e468254a8b7d06c0dbc7cac5fbdcbdb41 Mon Sep 17 00:00:00 2001 From: vnnkl <8235476+vnnkl@users.noreply.github.com> Date: Tue, 7 Jul 2026 20:41:35 +0200 Subject: [PATCH] fix: treat set-but-empty RIDDLE_OPENAI_REASONING as unset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Config UIs that write env files (remagic's settings form has a "" option in its reasoning select) produce RIDDLE_OPENAI_REASONING= — set but empty. The code then sends "reasoning_effort":"", which OpenAI rejects with 400 'Unrecognized request argument supplied: reasoning_effort' on non-reasoning models, silently killing every turn. Trim and treat empty as unset. --- riddle/src/oracle.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/riddle/src/oracle.rs b/riddle/src/oracle.rs index 12ae27e..a69726c 100644 --- a/riddle/src/oracle.rs +++ b/riddle/src/oracle.rs @@ -420,7 +420,14 @@ impl HttpOracle { // Sent as "reasoning_effort" only when set: reasoning models accept it // ("low" ≈ faster first ink), but some providers reject the field on // non-reasoning models, so it must stay out of the default request. - let reasoning = std::env::var("RIDDLE_OPENAI_REASONING").ok(); + // Set-but-EMPTY also means unset: config UIs writing env files (e.g. + // remagic's settings form, whose select includes a "" option) produce + // RIDDLE_OPENAI_REASONING= — and sending "reasoning_effort":"" is a + // 400 on OpenAI, silently killing every turn. + let reasoning = std::env::var("RIDDLE_OPENAI_REASONING") + .ok() + .map(|s| s.trim().to_string()) + .filter(|s| !s.is_empty()); eprintln!( "riddle: http oracle base={base} model={model} max_tokens={max_tokens} reasoning={}", reasoning.as_deref().unwrap_or("-")