openclaw - 💡(How to fix) Fix Telegram: Duplicate message storm during LLM API outages (missing message_id deduplication) [3 comments, 3 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#58611Fetched 2026-04-08 02:00:14
View on GitHub
Comments
3
Participants
3
Timeline
3
Reactions
0
Timeline (top)
commented ×2cross-referenced ×1

Root Cause

Telegram assigns a stable message_id to every message. OpenClaw appears to not deduplicate inbound Telegram messages by message_id, so each retry is treated as a new message and processed independently once the LLM recovers.

RAW_BUFFERClick to expand / collapse

Problem

When the upstream LLM API (e.g. Anthropic) experiences degradation or timeouts, Telegram retries webhook delivery for unacknowledged messages. If OpenClaw fails to return a 200 OK before the LLM call completes (or times out), Telegram will retry the same message repeatedly — potentially 50+ times — all of which queue up and flush simultaneously when the API recovers.

Observed Behavior

During an Anthropic API incident on 2026-03-31 (~19:41–22:09 UTC), a single Telegram message was delivered approximately 50 times into the same session. All duplicates carried the same message_id from Telegram metadata.

Root Cause

Telegram assigns a stable message_id to every message. OpenClaw appears to not deduplicate inbound Telegram messages by message_id, so each retry is treated as a new message and processed independently once the LLM recovers.

Expected Behavior

OpenClaw should:

  1. Acknowledge the Telegram webhook with 200 OK immediately on receipt (before LLM processing), and/or
  2. Deduplicate inbound messages by message_id within a short TTL window (e.g. 5 minutes) to prevent duplicate processing during retry floods

Impact

  • Massively inflated token usage (50x context injected)
  • Session context pollution
  • Potentially triggers unwanted repeated actions if the message contained a command

Suggested Fix

Add a short-lived deduplication cache (e.g. in-memory LRU or a simple Set with TTL) keyed on provider:message_id. Any message with a seen ID within the TTL window should be dropped silently after the initial 200 ACK is sent.

Environment

  • OpenClaw v2026.3.23-2
  • Telegram channel provider
  • Hosted on VPS (Docker)

extent analysis

TL;DR

Implement a deduplication cache in OpenClaw to prevent processing of duplicate Telegram messages based on their message_id.

Guidance

  • Verify that the message_id is consistently provided by Telegram for each message, including retries, to ensure the deduplication mechanism works as expected.
  • Consider implementing a short-lived cache (e.g., in-memory LRU or a simple Set with TTL) to store seen message_ids and drop duplicates within a defined TTL window (e.g., 5 minutes).
  • Ensure that the initial 200 OK acknowledgement is sent immediately upon receiving a Telegram webhook, before any LLM processing, to prevent Telegram from retrying the message delivery.
  • Review the OpenClaw documentation and codebase to determine the best approach for integrating the deduplication cache, potentially leveraging existing caching mechanisms or libraries.

Example

# Simplified example of a deduplication cache using a set with TTL
import time

class DeduplicationCache:
    def __init__(self, ttl=300):  # 5 minutes
        self.cache = {}
        self.ttl = ttl

    def add(self, message_id):
        self.cache[message_id] = time.time()

    def is_duplicate(self, message_id):
        if message_id in self.cache:
            if time.time() - self.cache[message_id] < self.ttl:
                return True
            else:
                del self.cache[message_id]
        return False

# Usage
cache = DeduplicationCache()
if not cache.is_duplicate(message_id):
    cache.add(message_id)
    # Process the message
else:
    # Drop the duplicate message
    pass

Notes

The provided example is a simplified illustration of a deduplication cache and may require modifications to fit the specific requirements and implementation of OpenClaw.

Recommendation

Apply a workaround by implementing a deduplication cache, as upgrading to a fixed version is not mentioned in the issue. This approach addresses the root cause of the problem and prevents duplicate message processing.

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