mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-10-14 06:17:41 +00:00
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:
1 parent
d3bf16d2de
commit
2bc0f5f14a
1 file changed
+5
-2
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user