From c7f5f95a379365fe16172dcb6bf39e45b897d974 Mon Sep 17 00:00:00 2001 From: "Rodrigo Rodriguez (Pragmatismo)" Date: Tue, 14 Apr 2026 17:24:17 -0300 Subject: [PATCH] fix: robust internal signal detection in orchestrator --- src/core/bot/mod.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/core/bot/mod.rs b/src/core/bot/mod.rs index c0b4a468..834be19b 100644 --- a/src/core/bot/mod.rs +++ b/src/core/bot/mod.rs @@ -882,7 +882,14 @@ impl BotOrchestrator { // Tool calls arrive as JSON that can span multiple chunks // Check if this chunk is an internal event (thinking/thinking_clear) - if chunk.trim().starts_with("{\"type\":\"thinking\"") || chunk.trim().starts_with("{\"type\":\"thinking_clear\"") { + let is_internal_signal = if chunk.trim().starts_with("{\"type\"") { + if let Ok(v) = serde_json::from_str::(&chunk) { + let t = v.get("type").and_then(|t| t.as_str()).unwrap_or_default(); + t == "thinking" || t == "thinking_clear" + } else { false } + } else { false }; + + if is_internal_signal { let response = BotResponse { bot_id: message.bot_id.clone(), user_id: message.user_id.clone(),