fix(whatsapp): reconnects fill the agent session queue with connection notices (#191037)
Root cause: extensions/whatsapp/src/auto-reply/monitor.ts:405 and :500 (main 069c3e2b02) enqueue a new "connected" and "disconnected" system event on every reconnect with no `contextKey`, and the queue's built-in dedupe (src/infra/system-events.ts:285) only drops a keyless event when it repeats the immediately previous text, so alternating connection notices pile up until the 20-entry per-session limit refuses everything else.
Fixes #190640
## What Problem This Solves
On a quiet WhatsApp account the connection drops and reconnects many times a day. Each reconnect adds two notices to the agent's main session. Within hours that session's 20-slot event queue is full of identical connect/disconnect notices, and other notices for the same session (for example node presence changes or hook results) are silently dropped until the Gateway restarts.
## User Impact
User impact: reconnects keep only the latest WhatsApp connection state per account, so other notices for the main session are delivered again.
## Why This Change Was Made
The WhatsApp monitor now sends both connection notices with one stable per-account key and `replace`, the queue's existing coalescing mechanism (same shape other state notices use). The notice text and the reconnect/watchdog behavior do not change; the queue just holds the newest state instead of a history. Different accounts use different keys, so one account never replaces another account's notice.
Thanks @sercada for the detailed production report and @ericcurtin for the fix.
## Evidence
Real Gateway (`ocx src`, source tier) with the real WhatsApp plugin against Crabline's local WhatsApp Web server, a TCP relay that drops the socket to cause 10 real reconnects (status 428), then a node presence `system-event` RPC and a real inbound WhatsApp DM. The DM turn's request to a local recording model fixture shows what the agent receives.
- main (069c3e2b02): queue full after the reconnects; the presence RPC returns `ok: true` but logs `System event queue is full` and the notice is lost; the DM turn gets 20 connection notices, ending on a stale "disconnected", and no presence notice.
- this PR: no queue-full warnings; the DM turn gets exactly one notice ("connected", the current state) plus the presence notice.
- Control, one reconnect on this PR: the DM turn still gets the connection notice once.
Observed proof lines: https://github.com/openclaw/openclaw/pull/191037#issuecomment-6980331003
Regression test `keeps one connection notice queued across reconnects` (real monitor, real queue, 12 reconnects) fails on main with 20 queued notices and passes here.
Merge danger: two-way door. In-memory queue behavior only, no stored state or config; a revert restores the old notices. Blast radius: WhatsApp users' main-session connection notices.
Co-authored-by: Ayaan Zaidi <hi@obviy.us>
fix(whatsapp): reconnects fill the agent session queue with connectio…
Find Your Interest
- Accessible name computation in Chromium chapter III: name from hidden subtrees
- Accessible name computation in Chromium chapter III: name from hidden subtrees
- How LinkedIn Uses AI to Review 40,000 Pull Requests a Week
- Last Week (Month) in AI #347 - Nvidia's spy, Anthropic's $1.4T IPO, AI's blue wave
- Salesforce Locked Slack for Privacy, Then Opened It for a Partner
- How to Build an Accordion-Menu using CSS and a bit of jQuery
- Everyone Hates AI. Half of Them Use It.
- wsf-xxxviii
- wsf-xxxi
- Who Checks the Boring Layer





