diff --git a/botserver/src/core/bot/mod.rs b/botserver/src/core/bot/mod.rs index 5ae59ac9..a7d02028 100644 --- a/botserver/src/core/bot/mod.rs +++ b/botserver/src/core/bot/mod.rs @@ -1346,73 +1346,32 @@ while let Some(chunk) = stream_rx.recv().await { trace!("Cleared leftover in_analysis state"); } - if !in_analysis { - full_response.push_str(&chunk); - html_buffer.push_str(&chunk); +if !in_analysis { + full_response.push_str(&chunk); - // Check if we should flush the buffer: - // 1. HTML tag pair completed (e.g., , ,
, , ) - // 2. Buffer is large enough (> 500 chars) - // 3. This is the last chunk (is_complete will be true next iteration) - let should_flush = (html_buffer.len() > 1000 - || html_buffer.contains("") - || html_buffer.contains("") - || html_buffer.contains("") - || html_buffer.contains("") - || html_buffer.contains("") - || html_buffer.contains("") - || html_buffer.contains("") - || html_buffer.contains("") - || html_buffer.contains("") - || html_buffer.contains("") - || html_buffer.contains("") - || html_buffer.contains("") - || html_buffer.contains("") - || html_buffer.contains("") - || html_buffer.contains("") - || html_buffer.contains("") - || html_buffer.contains("") - || html_buffer.contains("") - || html_buffer.contains("") - || html_buffer.contains("") - || html_buffer.contains("") - || html_buffer.contains("") - || html_buffer.contains("") - || html_buffer.contains("") - || html_buffer.contains("")) - && !is_inside_html_tag(&html_buffer); + // Send immediately without buffering + let response = BotResponse { + bot_id: message.bot_id.clone(), + user_id: message.user_id.clone(), + session_id: message.session_id.clone(), + channel: message.channel.clone(), + content: chunk.clone(), + message_type: MessageType::BOT_RESPONSE, + stream_token: None, + is_complete: false, + suggestions: Vec::new(), + switchers: Vec::new(), + context_name: None, + context_length: 0, + context_max_length: 0, + }; - if should_flush { - // Sanitize malformed tags (e.g. "< class" -> "