openclaw - 💡(How to fix) Fix Gateway replays stale queued messages after restart [1 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#55564Fetched 2026-04-08 01:37:56
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0

After a gateway restart (e.g. VPS reboot, openclaw gateway restart, or service crash), the gateway delivers all queued/pending outbound messages at once. This creates a flood of stale messages that are no longer relevant.

Root Cause

After a gateway restart (e.g. VPS reboot, openclaw gateway restart, or service crash), the gateway delivers all queued/pending outbound messages at once. This creates a flood of stale messages that are no longer relevant.

Fix Action

Workaround

None currently. Users must manually /stop to halt the flood.

RAW_BUFFERClick to expand / collapse

Description

After a gateway restart (e.g. VPS reboot, openclaw gateway restart, or service crash), the gateway delivers all queued/pending outbound messages at once. This creates a flood of stale messages that are no longer relevant.

Steps to Reproduce

  1. Have an active conversation with the agent via Telegram (or any channel)
  2. Reboot the VPS or restart the gateway service
  3. After the gateway comes back online, all pending messages from before the restart are delivered to the channel simultaneously

Observed Behavior

  • ~20+ stale messages delivered all at once, all with the same timestamp
  • Messages reference work that was already completed hours ago
  • Users see a confusing flood of old context that looks like the agent "went nuts"
  • Had to use /stop to cut it off

Expected Behavior

Messages queued before a restart should either:

  • Be dropped if they exceed a configurable TTL (e.g. 60 seconds)
  • Be silently discarded on restart
  • At minimum, have a config option like gateway.delivery.maxAgeMs to control this

Environment

  • OpenClaw 2026.3.24
  • Ubuntu 22.04 (ARM64)
  • Channel: Telegram (forum/topic mode)
  • Gateway runs as systemd user service

Workaround

None currently. Users must manually /stop to halt the flood.

Suggestion

Add a gateway.delivery.staleTTLMs config option (default ~60000ms) that drops queued messages older than the threshold on gateway startup. This would prevent stale message replay while still allowing brief network interruptions to recover gracefully.

extent analysis

Fix Plan

To address the issue of stale messages being delivered after a gateway restart, we can implement a configurable TTL (time to live) for queued messages. Here are the steps:

  • Add a new configuration option gateway.delivery.staleTTLMs with a default value of 60000ms (1 minute)
  • Modify the message queue to check the age of each message on gateway startup
  • Drop messages that exceed the configured TTL

Example code snippet in Python:

import time

class MessageQueue:
    def __init__(self, config):
        self.config = config
        self.messages = []

    def add_message(self, message):
        self.messages.append((message, time.time()))

    def start(self):
        current_time = time.time()
        stale_ttl_ms = self.config.get('gateway.delivery.staleTTLMs', 60000)
        stale_ttl_s = stale_ttl_ms / 1000

        # Drop stale messages
        self.messages = [(msg, timestamp) for msg, timestamp in self.messages
                         if current_time - timestamp < stale_ttl_s]

    def deliver_messages(self):
        # Deliver remaining messages
        for msg, _ in self.messages:
            # Deliver message logic here
            pass

Verification

To verify the fix, follow these steps:

  • Configure the gateway.delivery.staleTTLMs option to a desired value (e.g., 30000ms)
  • Queue some messages before restarting the gateway
  • Restart the gateway and observe that messages older than the configured TTL are not delivered

Extra Tips

  • Consider adding logging to track dropped messages and their ages
  • Review the message queue implementation to ensure it can handle a large number of messages efficiently
  • Test the fix with different TTL values and network interruption scenarios to ensure it works as expected.

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 - 💡(How to fix) Fix Gateway replays stale queued messages after restart [1 participants]