From b31e08004ff047194c892478fceb942f663a6352 Mon Sep 17 00:00:00 2001
From: Rodrigo Rodriguez
Date: Thu, 30 Apr 2026 21:32:42 -0300
Subject: [PATCH] remove: HTML tag balancing and buffering - Remove HTML buffer
accumulation - Send LLM chunks immediately without processing - Remove tag
sanitization and balance checks - HTML now streams raw from LLM to client
---
botserver/src/core/bot/mod.rs | 85 +++++++++--------------------------
1 file changed, 22 insertions(+), 63 deletions(-)
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" -> " "