Skip to content

Telegram streaming: intermediate text blocks between tool calls are silently lost (overwritten by final block) #87326

Description

@AbdelftahZowail

Problem

When the model produces text → calls tools → produces more text → calls more tools → delivers final text, all intermediate text blocks share the same streaming preview message and are overwritten by subsequent blocks. Only the final text is visible to the user. Meaningful intermediate content (summaries, findings, explanations) is silently lost.

This is a regression from PR #32890.

Steps to reproduce

  1. Ask the agent to browse multiple websites in one turn
  2. Agent writes "Let me check site A..." → streams to preview
  3. Agent calls browser tools
  4. Agent writes "Site A shows X. Now checking site B..." → overwrites preview
  5. Agent calls more tools
  6. Agent writes "Done. Sites A and B show X and Y." → overwrites preview again, finalizes
  7. User sees only: "Let me check site A..." and "Done." — the intermediate summary is lost

Any turn where the model produces multiple meaningful text blocks separated by tool calls will silently lose text.

Root cause

PR #32890 removed the archive + forceNewMessage logic from onAssistantMessageStart in bot-message-dispatch.ts to prevent inter-tool narration from leaking into chat as separate messages. But it removed ALL interleaved delivery — not just the transient narration.

The stream now reuses a single preview across all text blocks in a turn. The streamText function in lane-delivery-text-deliverer.ts updates that preview in place for non-final blocks (isFinal=false) but never commits them as real messages before the final block overwrites them. The onAssistantMessageStart handler only calls rotateLaneForNewMessage when the lane is already finalized — which never happens for intermediate blocks.

Relevant code

  • extensions/telegram/src/bot-message-dispatch.ts → onAssistantMessageStart handler — only rotates when answerLane.finalized is true
  • extensions/telegram/src/lane-delivery-text-deliverer.ts → streamText() — updates preview in place for non-final blocks, only commits on isFinal=true
  • extensions/telegram/src/draft-stream.ts → onSupersededPreview callback — deletes superseded previews when forceNewMessage() is called

Prior art

Expected behavior

Text blocks delivered with info.kind === "block" (non-final) should either be finalized as real messages before a new text block starts, or be cumulatively preserved so the user sees all text the model produced.

Environment

  • OpenClaw: 2026.5.26 (10ad3aa) — also reproducible on main as of 2026-05-27
  • Channel: Telegram (streaming mode: partial)

Activity

  1. clawsweeper commented on May 27, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed May 27, 2026, 11:09 AM ET / 15:09 UTC.

    Summary
    Keep open: current main still has the reported Telegram preview behavior, and the fix direction needs maintainer product judgment because preserving inter-tool text can conflict with the existing suppression work for transient tool narration.

    Reproducibility: yes. for source-level reproduction: current Telegram lane delivery tests and code show a non-final block preview update followed by a final update on the same message. I did not establish a live Telegram run in this read-only review.

    Next step
    A fix is likely needed, but maintainers should first decide the durable-block contract so a repair does not undo the suppression behavior tracked in related inter-tool narration work.

    Review details

    Best possible solution:

    Define which inter-tool text is durable user-facing block content, then preserve only that content in Telegram without reopening transient tool/progress narration leaks.

    Do we have a high-confidence way to reproduce the issue?

    Yes for source-level reproduction: current Telegram lane delivery tests and code show a non-final block preview update followed by a final update on the same message. I did not establish a live Telegram run in this read-only review.

    Is this the best way to solve the issue?

    Unclear: preserving all interleaved text would not be the safest fix by itself because prior work intentionally suppresses transient tool narration. The maintainable path needs a narrower durable-block contract before code changes.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • A direct fix that materializes every inter-tool text block could reintroduce the transient narration leak tracked in Text between tool calls leaks to messaging channels #25592.
    • I did not run a live Telegram reproduction in this read-only review; the current conclusion is based on source, docs, tests, and provided issue context.

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

    Label changes

    Label changes:

    • add P1: The issue describes current Telegram channel message loss for multi-tool turns in the latest release and current main.
    • add impact:message-loss: Non-final text blocks can be overwritten by later preview/final text, leaving user-visible intermediate content absent from chat history.
    • add issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.
    • add clawsweeper:source-repro: Current issue advisory state selects this label.
    • add clawsweeper:no-new-fix-pr: Current issue advisory state selects this label.
    • add clawsweeper:fix-shape-clear: Current issue advisory state selects this label.
    • add clawsweeper:needs-maintainer-review: Current issue advisory state selects this label.
    • add clawsweeper:needs-product-decision: Current issue advisory state selects this label.

    Label justifications:

    • P1: The issue describes current Telegram channel message loss for multi-tool turns in the latest release and current main.
    • impact:message-loss: Non-final text blocks can be overwritten by later preview/final text, leaving user-visible intermediate content absent from chat history.
    Evidence reviewed

    Acceptance criteria:

    • node scripts/run-vitest.mjs extensions/telegram/src/lane-delivery.test.ts extensions/telegram/src/bot-message-dispatch.test.ts
    • Live Telegram partial-streaming proof for a text -> tool -> text -> tool -> final turn after the product contract is chosen

    What I checked:

    Likely related people:

    • Vincent Koc: Current shallow blame for the Telegram deliverer, dispatch, tests, and streaming docs points to commit 545ad7f; the grafted checkout limits older attribution. (role: recent area contributor; confidence: medium; commits: 545ad7f256e2; files: extensions/telegram/src/lane-delivery-text-deliverer.ts, extensions/telegram/src/bot-message-dispatch.ts, extensions/telegram/src/lane-delivery.test.ts)
    • Rubén Cuevas: Commit 996eb9a changed Telegram stale reply delivery fencing in the same dispatch surface and tests. (role: recent adjacent contributor; confidence: medium; commits: 996eb9a024d0; files: extensions/telegram/src/bot-message-dispatch.ts, extensions/telegram/src/bot-message-dispatch.test.ts)
    • scoootscooob: Commit e5bca08 moved the Telegram implementation into extensions/telegram and introduced the current extension file layout in available history. (role: refactor author; confidence: low; commits: e5bca0832fbd; files: extensions/telegram/src/bot-message-dispatch.ts, extensions/telegram/src/lane-delivery-text-deliverer.ts, extensions/telegram/src/lane-delivery.test.ts)
    • Sid-Qin: The provided context shows a closed unmerged PR explicitly discussing reuse of one Telegram preview across tool-use rounds and only final text persisting, which is directly related to this behavior tradeoff. (role: related prior PR author; confidence: low; commits: 7c87c674317a; files: extensions/telegram/src/bot-message-dispatch.ts, extensions/telegram/src/bot-message-dispatch.test.ts)
    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.
  2. WarrenJones commented on May 27, 2026

    @WarrenJones
  3. AbdelftahZowail commented on May 27, 2026

    @AbdelftahZowail
    Author

    To illustrate the difference between useful content and narration that should stay suppressed, here's a concrete example from a real interaction:

    Real interaction: multi-site browsing

    User: "Can you browse a few sites and tell me what you find?"

    Agent internal output:

    1. Text: "Let me check a few sites real quick"
    2. → browser_navigate("https://httpbin.org/headers")
    3. Text: "httpbin loaded fine, JSON response visible. Now let me check Hacker News"
    4. → browser_navigate("https://news.ycombinator.com")
    5. → browser_extract_content(...)
    6. Text: "HN front page loaded with 30 stories. Top post is about AI fatigue with 914 points. Now checking one more page"
    7. → browser_navigate("https://httpbin.org/html")
    8. → browser_get_html("body")
    9. Text: "httpbin/html returned a Moby-Dick excerpt. Here's the summary: httpbin works, HN loaded 30 stories, httpbin/html renders correctly. Browser is good."
    10. Text: "And closed. What next?"

    What the user actually saw on Telegram:

    • "Let me check a few sites real quick"
    • "And closed. What next?"

    All three intermediate content blocks (steps 3, 6, 9) were silently lost because they shared the same preview message and each one overwrote the previous. The user never saw the findings they asked for.

    The UX tradeoff

    What SHOULD be suppressed (narration): plain tool-play commentary that adds no value outside the agent loop — e.g. "Now I will navigate to HN", "Let me extract the content", "I should check the status code". These were the target of PR #32890 and suppressing them is correct.

    What currently gets suppressed but SHOULD be delivered: any intermediate text that communicates findings, results, or context to the user — e.g. "HN shows X story with Y points", "Site B is down, trying alternative", "Found 3 matches so far, continuing search". These are real content that the user explicitly asked for.

    The challenge: these two categories look identical to the streaming pipeline. Both are info.kind === "block" text chunks between tool calls. The current code treats them both the same — stream to preview, never commit, let the final block overwrite everything.

    One possible direction: if a non-final text block exceeds a certain length or contains substantive content patterns, it could be worth committing as a real message rather than living only in the transient preview.

  4. anagnorisis2peripeteia commented on May 27, 2026

    @anagnorisis2peripeteia
    Contributor

    interested in how we can collaborate here.

    It's easier imo to define the reply block inbetween tool blocks as "reasoning" that belongs in the reasoning lane in telegram and that's why in 87072 I aim to recreate what one might see in a cli like claude code or codex with all the whirrs and dings that make you feel like it's running and doing something

  5. rollingshmily commented on May 31, 2026

    @rollingshmily

    Same issue here — OpenClaw 2026.5.28 on Telegram.

    Every turn that involves tool calls + intermediate text blocks, the intermediate content gets silently overwritten. User sees nothing between tool calls, only the final block survives.

    This is a severe regression that makes basic Telegram chat almost unusable. I've had to disable streaming entirely (streaming.mode: off) as a workaround, which is not ideal.

    A lot of us use OpenClaw primarily through Telegram — would really appreciate prioritizing this fix. The root cause is clear (PR #32890 removed archive + forceNewMessage logic), should be relatively straightforward to patch.

    Thanks!

  6. AbdelftahZowail commented on Jun 7, 2026

    @AbdelftahZowail
    Author

    Same issue here — OpenClaw 2026.5.28 on Telegram.

    Every turn that involves tool calls + intermediate text blocks, the intermediate content gets silently overwritten. User sees nothing between tool calls, only the final block survives.

    This is a severe regression that makes basic Telegram chat almost unusable. I've had to disable streaming entirely (streaming.mode: off) as a workaround, which is not ideal.

    A lot of us use OpenClaw primarily through Telegram — would really appreciate prioritizing this fix. The root cause is clear (PR #32890 removed archive + forceNewMessage logic), should be relatively straightforward to patch.

    Thanks!

    I don't really understand how OSS contribution works here on GitHub but I think they're working on it as well speak so hopefully it'll be out soon

  7. locked as resolved and limited conversation to collaborators on Jun 11, 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

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions