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(),