Repository navigation
whatsapp: expose connection watchdog tuning in account config - #89214
danashburn wants to merge 2 commits into
Conversation
Adds optional `channels.whatsapp.watchdog.*` (and per-account override at `channels.whatsapp.accounts.<id>.watchdog.*`) to the WhatsApp channel config schema, plumbed through to the existing `WebMonitorTuning` parameter of `monitorWebChannel`. The watchdog reads three knobs from `tuning` with hardcoded internal defaults (`extensions/whatsapp/src/auto-reply/monitor.ts:259-261`): - transportTimeoutMs (default 300_000 = 5 min — WebSocket silent) - messageTimeoutMs (default 1_800_000 = 30 min — no app messages) - watchdogCheckMs (default 60_000 = 1 min — evaluation interval) `messageTimeoutMs * 1` is used for an account whose connection opened after a recent inbound (`connection-controller.ts:385`), and `messageTimeoutMs * 4` otherwise. For deployments whose use pattern includes hour-long idle gaps between user-initiated turns (personal assistants, on-call bots), the 30-min default recycles WhatsApp Web every 30 min and any in-flight dispatch races the abort, leaving `pendingFinalDelivery` stuck on the session (see openclaw#89115 for the dispatch race that openclaw#89210 documents the trigger for). The `WebMonitorTuning` type at `extensions/whatsapp/src/auto-reply/ types.ts:36-50` already includes all three fields. The caller at `channel.ts:316` constructs the `tuning` object with only `{statusSink, accountId, channelRuntime}`. This PR adds the schema definition for `watchdog` and wires it through. Schema choices: - All three fields optional — unset preserves existing behavior - `.int().positive()` — rejects 0/negative; reject explicit "disable the watchdog" attempts because that would also disable the transport-dead detection - `.strict()` — surface typos in the config - Common to both channel-root and per-account levels (via the existing `buildWhatsAppCommonShape` helper) Tests: 4 new cases in `zod-schema.providers-whatsapp.test.ts` covering channel-level, account-level, strict rejection, and non-positive value rejection. Docs: new bullet under the Runtime model section explaining when to override, with a JSON5 example. Sits alongside the existing `web.whatsapp.*` Baileys timing bullet for symmetry. Refs: openclaw#89210 (this issue), openclaw#89115 (the dispatch race that becomes much rarer once operators can widen the watchdog window). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Codex review: needs real behavior proof before merge. Reviewed June 29, 2026, 7:36 PM ET / 23:36 UTC. Summary PR surface: Source +61, Tests +57, Docs +14. Total +132 across 5 files. Reproducibility: yes. at source level: current main has internal WhatsApp watchdog tuning fields but no schema, static type, generated metadata, or gateway caller path that supplies them from config. I did not run a live 30-minute idle WhatsApp gateway reproduction in this read-only review. Review metrics: 2 noteworthy metrics.
Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Finish one maintainer-approved WhatsApp watchdog config contract with aligned Zod schema, exported static types, generated metadata, account precedence semantics, unchanged defaults, refreshed branch state, and redacted real gateway proof using the new config path. Do we have a high-confidence way to reproduce the issue? Yes, at source level: current main has internal WhatsApp watchdog tuning fields but no schema, static type, generated metadata, or gateway caller path that supplies them from config. I did not run a live 30-minute idle WhatsApp gateway reproduction in this read-only review. Is this the best way to solve the issue? No, not yet. Passing values through the existing Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 18b2ff683fd3. Label changesLabel justifications:
Evidence reviewedPR surface: Source +61, Tests +57, Docs +14. Total +132 across 5 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (1 earlier review cycle)
|
|
This looks like a good narrow fix. One doc/config question: should we explicitly call out precedence between I assume the per-account value wins because this lives in the shared shape/merge path, but spelling that out would make operator-facing behavior easier to trust when someone mixes a global default with one noisy account override. |
CI feedback addressed: 1. `check-prod-types`, `check-test-types`, `check-additional-extension-*`, `checks-fast-contracts-channels-a`, `checks-node-agentic-control-plane-startup-health-runtime`: all blocked on `TS2339: Property 'watchdog' does not exist on type 'ResolvedWhatsAppAccount'` at `extensions/whatsapp/src/channel.ts:322`. `ResolvedWhatsAppAccount` is the parallel static type (lives in `accounts.ts`, listing every field flowing from `WhatsAppAccountConfig` to the runtime) — added `watchdog?: WhatsAppAccountConfig["watchdog"]` field + resolver return. 2. `check-docs` (oxfmt): missing trailing blank line after the JSON5 example. Ran `oxfmt --write` to auto-fix. 3. byungskers's docs review question — added explicit precedence note: per-account values override the channel-level default (same as `dmHistoryLimit` / `mediaMaxMb` / other common keys), so operators can ship a global default and override one noisy account. Real-behavior-proof gate (separate workflow) requires after-fix evidence from a real OpenClaw setup in the PR body — adding that as a follow-up edit to the PR body. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Real behavior proof from productionPosting per the Before — 30-min cycle observed under default
|
|
Heads-up — pushed Workflow status for |
|
This pull request has been automatically marked as stale due to inactivity. |
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: whatsapp: expose connection watchdog tuning in account config This is item 1/1 in the current shard. Shard 21/22. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
|
Closing per ClawSweeper review verdict |
|
Independent reproduction from a second deployment, in case it helps unblock this. The PR was closed as "unproven"; here is production evidence from a setup that is not the original reporter's. Environment: self-hosted gateway on Linux (systemd), core The watchdog fires purely on message silence, never on transport failure. Over 5 continuous days:
The WebSocket never went silent once. All 57 reconnects were false positives on a healthy socket. Verified as a timer, not a fault. The intervals between events cluster at 120.0-120.1 min with machine precision, which is Why the default does not fit this class of deployment. Both accounts run On the "account precedence semantics unclear" review point. This deployment happens to be exactly that case: two accounts under one gateway, each with its own Impact, stated honestly. For us this is currently log noise, not data loss. I checked whether reconnects leak into agent context as reported in #66965, and on this deployment they do not: 0 No workaround exists in config. The review findings on the branch (missing exported static config type field, metadata not regenerated, precedence semantics, conflicts) all read as mechanical rather than design objections. Happy to test a revived branch against this two-account instance and report back with the same measurements. |
Summary
Adds optional
channels.whatsapp.watchdog.*(and per-account override atchannels.whatsapp.accounts.<id>.watchdog.*) to the WhatsApp channel config schema, plumbed through to the existingWebMonitorTuningparameter ofmonitorWebChannel.Fixes #89210. Significantly reduces the rate at which #89115 fires for operators whose use pattern is idle-prone.
Background
The
WebMonitorTuningtype atextensions/whatsapp/src/auto-reply/types.ts:36-50already includes the three knobs the connection watchdog reads. The gateway caller atextensions/whatsapp/src/channel.ts:316constructs thetuningobject with only{statusSink, accountId, channelRuntime}, so the receivers fall back to internal defaults:transportTimeoutMsmessageTimeoutMswatchdogCheckMsWhen
connection.openedAfterRecentInbound === true(basically any active chat session perconnection-controller.ts:385), the app-silence trigger usesmessageTimeoutMs * 1. OtherwisemessageTimeoutMs * 4.For deployments whose use pattern includes hour-long idle gaps between user-initiated turns (personal assistants, on-call bots, infrequent-message workloads), the 30-min default recycles the WhatsApp Web socket on a regular cadence during idle. Any in-flight dispatch that races the abort window leaves
pendingFinalDeliverystuck on the session — the upstream dispatch race documented in #89115. The race fires roughly as often as the watchdog cycles.This PR doesn't touch the watchdog mechanism. It only adds the config plumbing so operators can move the trigger out of their normal idle window.
Changes
src/config/zod-schema.providers-whatsapp.tsWhatsAppWatchdogSchema+ include inbuildWhatsAppCommonShapeso both channel-root and per-account paths accept itextensions/whatsapp/src/channel.tsaccount.watchdoginstartAccountand spread defined fields into thetuningarg ofmonitorWebChannelextensions/whatsapp/src/accounts.tswatchdog?: WhatsAppAccountConfig["watchdog"]toResolvedWhatsAppAccount+ return from the resolver (added in 8dad90f — the static-type plumbing pair to the zod-inferred type)docs/channels/whatsapp.mddmHistoryLimit/mediaMaxMbsrc/config/zod-schema.providers-whatsapp.test.tsDesign notes
.int().positive(). Rejects 0 and negative. An explicit "disable the watchdog" would also disable the transport-dead check, which is the genuinely-useful safety belt. Operators who want the WebSocket-level check but a very lenient app-silence cap can setmessageTimeoutMsto a large value (e.g., 8h, 24h)..strict(). Surfaces typos in the config; consistent with adjacent schemas (WhatsAppAckReactionSchema,WhatsAppPluginHooksSchema).channel.ts. Only spreads fields that are!== undefinedso an emptywatchdog: {}and an absentwatchdogboth behave identically (receiver applies its own internal defaults).buildWhatsAppCommonShapeso both levels accept it; the existing config-merge surface handles precedence (account overrides channel) the same asdmHistoryLimitand the other common keys.Real behavior proof
Production setup: single-tenant
openclaw 2026.5.28gateway in Docker, single WhatsApp account, run as a personal assistant with hour-long idle gaps between user turns.Before — 30-min cycle observed under default
messageTimeoutMs. Container logs2026-06-01T17:53:37ZandT18:23:40Z(exactly 30 min apart):Each disconnect raced the in-flight dispatch and left at least one
pendingFinalDeliverystuck on either theopenclaworresearchagent session (the upstream race in #89115). User-visible: agent "went silent." Our local cron-watchdog auto-flushed the stuck flag after detection, but real time between question and answer regularly hit 2h.Bridge — patched
messageTimeoutMsdefault to 28_800_000 (8h) in the bundledmonitor-*.jsto validatetuning.messageTimeoutMsflows where this PR expects it to flow:The OC gateway loads plugins from the user-local search path
/home/node/.openclaw/npm/node_modules/@openclaw/whatsapp/BEFORE the bundled/usr/local/lib/...path, so we also patch the user-local copy at entrypoint runtime (node user has write access there).After — entrypoint log
2026-06-02T09:29:22Z:File contents post-fix:
Live container — zero
watchdog timeout (app-silent)events since 09:29 UTC:For reference, before the dual-path patch, the same container reliably logged the
(app-silent)line every 30 min during chat sessions and every 2h overnight (theappSilenceTimeoutMs = messageTimeoutMs * 4fallback). After the dual-path patch, none.With this PR landed, the bridge above (sed against bundled dist files in two locations) goes away and is replaced by a single config block in
openclaw.json:Test plan
pnpm test src/config/zod-schema.providers-whatsapp.test.ts— 4 new tests pass alongside existing 11pnpm tsc --noEmit— type-check (account.watchdogpropagates from schema toWhatsAppAccountConfigvia the existingOpenClawConfiginference chain; staticResolvedWhatsAppAccountupdated in8dad90fe)pnpm format:docs:check— passes afteroxfmt --writeondocs/channels/whatsapp.mdmonitor-*.jsto 8h, observed absence ofwatchdog timeout (app-silent)log line across multiple chat sessions and idle periods (see Real behavior proof section above)I haven't run the full local suite — happy to fix anything reviewers flag.