Skip to content

Beta blocker: telegram - partial draft previews can spam multiple visible messages for one turn #84885

Closed

Description

@100yenadmin

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

  1. Run OpenClaw 2026.5.19 with Telegram polling enabled and draft/partial streaming enabled.
  2. Send a Telegram DM that produces a long or repeatedly-updated partial stream.
  3. Observe the Telegram chat and gateway log while the agent turn is still in progress.
  4. 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=1

The 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;
Loading

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.

Activity

  1. clawsweeper commented on May 21, 2026

    @clawsweeper
    Contributor

    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 keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
    • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to 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-blocker label requires explicit maintainer handling.

    Reproducibility: yes. source-level: current main still has a non-final oversized-preview rollover path and tests that expect multiple sendMessage calls. I did not run a live Telegram repro in this read-only pass.

    Next step
    The protected beta-blocker label 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 sendMessage calls. 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:

    • add P1: A beta-blocker Telegram streaming bug can visibly duplicate bot output during a real channel turn.
    • add impact:message-loss: The issue is about duplicated visible Telegram channel messages for one logical reply.
    • add issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.
    • add 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:

    Likely related people:

    • steipete: Current blame for the Telegram draft overflow logic, dispatcher retention callback, and matching tests points to Peter Steinberger in commit 3844513. (role: recent area contributor; confidence: high; commits: 384451343191; files: extensions/telegram/src/draft-stream.ts, extensions/telegram/src/bot-message-dispatch.ts, extensions/telegram/src/draft-stream.test.ts)
    • anagnorisis2peripeteia: The changelog credits prior Telegram over-limit draft-preview continuation work from fix(telegram): chain over-limit stream previews #74508, which is directly adjacent to this overflow behavior. (role: credited related contributor; confidence: medium; files: CHANGELOG.md)
    • scoootscooob: History shows the Telegram channel implementation was moved into 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:

    • No live Telegram repro was run in this read-only review; the reproduction confidence comes from current source, tests, and the reporter's release logs.
    • A fix must preserve valid long final-reply splitting while preventing non-final partial previews from becoming retained visible pages.

    Codex review notes: model gpt-5.5, reasoning high; reviewed against e3b77d6d2c89.

  2. added
    P1High-priority user-facing bug, regression, or broken workflow.
    impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.
    issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.
    clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.
    on May 21, 2026
  3. 100yenadmin commented on May 21, 2026

    @100yenadmin
    ContributorAuthor

    Regression-range note from local v2026.5.18..v2026.5.19 diff and live incident logs:

    • extensions/telegram/src/draft-stream.ts did not change between v2026.5.18 and v2026.5.19; the retained non-final overflow behavior appears older than this release range.
    • The repeated visible sends in the May 21 incident were subsystem=channels/telegram preview transport sends, e.g. message ids 24320..24325, 24327..24332; the durable final path logged separately as subsystem=telegram/send at messageId=24333.
    • Native Telegram tool-progress drafts were added in this range (7cc4258dd5 and follow-ups), but the local config/backups had no streaming.preview.nativeToolProgress, and resolveChannelStreamingPreviewNativeToolProgress(..., defaultValue = false) keeps that path off by default. So the local evidence does not point to native drafts as the primary enabled path.
    • The strongest v2026.5.19-range amplifier is Add Telegram progress preview flows #83847 / d60ab48511 (Add Telegram progress preview flows), because it changes the dispatcher/progress-preview plumbing around extensions/telegram/src/bot-message-dispatch.ts and src/plugin-sdk/channel-streaming.ts while the older draft-stream.ts overflow behavior remains present.
    • The live burst happened during LCM/context recovery churn: replay-like batch refusals, context-overflow-diag, failed LCM runtime LLM override, fallback/truncation retry, then EmbeddedAttemptSessionTakeoverError after 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.

  4. 100yenadmin commented on May 21, 2026

    @100yenadmin
    ContributorAuthor
  5. obviyus commented on May 28, 2026

    @obviyus
    Collaborator

    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:

    • One driver group mention triggered one SUT agent turn.
    • Mock OpenAI received exactly one POST /v1/responses.
    • The mock response streamed delayed oversized partial text chunks.
    • The driver observed the SUT create 3 visible Telegram message objects for that one logical turn, plus 7 edit updates.
    • The first visible preview grew through edits, then a second visible preview was created and edited, then another visible final/tail message appeared.
    • No live OpenAI used. Temp gateway/config/state only. No repro processes left running.

    Verdict: still reproducible on current main; partial Telegram draft streaming can emit multiple visible messages for one turn before final delivery.

  6. locked as resolved and limited conversation to collaborators on May 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority user-facing bug, regression, or broken workflow.beta-blockerPlugin beta-release blocker pending stable cutoff triageclawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions