openclaw - ✅(Solved) Fix Telegram: handle edited_message updates (streaming bot messages appear truncated) [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#72873Fetched 2026-04-28 06:31:06
View on GitHub
Comments
1
Participants
2
Timeline
2
Reactions
0
Timeline (top)
commented ×1cross-referenced ×1

Root Cause

The Telegram channel plugin registers handlers for bot.on("message") and bot.on("channel_post") but does not register an edited_message handler. While edited_message is included in the allowed_updates list (so Telegram does send them), they are silently dropped.

Fix Action

Fixed

PR fix notes

PR #73104: fix(telegram): handle edited message updates

Description (problem / solution / changelog)

Summary

  • Problem: Telegram edited_message updates were included in allowed updates but had no registered handler, so edited/streaming Telegram messages were silently dropped after the initial partial message.
  • Why it matters: Streaming bots commonly edit the same Telegram message as tokens arrive, causing OpenClaw to process only the first truncated chunk.
  • What changed: Added Telegram edited_message handling with per-chatId:messageId debounce so rapid edits coalesce into one final inbound dispatch.
  • What did NOT change (scope boundary): This PR does not rewrite/remove the originally processed message from session history and does not handle edited_channel_post.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Closes #72873
  • Related #20173
  • Related #9656
  • Related #53654
  • This PR fixes a bug or regression

Root Cause (if applicable)

  • Root cause: The Telegram plugin registered handlers for message and channel_post, but not edited_message.
  • Missing detection / guardrail: There was no focused test covering Telegram edited-message updates.
  • Contributing context (if known): edited_message was already present in allowed updates, so Telegram could send these updates but the plugin dropped them.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file: extensions/telegram/src/bot.edited-message.test.ts
  • Scenario the test should lock in: Telegram edited messages are registered, debounced, coalesced by message id, and bot-authored edits are skipped.
  • Why this is the smallest reliable guardrail: The issue is isolated to Telegram handler registration and dispatch behavior, so focused extension tests cover the fix without needing a full live Telegram test.
  • Existing test that already covers this (if any): None.
  • If no new test is added, why not: N/A — new focused tests were added.

User-visible / Behavior Changes

Telegram edited messages are now processed after a short debounce. For streaming edits, OpenClaw receives the final edited version instead of only the initial partial message.

Diagram (if applicable)

Before:
Telegram edited_message -> no handler -> dropped

After:
Telegram edited_message -> debounce by chatId:messageId -> latest edit dispatched

AI-Assisted

  • AI-assisted (Claude Code / claude-sonnet-4-6)
  • Testing: fully tested — 5 focused unit tests added, pnpm check:changed and pnpm test:changed pass
  • Prompts/session log: available on request
  • I understand what the code does
  • codex review --base origin/main: not run (no Codex access)

Changed files

  • extensions/telegram/src/bot-handlers.runtime.ts (modified, +87/-0)
  • extensions/telegram/src/bot.edited-message.test.ts (added, +188/-0)
  • extensions/telegram/src/bot.types.ts (modified, +1/-0)
RAW_BUFFERClick to expand / collapse

Problem

When another bot sends a streaming message in a Telegram group (e.g. editing the same message repeatedly as tokens arrive), OpenClaw only processes the initial message update and ignores all subsequent edited_message updates. This results in the agent seeing only the first partial chunk of the streamed message.

Root Cause

The Telegram channel plugin registers handlers for bot.on("message") and bot.on("channel_post") but does not register an edited_message handler. While edited_message is included in the allowed_updates list (so Telegram does send them), they are silently dropped.

Expected Behavior

When a message is edited (especially by another bot doing streaming output), OpenClaw should process the final version of the edited message as inbound content.

Implementation Considerations

  • Debounce required: Streaming bots may edit a message dozens of times in quick succession. A naive handler would flood the inbound pipeline. A debounce mechanism (e.g. wait 2-3 seconds after the last edit before processing) is needed.
  • Deduplication: The original message and subsequent edited_message updates share the same message_id. The dedupe cache and session handling need to account for this — either replace the original inbound content or only process the edit if it arrives after the initial message was already handled.
  • Scope: This affects bot-to-bot communication in groups (e.g. two OpenClaw instances) and also human message edits (separate but related use case).

Related Issues

  • #20173 — Discord: Re-process edited user messages
  • #9656 — Signal: Handle message edits
  • #53654 — Discord: Support messageUpdate and messageDelete events

extent analysis

TL;DR

Register an edited_message handler and implement a debounce mechanism to process the final version of edited messages.

Guidance

  • Register a handler for bot.on("edited_message") to catch edited message updates.
  • Implement a debounce mechanism (e.g., wait 2-3 seconds after the last edit) to prevent flooding the inbound pipeline.
  • Update the dedupe cache and session handling to account for the shared message_id between the original message and subsequent edited_message updates.
  • Consider the scope of this fix, including bot-to-bot communication in groups and human message edits.

Example

bot.on("edited_message", (msg) => {
  // Debounce mechanism: wait 2-3 seconds after the last edit
  setTimeout(() => {
    // Process the edited message
    processEditedMessage(msg);
  }, 2000);
});

Notes

The implementation of the debounce mechanism and dedupe cache updates will depend on the specific requirements and existing codebase of OpenClaw.

Recommendation

Apply a workaround by registering an edited_message handler and implementing a debounce mechanism, as this will allow OpenClaw to process the final version of edited messages without requiring a full version upgrade.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix Telegram: handle edited_message updates (streaming bot messages appear truncated) [1 pull requests, 1 comments, 2 participants]