Skip to content

Gateway delivery-recovery replays already-delivered messages after restart #29106

@petersykim

Description

@petersykim

Summary

After restarting the gateway, the delivery-recovery system re-sends messages that were already successfully delivered in previous sessions. Recipients see duplicate messages that were originally sent days or weeks earlier.

Steps to Reproduce

  1. Have agents running normally with delivery history
  2. Restart the gateway (e.g. openclaw gateway restart)
  3. Delivery recovery runs and reports messages as "recovered"
  4. Channel receives duplicate copies of old messages that were already delivered

Expected Behavior

Delivery recovery should only re-send messages that were genuinely not delivered. Already-acknowledged deliveries should be skipped.

Actual Behavior

The recovery system re-delivers messages regardless of prior delivery status. From today's logs: Delivery recovery complete: 7 recovered — but those 7 messages had already been received by the user previously (some ~1 week old).

Notes

It looks like ackDelivery() removes the queue file on success, but if the gateway is restarted between delivery and ack (or the ack write is interrupted), the file persists and gets replayed indefinitely on every subsequent restart. A delivery ID check or a "delivered" marker in the queue entry before replaying would prevent this.

Workaround

None currently — duplicates arrive silently with no user-visible warning.

Environment

  • OpenClaw: 2026.2.26
  • macOS 26.2 (arm64)

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleMarked as stale due to inactivity

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions