From fc68b212521a87d6e8001024eb1d5bbdee430de0 Mon Sep 17 00:00:00 2001 From: "Rodrigo Rodriguez (Pragmatismo)" Date: Tue, 14 Apr 2026 19:42:48 -0300 Subject: [PATCH] fix: support flexible JSON order for GPT-oSS thinking signals --- src/core/bot/mod.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/core/bot/mod.rs b/src/core/bot/mod.rs index b16fde3f..487e7340 100644 --- a/src/core/bot/mod.rs +++ b/src/core/bot/mod.rs @@ -882,9 +882,10 @@ impl BotOrchestrator { // Add chunk to tool_call_buffer and try to parse // Tool calls arrive as JSON that can span multiple chunks - // Extract and send any thinking signals embedded in the chunk - // Thinking signals can appear anywhere in the chunk (start, middle, or end) - let thinking_regex = regex::Regex::new(r#"\{"content":"[^"]*","type":"thinking"\}|\{"type":"thinking_clear"\}"#).unwrap(); + // Extract and send any thinking signals embedded in the chunk + // Thinking signals can appear anywhere in the chunk (start, middle, or end) + // Support both formats: {"content":"...","type":"thinking"} and {"type":"thinking","content":"..."} + let thinking_regex = regex::Regex::new(r#"\{"content":"([^"]*)"\s*,\s*"type":"thinking"\}|\{"type":"thinking"\s*,\s*"content":"([^"]*)"\}|\{"type":"thinking_clear"\}"#).unwrap(); let mut cleaned_chunk = chunk.clone(); let mut found_thinking = false;