Repository navigation
Description
Bug type
Behavior bug (incorrect output/state without crash)
Beta release blocker
Yes
Summary
Telegram streaming.mode="partial" can emit many visible sendMessage previews for a single inbound turn instead of keeping one draft preview and one final reply.
Steps to reproduce
- Run OpenClaw
2026.5.19with Telegram polling enabled and draft/partial streaming enabled. - Send a Telegram DM that produces a long or repeatedly-updated partial stream.
- Observe the Telegram chat and gateway log while the agent turn is still in progress.
- A single inbound user message can result in many visible bot messages before the durable final send.
Expected behavior
Partial streaming should maintain at most one mutable visible draft per active turn, then finalize or replace it with the durable final reply. Draft overflow should not roll over into retained visible messages before finalization.
Actual behavior
On a local 2026.5.19 incident, one Telegram DM turn produced a burst of visible Telegram sends in the same chat:
/tmp/openclaw/openclaw-2026-05-21.log
2026-05-21T15:07:45+07:00 telegram sendMessage ok chat=<redacted-dm> message=24320
2026-05-21T15:07:46+07:00 telegram sendMessage ok chat=<redacted-dm> message=24321
2026-05-21T15:07:47+07:00 telegram sendMessage ok chat=<redacted-dm> message=24322
2026-05-21T15:07:48+07:00 telegram sendMessage ok chat=<redacted-dm> message=24323
2026-05-21T15:07:49+07:00 telegram sendMessage ok chat=<redacted-dm> message=24324
2026-05-21T15:08:35+07:00 telegram sendMessage ok chat=<redacted-dm> message=24325
2026-05-21T15:10:27+07:00 telegram sendMessage ok chat=<redacted-dm> message=24327
2026-05-21T15:10:28+07:00 telegram sendMessage ok chat=<redacted-dm> message=24328
2026-05-21T15:10:31+07:00 telegram sendMessage ok chat=<redacted-dm> message=24329
2026-05-21T15:10:50+07:00 telegram sendMessage ok chat=<redacted-dm> message=24330
2026-05-21T15:10:50+07:00 telegram sendMessage ok chat=<redacted-dm> message=24331
2026-05-21T15:10:51+07:00 telegram sendMessage ok chat=<redacted-dm> message=24332
2026-05-21T15:10:53+07:00 telegram outbound send ok accountId=default chatId=<redacted-dm> messageId=24333 operation=sendMessage deliveryKind=text chunkCount=1The durable outbound path only logged the final send (telegram outbound send ok ... messageId=24333). The earlier channels/telegram sendMessage ok entries appear to be draft/preview transport sends, not durable final delivery ledger entries.
OpenClaw version
2026.5.19
Operating system
macOS 26 / Darwin arm64
Install method
Global OpenClaw gateway managed by launchd (ai.openclaw.gateway)
Model
OpenRouter/OpenAI GPT-5 family route in the affected session; exact final model for every preview send is NOT_ENOUGH_INFO.
Provider / routing chain
Telegram polling -> OpenClaw gateway -> embedded agent -> OpenRouter/OpenAI route
Additional provider/model setup details
The local mitigation was to set both:
{
"channels.telegram.streaming.mode": "off",
"channels.telegram.accounts.default.streaming.mode": "off"
}After restart, openclaw channels status --json reported Telegram polling connected and event loop not degraded.
Logs, screenshots, and evidence
Source-level path of concern:
- extensions/telegram/src/draft-stream.ts:206 handles renderedText.length > maxChars.
- extensions/telegram/src/draft-stream.ts:207-223 retains the old preview and resets to a new message when lastDeliveredText.length > deliveredTextOffset.
- extensions/telegram/src/draft-stream.ts:225-233 splits an oversized first rendered preview by recursively sending chunks.
Current behavior allows the overflow/retention path while streamState.final is false, so non-final partial previews can become multiple retained visible Telegram messages.
Related outbound paths:
- extensions/telegram/src/draft-stream.ts:125-135 sends preview messages through api.sendMessage.
- src/channels/turn/durable-delivery.ts and src/channels/message/send.ts handle durable final delivery.flowchart TD
A[Telegram inbound DM] --> B[Agent turn starts]
B --> C[Partial draft stream update]
C --> D{Rendered preview > Telegram max?}
D -- no --> E[edit existing preview]
D -- yes, non-final --> F[roll over / send new visible preview]
F --> C
B --> G[Final assistant reply]
G --> H[Durable final send]
classDef bad fill:#ffd6d6,stroke:#cc3333,color:#111;
class F bad;
Impact and severity
Affected: Telegram users with partial streaming enabled.
Severity: High / beta blocker for Telegram reliability. The user sees repeated bot messages for one turn and may believe the agent is looping.
Frequency: Observed during the local 2026.5.19 Eva incident; deterministic unit-level risk exists from the overflow code path.
Consequence: Duplicate visible replies, confusing chat state, and extra outbound Telegram sends.
Additional information
Related but not identical: #75498 covers Web UI-only final delivery and partial streaming ambiguity. This issue is the narrower visible-spam/preview-rollover failure mode: non-final draft overflow should not retain and send multiple visible preview messages.
Suggested fix shape: gate the rollover/chained-message path on finalization. For non-final partial previews, keep a single preview message and truncate/coalesce the preview until the final response is ready; only split/retain overflow pages for the final reply.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon May 21, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve.
Workflow note: Future ClawSweeper reviews update this same comment in place.
How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.Summary
Keep open. Current main still contains the non-final Telegram draft overflow path that can rotate into retained visible preview messages, and the
beta-blockerlabel requires explicit maintainer handling.Reproducibility: yes. source-level: current main still has a non-final oversized-preview rollover path and tests that expect multiple
sendMessagecalls. I did not run a live Telegram repro in this read-only pass.Next step
The protected
beta-blockerlabel keeps this in maintainer-owned Telegram release triage rather than automatic cleanup or repair queuing.Review details
Best possible solution:
Update Telegram draft streaming so non-final partials coalesce or truncate into one editable preview, reserve chaining/retention for finalization, and add focused unit coverage plus live Telegram proof.
Do we have a high-confidence way to reproduce the issue?
Yes, source-level: current main still has a non-final oversized-preview rollover path and tests that expect multiple
sendMessagecalls. I did not run a live Telegram repro in this read-only pass.Is this the best way to solve the issue?
Yes, the suggested direction is the maintainable fix: gate rollover/retention on finalization and keep non-final partial previews to one mutable message while preserving long final splitting.
Label changes:
P1: A beta-blocker Telegram streaming bug can visibly duplicate bot output during a real channel turn.impact:message-loss: The issue is about duplicated visible Telegram channel messages for one logical reply.issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.clawsweeper:source-repro: Current issue advisory state selects this label.Label justifications:
P1: A beta-blocker Telegram streaming bug can visibly duplicate bot output during a real channel turn.impact:message-loss: The issue is about duplicated visible Telegram channel messages for one logical reply.What I checked:
sendOrEditStreamMessagehandlesrenderedText.length > maxCharswithout checkingstreamState.final, advancesdeliveredTextOffset, resets to a new message, marks the old previewretain: true, and recurses into another send/edit path. (extensions/telegram/src/draft-stream.ts:206, e3b77d6d2c89)onSupersededPreviewcallback returns without deleting the old preview whensuperseded.retainis set, so rollover pages remain visible. (extensions/telegram/src/bot-message-dispatch.ts:576, e3b77d6d2c89)sendMessagetwice and separately expect overflow preview pages to be retained. (extensions/telegram/src/draft-stream.test.ts:402, e3b77d6d2c89)partialmode as a single preview replaced with the latest text, which conflicts with repeated retained non-final preview sends. Public docs:docs/concepts/streaming.md. (docs/concepts/streaming.md:126, e3b77d6d2c89)extensions/telegram/src/draft-stream.ts:206, 384451343191)Likely related people:
extensions/telegram/src/draft-stream.ts,extensions/telegram/src/bot-message-dispatch.ts,extensions/telegram/src/draft-stream.test.ts)CHANGELOG.md)extensions/in commit e5bca08, making this person relevant for file-history routing but not the current overflow behavior. (role: historical migration contributor; confidence: low; commits: e5bca0832fbd; files:extensions/telegram/src/draft-stream.ts)Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against e3b77d6d2c89.
100yenadmin commentedon May 21, 2026
Regression-range note from local
v2026.5.18..v2026.5.19diff and live incident logs:extensions/telegram/src/draft-stream.tsdid not change betweenv2026.5.18andv2026.5.19; the retained non-final overflow behavior appears older than this release range.subsystem=channels/telegrampreview transport sends, e.g. message ids24320..24325,24327..24332; the durable final path logged separately assubsystem=telegram/sendatmessageId=24333.7cc4258dd5and follow-ups), but the local config/backups had nostreaming.preview.nativeToolProgress, andresolveChannelStreamingPreviewNativeToolProgress(..., defaultValue = false)keeps that path off by default. So the local evidence does not point to native drafts as the primary enabled path.d60ab48511(Add Telegram progress preview flows), because it changes the dispatcher/progress-preview plumbing aroundextensions/telegram/src/bot-message-dispatch.tsandsrc/plugin-sdk/channel-streaming.tswhile the olderdraft-stream.tsoverflow behavior remains present.context-overflow-diag, failed LCM runtime LLM override, fallback/truncation retry, thenEmbeddedAttemptSessionTakeoverErrorafter session rotation. That suggests preview streams should also be cancelled/suppressed while a turn enters fallback/compaction/session-takeover recovery, not only fixed at final delivery.Current fix direction still looks right: keep non-final partial previews to one mutable/coalesced message, reserve split/retained pages for finalization, and add coverage for preview cleanup/cancellation on run error or context-engine recovery.
100yenadmin commentedon May 21, 2026
@obviyus
obviyus commentedon May 28, 2026
Maintainer E2E repro on current
main(3fb67467fa16) with the Telegram bot-to-bot harness and mock OpenAI. All Telegram identifiers and local paths redacted.Proof summary:
POST /v1/responses.Verdict: still reproducible on current
main; partial Telegram draft streaming can emit multiple visible messages for one turn before final delivery.