fix(telegram): prevent duplicate messages in groups when streaming disabled

When group_stream=false (default), channels implementing StreamingChannel
still processed chunk events, creating stream messages alongside block
replies — causing each intermediate message to appear twice.

Gate the streaming handler on rc.Streaming so it only activates when
streaming is actually enabled for the run.
This commit is contained in:
viettranx committed 2026-03-27 19:49:33 +07:00
1 parent d3bf16d2de
commit 2bc0f5f14a
1 file changed
+5 -2
+5 -2
View File
@@ -35,8 +35,11 @@ func (m *Manager) HandleAgentEvent(eventType, runID string, payload any) {
ctx = store.WithTenantID(ctx, ta.TenantID())
}
// Forward to StreamingChannel
if sc, ok := ch.(StreamingChannel); ok {
// Forward to StreamingChannel (only when streaming is enabled for this run).
// Without this gate, channels that implement StreamingChannel but have streaming
// disabled (e.g. group_stream=false) would create stream messages AND emit
// block.reply outbound messages, causing duplicate delivery.
if sc, ok := ch.(StreamingChannel); ok && rc.Streaming {
switch eventType {
case protocol.AgentEventRunStarted:
stream, err := sc.CreateStream(ctx, rc.ChatID, true)