Skip to content

fix(telegram): use message transport for all DM streaming lanes#38906

Closed
gambletan wants to merge 1 commit intoopenclaw:mainfrom
gambletan:fix/33453-telegram-dm-duplicate-streaming
Closed

fix(telegram): use message transport for all DM streaming lanes#38906
gambletan wants to merge 1 commit intoopenclaw:mainfrom
gambletan:fix/33453-telegram-dm-duplicate-streaming

Conversation

@gambletan
Copy link
Contributor

Summary

Fixes #33453

When channels.telegram.streaming is set to "partial", Telegram DM conversations show duplicate messages — the streaming preview plus a separate final message.

Root cause: The answer lane in DMs uses draft transport (sendMessageDraft), which doesn't track a streamMessageId. When the final delivery arrives, resolvePreviewTarget() can't find the preview message to edit in place, so deliverLaneText falls through to sendPayload() and sends a duplicate.

The reasoning lane already had a fix for this, but the answer lane was still using draft transport.

Fix: Remove the laneName === "reasoning" guard so all lanes use message transport in DMs.

Test plan

  • Updated existing test to verify both lanes use "message" transport in DMs
  • All 139 test files pass (1150 tests)

🤖 Generated with Claude Code

…claw#33453)

Draft transport in DMs doesn't track streamMessageId, so
resolvePreviewTarget() misses the preview on final delivery and sends a
duplicate message. Extend the existing reasoning-lane message transport
fix to all lanes in DMs.
@openclaw-barnacle openclaw-barnacle bot added channel: telegram Channel integration: telegram size: XS labels Mar 7, 2026
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 7, 2026

Greptile Summary

This PR fixes a duplicate-message bug in Telegram DM conversations when channels.telegram.streaming is set to "partial".

Root cause verified: The answer lane was using draft transport ("auto"), which doesn't track a streamMessageId. When the final delivery arrived, resolvePreviewTarget() couldn't locate the preview message to edit in place, falling through to sendPayload() and sending a duplicate.

Fix verified: The implementation correctly removes the laneName === "reasoning" guard, applying message transport ("message" preview transport using sendMessage + editMessageText) to all lanes in DMs when streaming is enabled (canStreamAnswerDraft is true). This ensures both answer and reasoning lanes track a streamMessageId and prevent duplicates.

Test coverage verified: The test "uses message preview transport for all DM lanes when streaming is active" correctly verifies that both answer (call[0]) and reasoning (call[1]) lanes use previewTransport: "message" in DM contexts. All 139 test files (1150 tests) pass.

No issues found. The implementation is minimal, focused, and correct.

Confidence Score: 5/5

  • This PR is safe to merge — it is a minimal, single-condition fix with no regressions.
  • This PR makes a focused, verified fix by removing a guard condition that restricted message transport to only the reasoning lane in DMs. The change is well-tested: the updated test explicitly verifies both answer and reasoning lanes now use message transport in DM contexts when streaming is active. The logic is correct (applies to both lanes via a shared condition in the createDraftLane function), group chat and non-streaming paths are unaffected, and all 1150 tests pass. No new code paths are introduced; this is purely a predicate simplification that unifies behavior across lanes.
  • No files require special attention.

Last reviewed commit: e14a678

Copy link

@mdlmarkham mdlmarkham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: Telegram DM Streaming Fix ✅

Verdict: Minimal fix with good test coverage. Ready to merge.

Problem

When channels.telegram.streaming: "partial" is set, DM conversations show duplicate messages:

  1. Streaming preview message
  2. Final delivery message

Root Cause

The answer lane in DMs was using sendMessageDraft (draft transport), which doesn't track streamMessageId. When final delivery arrives, resolvePreviewTarget() can't find the preview to edit, so it sends a new message instead.

The reasoning lane already had the fix (using message transport), but answer lane was missed.

The Fix

Remove the laneName === "reasoning" guard so all lanes use message transport in DMs:

// Before: only reasoning lane used message transport
if (laneName === "reasoning") {
  // message transport
}

// After: all lanes use message transport in DMs
transport = "message"

Test Coverage

  • ✅ Test updated to verify both lanes use "message" transport in DMs
  • ✅ All 139 test files pass (1150 tests)

Why Draft Transport Exists

Draft transport (sendMessageDraft) is for editing the same message repeatedly — useful for streaming updates in channels/groups. But in DMs:

  • Message transport works the same way
  • Streaming preview can be tracked and edited
  • No duplication

Edge Cases

  1. Group chats: Still use draft transport (correct) — the fix is DM-only
  2. Multiple streaming lanes: Both reasoning and answer use message transport in DMs ✅

Recommendation: Approve. Fixes duplicate messages in Telegram DMs, minimal change.

@steipete
Copy link
Contributor

steipete commented Mar 8, 2026

Landed on a505be7 from source commit e14a678.

What was done:

  • rebased/landed on latest 'main' via temp branch
  • kept DM-lane message-transport parity fix + updated dispatch test
  • added changelog entry with contributor + PR attribution
  • ran full gate before commit: 'pnpm lint && pnpm build && pnpm test'

Thanks @gambletan for the fix.

steipete added a commit that referenced this pull request Mar 8, 2026
Landed from contributor PR #38906 by @gambletan.

Co-authored-by: gambletan <ethanchang32@gmail.com>
@steipete steipete closed this Mar 8, 2026
vincentkoc pushed a commit to BryanTegomoh/openclaw-fork that referenced this pull request Mar 8, 2026
Landed from contributor PR openclaw#38906 by @gambletan.

Co-authored-by: gambletan <ethanchang32@gmail.com>
ziomancer pushed a commit to ziomancer/openclaw that referenced this pull request Mar 8, 2026
Landed from contributor PR openclaw#38906 by @gambletan.

Co-authored-by: gambletan <ethanchang32@gmail.com>
openperf pushed a commit to openperf/moltbot that referenced this pull request Mar 8, 2026
Landed from contributor PR openclaw#38906 by @gambletan.

Co-authored-by: gambletan <ethanchang32@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Telegram Duplicate Messages with Partial Streaming

3 participants