Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
fix: include _stream_id in stream delta coalescing key (#4063)
axelray-dev66fc54421cc4
diff --git a/nanobot/channels/manager.py b/nanobot/channels/manager.pyindex 9eff648e3..3294afc07 100644--- a/nanobot/channels/manager.py+++ b/nanobot/channels/manager.py@@ -396,7 +396,7 @@ class ChannelManager:def _coalesce_stream_deltas(self, first_msg: OutboundMessage) -> tuple[OutboundMessage, list[OutboundMessage]]:- """Merge consecutive _stream_delta messages for the same (channel, chat_id).+ """Merge consecutive _stream_delta messages for the same (channel, chat_id, _stream_id).This reduces the number of API calls when the queue has accumulated multipledeltas, which happens when LLM generates faster than the channel can process.@@ -404,7 +404,7 @@ class ChannelManager:Returns:tuple of (merged_message, list_of_non_matching_messages)"""- target_key = (first_msg.channel, first_msg.chat_id)+ target_key = (first_msg.channel, first_msg.chat_id, first_msg.metadata.get("_stream_id"))combined_content = first_msg.contentfinal_metadata = dict(first_msg.metadata or {})non_matching: list[OutboundMessage] = []@@ -418,7 +418,7 @@ class ChannelManager:break# Check if this message belongs to the same stream- same_target = (next_msg.channel, next_msg.chat_id) == target_key+ same_target = (next_msg.channel, next_msg.chat_id, next_msg.metadata.get("_stream_id") if next_msg.metadata else None) == target_keyis_delta = next_msg.metadata and next_msg.metadata.get("_stream_delta")is_end = next_msg.metadata and next_msg.metadata.get("_stream_end")