Skip to content

whatsapp: expose connection watchdog tuning in account config - #89214

Closed
danashburn wants to merge 2 commits into
openclaw:mainfrom
danashburn:whatsapp-watchdog-config-exposure
Closed

danashburn wants to merge 2 commits into
openclaw:mainfrom
danashburn:whatsapp-watchdog-config-exposure

Conversation

@danashburn

@danashburn danashburn commented Jun 1, 2026 •

Copy link
Copy Markdown

Summary

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.

Fixes #89210. Significantly reduces the rate at which #89115 fires for operators whose use pattern is idle-prone.

Background

The WebMonitorTuning type at extensions/whatsapp/src/auto-reply/types.ts:36-50 already includes the three knobs the connection watchdog reads. The gateway caller at extensions/whatsapp/src/channel.ts:316 constructs the tuning object with only {statusSink, accountId, channelRuntime}, so the receivers fall back to internal defaults:

Knob Internal default Meaning
transportTimeoutMs 300_000 (5 min) WebSocket silent (no ping/pong)
messageTimeoutMs 1_800_000 (30 min) No app messages in/out
watchdogCheckMs 60_000 (1 min) Evaluation interval

When connection.openedAfterRecentInbound === true (basically any active chat session per connection-controller.ts:385), the app-silence trigger uses messageTimeoutMs * 1. Otherwise messageTimeoutMs * 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 pendingFinalDelivery stuck 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

File What
src/config/zod-schema.providers-whatsapp.ts Add WhatsAppWatchdogSchema + include in buildWhatsAppCommonShape so both channel-root and per-account paths accept it
extensions/whatsapp/src/channel.ts Read account.watchdog in startAccount and spread defined fields into the tuning arg of monitorWebChannel
extensions/whatsapp/src/accounts.ts Add watchdog?: WhatsAppAccountConfig["watchdog"] to ResolvedWhatsAppAccount + return from the resolver (added in 8dad90f — the static-type plumbing pair to the zod-inferred type)
docs/channels/whatsapp.md New bullet under "Runtime model" with a JSON5 example. Includes explicit precedence note: per-account overrides channel-level, same as dmHistoryLimit / mediaMaxMb
src/config/zod-schema.providers-whatsapp.test.ts 4 new cases: channel-level, account-level, strict-reject extras, reject non-positive values

Design notes

  • All three fields optional. Unset preserves existing behavior — no operator action required on upgrade.
  • .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 set messageTimeoutMs to a large value (e.g., 8h, 24h).
  • .strict(). Surfaces typos in the config; consistent with adjacent schemas (WhatsAppAckReactionSchema, WhatsAppPluginHooksSchema).
  • Spread pattern in channel.ts. Only spreads fields that are !== undefined so an empty watchdog: {} and an absent watchdog both behave identically (receiver applies its own internal defaults).
  • Channel-root and per-account. Lives in buildWhatsAppCommonShape so both levels accept it; the existing config-merge surface handles precedence (account overrides channel) the same as dmHistoryLimit and the other common keys.

Real behavior proof

Production setup: single-tenant openclaw 2026.5.28 gateway 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 logs 2026-06-01T17:53:37Z and T18:23:40Z (exactly 30 min apart):

17:53:37 [whatsapp] watchdog timeout (app-silent) - restarting connection
17:53:37 [whatsapp] Web connection closed (status 499). Retry 1/12 in 2.04s… (status=499)
18:23:40 [whatsapp] watchdog timeout (app-silent) - restarting connection
18:23:40 [whatsapp] Web connection closed (status 499). Retry 1/12 in 2.01s… (status=499)

Each disconnect raced the in-flight dispatch and left at least one pendingFinalDelivery stuck on either the openclaw or research agent 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 messageTimeoutMs default to 28_800_000 (8h) in the bundled monitor-*.js to validate tuning.messageTimeoutMs flows where this PR expects it to flow:

RUN sed -i 's|messageTimeoutMs = tuning.messageTimeoutMs ?? 1800 \* 1e3|messageTimeoutMs = tuning.messageTimeoutMs ?? 28800 * 1e3|' \
    /usr/local/lib/node_modules/@openclaw/whatsapp/dist/monitor-*.js

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:

[2026-06-02T09:29:22+00:00] [whatsapp-patch] OK: already patched (8h) in bundled (/usr/local/lib/node_modules/@openclaw/whatsapp/dist/monitor-Ccph7Y8M.js)
[2026-06-02T09:29:22+00:00] [whatsapp-patch] applied 30min → 8h at runtime in user-npm (PRIMARY load path) (/home/node/.openclaw/npm/node_modules/@openclaw/whatsapp/dist/monitor-C5_C_RGJ.js)

File contents post-fix:

$ grep messageTimeoutMs /home/node/.openclaw/npm/node_modules/@openclaw/whatsapp/dist/monitor-C5_C_RGJ.js
const messageTimeoutMs = tuning.messageTimeoutMs ?? 28800 * 1e3;
$ grep messageTimeoutMs /usr/local/lib/node_modules/@openclaw/whatsapp/dist/monitor-Ccph7Y8M.js
const messageTimeoutMs = tuning.messageTimeoutMs ?? 28800 * 1e3;

Live container — zero watchdog timeout (app-silent) events since 09:29 UTC:

$ sudo docker logs docker-clawdbot-gateway-1 --since 09:29 2>&1 | grep -c "watchdog timeout"
0

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 (the appSilenceTimeoutMs = messageTimeoutMs * 4 fallback). 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:

{
  channels: {
    whatsapp: {
      watchdog: {
        messageTimeoutMs: 28800000,
      },
    },
  },
}

Test plan

  • pnpm test src/config/zod-schema.providers-whatsapp.test.ts — 4 new tests pass alongside existing 11
  • pnpm tsc --noEmit — type-check (account.watchdog propagates from schema to WhatsAppAccountConfig via the existing OpenClawConfig inference chain; static ResolvedWhatsAppAccount updated in 8dad90fe)
  • pnpm format:docs:check — passes after oxfmt --write on docs/channels/whatsapp.md
  • Manual: production patched monitor-*.js to 8h, observed absence of watchdog 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.

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]>
@openclaw-barnacle openclaw-barnacle Bot added triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. docs Improvements or additions to documentation channel: whatsapp-web Channel integration: whatsapp-web size: S labels Jun 1, 2026
@clawsweeper

clawsweeper Bot commented Jun 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed June 29, 2026, 7:36 PM ET / 23:36 UTC.

Summary
The PR adds optional WhatsApp watchdog timeout settings to channel and per-account config, passes them to monitorWebChannel, documents them, and adds Zod schema tests.

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.

  • Public WhatsApp config surface: 1 object, 3 optional fields, 2 scopes. The PR adds channel-level and per-account openclaw.json contract surface, so schema, types, docs, generated metadata, and upgrade behavior need to align before merge.
  • Generated metadata updates: 0 generated files changed. Bundled channel config discovery consumes generated metadata, so a Zod-only source change can leave the public schema surface stale.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #89210
Summary: This PR is the candidate implementation for the open WhatsApp watchdog config issue; the session-state race, passive watchdog cleanup, and active liveness proposal are related but distinct.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🦪 silver shellfish
Patch quality: 🧂 unranked krab
Result: blocked until stronger real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add redacted real gateway proof from this branch showing channels.whatsapp.watchdog.messageTimeoutMs is accepted and reaches the monitor tuning path.
  • [P1] Add the missing exported static config type field and regenerate bundled channel config metadata.
  • Define and test watchdog account precedence, either as a deep-merged object or documented whole-object replacement.

Proof guidance:

  • [P1] Needs stronger real behavior proof before merge: The production logs show a dist monkey-patch changing watchdog defaults and later no timeout events, but they do not show this PR branch accepting channels.whatsapp.watchdog.* and passing configured values into a real gateway; add redacted after-fix proof and update the PR body to trigger re-review.

Risk before merge

  • [P1] The PR adds a public openclaw.json WhatsApp config surface while exported static types and generated channel config metadata remain out of sync with the Zod schema and docs.
  • [P1] The docs promise per-account watchdog values can tune one account independently, but the current resolver shallow-replaces nested watchdog objects unless the key is explicitly deep-merged or the docs/tests define whole-object replacement.
  • [P1] Operator-tuned watchdog thresholds can reduce idle reconnect churn but can also delay recovery from genuinely stale WhatsApp Web sessions when set too high.
  • [P1] The submitted proof shows a dist monkey-patch changing watchdog defaults, not this PR branch accepting the new config path and passing it into a real running gateway.
  • [P1] GitHub reports the branch as dirty/conflicting, so the exact head needs a refresh before mergeability or CI can be trusted.

Maintainer options:

  1. Complete The Config Contract (recommended)
    Add the exported static config type, regenerate bundled channel config metadata, define account precedence with focused tests/docs, rebase, and add real gateway proof before merge.
  2. Document Whole-Object Overrides
    If shallow nested-account semantics are intentional, update docs and tests to say account watchdog replaces the channel-level object instead of partially merging fields.
  3. Pause The Public Knob
    Pause or close the PR if maintainers prefer active liveness verification or another owner-approved recovery design before exposing passive watchdog thresholds as public config.

Next step before merge

  • [P1] This PR needs maintainer review because the remaining blockers include public config/API direction, contributor-side real behavior proof, and branch conflict refresh rather than a safe automated repair-only path.

Security
Cleared: No concrete security or supply-chain concern was found; the diff is limited to WhatsApp config/schema/docs/runtime plumbing and tests.

Review findings

  • [P1] Add watchdog to the exported WhatsApp config type — extensions/whatsapp/src/accounts.ts:49
  • [P1] Regenerate bundled channel config metadata — src/config/zod-schema.providers-whatsapp.ts:152
  • [P2] Align account watchdog precedence with the resolver — docs/channels/whatsapp.md:168
Review details

Best 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 WebMonitorTuning owner boundary is the right shape, but the branch is not the best mergeable solution until the public config contract, generated metadata, account precedence, branch refresh, and real-branch proof are complete.

Full review comments:

  • [P1] Add watchdog to the exported WhatsApp config type — extensions/whatsapp/src/accounts.ts:49
    ResolvedWhatsAppAccount.watchdog now indexes WhatsAppAccountConfig["watchdog"], but the branch does not add watchdog to src/config/types.whatsapp.ts. That leaves the new public config key out of the exported static contract and can fail or stale type/generated consumers even though the Zod schema accepts it.
    Confidence: 0.96
  • [P1] Regenerate bundled channel config metadata — src/config/zod-schema.providers-whatsapp.ts:152
    Adding watchdog to the Zod source schema is not enough for the public channel config surface: src/config/bundled-channel-config-metadata.generated.ts still has no watchdog or timeout entries. Schema-driven config discovery can remain stale until the generated metadata is refreshed with the new field.
    Confidence: 0.93
  • [P2] Align account watchdog precedence with the resolver — docs/channels/whatsapp.md:168
    The docs say per-account values can tighten or loosen one noisy account independently, but the WhatsApp account resolver shallow-spreads account config over channel/default config and does not deep-merge watchdog. An account that sets only messageTimeoutMs drops any channel-level transportTimeoutMs or watchdogCheckMs, so either deep-merge watchdog with tests or document whole-object replacement.
    Confidence: 0.9

Overall correctness: patch is incorrect
Overall confidence: 0.93

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 18b2ff683fd3.

Label changes

Label justifications:

  • P1: The PR is the active candidate for a WhatsApp watchdog problem tied to real channel availability and message delivery for idle-prone operators.
  • merge-risk: 🚨 compatibility: The PR adds a public WhatsApp openclaw.json config surface that must stay aligned across schema, static types, generated metadata, docs, and account precedence behavior.
  • merge-risk: 🚨 availability: Allowing operators to raise watchdog thresholds can reduce idle reconnects but can also delay recovery from genuinely stale WhatsApp Web sessions if configured too loosely.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦪 silver shellfish and patch quality is 🧂 unranked krab.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The production logs show a dist monkey-patch changing watchdog defaults and later no timeout events, but they do not show this PR branch accepting channels.whatsapp.watchdog.* and passing configured values into a real gateway; add redacted after-fix proof and update the PR body to trigger re-review.
Evidence reviewed

PR surface:

Source +61, Tests +57, Docs +14. Total +132 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 3 61 0 +61
Tests 1 57 0 +57
Docs 1 14 0 +14
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 132 0 +132

What I checked:

  • Repository policy read and applied: Root, docs, and extensions AGENTS.md were read fully; their guidance treats config/default surfaces as compatibility-sensitive and requires aligned schema, types, docs, generated metadata, proof, and plugin-boundary review. (AGENTS.md:31, 18b2ff683fd3)
  • Current main has internal tuning but no config pass-through: monitorWebChannel reads transportTimeoutMs, messageTimeoutMs, and watchdogCheckMs from its tuning object, while the current WhatsApp gateway caller passes only status/account/runtime fields. (extensions/whatsapp/src/auto-reply/monitor.ts:225, 18b2ff683fd3)
  • Current exported config type lacks watchdog: WhatsAppSharedConfig exposes existing WhatsApp config keys but has no watchdog, messageTimeoutMs, transportTimeoutMs, or watchdogCheckMs field. (src/config/types.whatsapp.ts:54, 18b2ff683fd3)
  • PR head indexes a missing static type field: The PR adds watchdog?: WhatsAppAccountConfig["watchdog"] to ResolvedWhatsAppAccount, but the PR diff does not add the corresponding exported WhatsApp config type field. (extensions/whatsapp/src/accounts.ts:49, 8dad90fe9608)
  • Generated channel config metadata remains stale: The generated WhatsApp channel config metadata contains no top-level or account-level watchdog object, while repository scripts expose config:channels:check specifically to detect stale generated output. (src/config/bundled-channel-config-metadata.generated.ts:34, 18b2ff683fd3)
  • Account config merge is shallow unless nested keys are declared: mergeAccountConfig only deep-merges keys listed in nestedObjectKeys; the WhatsApp resolver does not include watchdog, so partial account watchdog objects replace the channel-level object instead of merging fields. (src/channels/plugins/account-helpers.ts:179, 18b2ff683fd3)

Likely related people:

  • vincentkoc: Authored and merged the prior quiet-socket watchdog mitigation and recently touched the WhatsApp monitor/controller/docs path this PR extends. (role: recent watchdog behavior contributor; confidence: high; commits: d4ed277f4aab, efae4af0ebd0, e672b61417af; files: extensions/whatsapp/src/auto-reply/monitor.ts, extensions/whatsapp/src/connection-controller.ts, docs/channels/whatsapp.md)
  • mcaxtr: Recent commits touched WhatsApp connection lifecycle, bounded socket operations, startup waits, and account config surfaces around this controller/monitor boundary. (role: recent WhatsApp lifecycle and account-config contributor; confidence: high; commits: 52d9d16e1be9, 7d8b000bf78a, dd2083c7ec51; files: extensions/whatsapp/src/auto-reply/monitor.ts, extensions/whatsapp/src/connection-controller.ts, extensions/whatsapp/src/account-config.ts)
  • steipete: History shows repeated work on config helper documentation, WhatsApp schema/static type surfaces, and plugin seam cleanup relevant to a public config addition. (role: adjacent config and plugin-seam contributor; confidence: medium; commits: 40c8ed0dff65, 0796e992e463, 58912f8fd842; files: src/config/zod-schema.providers-whatsapp.ts, src/config/types.whatsapp.ts, extensions/whatsapp/src/channel.ts)
  • velvet-shark: Authored the closest existing operator-facing WhatsApp timing configuration precedent for Baileys socket timings. (role: adjacent timing-config contributor; confidence: medium; commits: dd643c82b55e; files: docs/channels/whatsapp.md, extensions/whatsapp/src/socket-timing.ts, extensions/whatsapp/src/connection-controller.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (1 earlier review cycle)
  • reviewed 2026-06-21T09:13:22.998Z sha 8dad90f :: needs real behavior proof before merge. :: [P1] Add watchdog to the exported WhatsApp config type | [P1] Regenerate the bundled channel config metadata | [P2] Match account watchdog precedence to the resolver

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jun 1, 2026
@byungskers

Copy link
Copy Markdown

This looks like a good narrow fix. One doc/config question: should we explicitly call out precedence between channels.whatsapp.watchdog.* and channels.whatsapp.accounts.<id>.watchdog.* in the docs example/text?

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]>
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. label Jun 2, 2026
@danashburn

Copy link
Copy Markdown
Author

Real behavior proof from production

Posting per the Real behavior proof workflow's required-section gate. Production setup: single-tenant openclaw 2026.5.28 gateway 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 logs 2026-06-01T17:53:37Z and T18:23:40Z (≈30 min apart, during Dan's normal-use day):

17:53:37 [whatsapp] watchdog timeout (app-silent) - restarting connection
17:53:37 [whatsapp] Web connection closed (status 499). Retry 1/12 in 2.04s… (status=499)
18:23:40 [whatsapp] watchdog timeout (app-silent) - restarting connection
18:23:40 [whatsapp] Web connection closed (status 499). Retry 1/12 in 2.01s… (status=499)

Each disconnect raced the in-flight dispatch and left at least one pendingFinalDelivery stuck on either the openclaw or research agent session (the upstream race in #89115). User-visible: agent "went silent." Our local cron-watchdog auto-flushed the stuck flag after detecting it, but Dan waited up to 2h between asking Nova something and getting a reply.

Bridge — patched messageTimeoutMs to 8h via Docker image

To validate the value tuning.messageTimeoutMs actually flows where this PR expects it to flow, I patched the bundled default in our image build:

RUN sed -i 's|messageTimeoutMs = tuning.messageTimeoutMs ?? 1800 \* 1e3|messageTimeoutMs = tuning.messageTimeoutMs ?? 28800 * 1e3|' \
    /usr/local/lib/node_modules/@openclaw/whatsapp/dist/monitor-*.js

Two real-world lessons that future operators will hit and that this PR will retire:

  1. 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. The Dockerfile patch alone on the bundled copy was a no-op for our setup — we had to patch both. (Logs after the bundled-only patch showed watchdog timeout (app-silent) at exactly 2h intervals, which is 30min × 4 = the appSilenceTimeoutMs fallback against the unpatched user-local default during overnight idle.)
  2. The container runs as node user, so the bundled-path patch can only happen at Docker build stage as root. The user-local-path patch can run from the entrypoint at runtime. With this PR landed, both monkey-patches disappear and operators set the value once in openclaw.json.

After — config flowing through, app-silent stays quiet

Entrypoint log 2026-06-02T09:29:22Z, both paths patched to 8h:

[2026-06-02T09:29:22+00:00] [whatsapp-patch] OK: already patched (8h) in bundled (/usr/local/lib/node_modules/@openclaw/whatsapp/dist/monitor-Ccph7Y8M.js)
[2026-06-02T09:29:22+00:00] [whatsapp-patch] applied 30min → 8h at runtime in user-npm (PRIMARY load path) (/home/node/.openclaw/npm/node_modules/@openclaw/whatsapp/dist/monitor-C5_C_RGJ.js)

File contents post-fix:

$ grep messageTimeoutMs /home/node/.openclaw/npm/node_modules/@openclaw/whatsapp/dist/monitor-C5_C_RGJ.js
const messageTimeoutMs = tuning.messageTimeoutMs ?? 28800 * 1e3;
$ grep messageTimeoutMs /usr/local/lib/node_modules/@openclaw/whatsapp/dist/monitor-Ccph7Y8M.js
const messageTimeoutMs = tuning.messageTimeoutMs ?? 28800 * 1e3;

Live container — zero watchdog timeout (app-silent) events since 09:29 UTC:

$ sudo docker logs docker-clawdbot-gateway-1 --since 09:29 2>&1 | grep -c "watchdog timeout"
0

For reference, before the dual-path patch, the same container reliably logged the (app-silent) line every 2h (overnight) and every 30min (during chat sessions). After the dual-path patch, none.

What this PR replaces

The bridge above is sed against bundled dist files in two locations. It's brittle to:

  • OC version bumps that rebundle with new hash suffixes in the file name
  • @openclaw/whatsapp internal refactors that move the default
  • Operators who don't know about the two install paths

With this PR landed, the operator config becomes:

{
  channels: {
    whatsapp: {
      watchdog: {
        messageTimeoutMs: 28800000,
      },
    },
  },
}

and the bridge goes away cleanly on next OC upgrade.


Also addressed @byungskers's docs question by adding an explicit precedence sentence (per-account overrides channel-level, same as dmHistoryLimit / mediaMaxMb). The earlier CI failures (check-prod-types, check-test-types, check-lint, etc.) all cascaded from a missing watchdog?: WhatsAppAccountConfig["watchdog"] field on ResolvedWhatsAppAccount — added in 8dad90fe.

@danashburn

Copy link
Copy Markdown
Author

Heads-up — pushed 8dad90fe to address the check-prod-types / check-test-types / check-lint / check-additional-extension-* / checks-fast-contracts-channels-a failures from the initial run. Root cause was a missing watchdog?: WhatsAppAccountConfig["watchdog"] field on ResolvedWhatsAppAccount in extensions/whatsapp/src/accounts.ts; the new TS field + resolver-return entry are in that commit. Also auto-fixed the check-docs failure with oxfmt --write and added the explicit precedence sentence per @byungskers's review.

Workflow status for 8dad90fe: 0 runs (combined status: pending, 0 checks). Looks like first-time contributor workflow approval is per-commit and the fix push needs a maintainer's nudge to re-trigger CI. Would a maintainer mind re-approving the workflow runs on the latest commit when you have a moment? Happy to push fixes for anything else CI surfaces.

@clawsweeper clawsweeper Bot added status: 🛠️ actively grinding The PR author has acted after the latest ClawSweeper review and work remains. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 14, 2026
@clawsweeper clawsweeper Bot added status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed status: 🛠️ actively grinding The PR author has acted after the latest ClawSweeper review and work remains. labels Jun 15, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added stale Marked as stale due to inactivity triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed stale Marked as stale due to inactivity labels Jul 20, 2026
@clawsweeper

clawsweeper Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

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.

@steipete

Copy link
Copy Markdown
Contributor

Closing per ClawSweeper review verdict stalled_unproven_pr (decision packet 2026-07-21T20:26:37.329Z). This item was part of the audited close backlog (openclaw/clawsweeper#920) stranded by an apply-lane defect, drained manually after re-verification. If this is wrong, reopen and ClawSweeper will re-review.

@grrek

grrek commented Sep 3, 2026

Copy link
Copy Markdown

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 2026.6.34 (extended-stable), @openclaw/whatsapp 2026.5.18, two WhatsApp accounts on one instance.

The watchdog fires purely on message silence, never on transport failure. Over 5 continuous days:

watchdogReason count
transport-inactive 0
app-silent 57

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 messageTimeoutMs * 4. I tested it as a falsifiable prediction rather than a correlation: on 2026-09-01 the last inbound message arrived at 18:17:47, so the next watchdog was predicted at 20:17:47 plus the 60s check jitter. Observed: 20:17:55. Delta 2h 0m 8s.

Why the default does not fit this class of deployment. Both accounts run dmPolicy: allowlist with exactly one permitted number and groupPolicy: disabled. Near-zero inbound traffic is the designed steady state, so silence is normal operation rather than a symptom. The result is ~12 reconnects per account per day, which is just 12 x 2h = 24h. The watchdog is measuring the clock, not the connection.

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 WhatsAppConnectionController and its own independent watchdog. They show up in the logs as two separate 2h chains offset by 9-26 minutes. Worth noting for anyone picking this up: the log line reads Listening for personal WhatsApp inbound messages for both accounts, where "personal" is the channel type rather than the account name, so the account that fired is not distinguishable from the logs today. Per-account override is the right shape, and a channel-level default with per-account override would cover this instance cleanly.

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 user and 0 system entries mentioning the watchdog across all agent session files. The reason it matters anyway is that each reconnect opens a ~5s window (detect at 12:33:25, listening again at 12:33:30). On plugin builds carrying the stale-append drop, messages arriving inside that window were discarded silently, so a benign timer turned into lost inbound messages. Reducing needless reconnects shrinks that exposure regardless of which bug is live.

No workaround exists in config. messageTimeoutMs is only read from a tuning object that ships as tuning = {} and is never populated from openclaw.json. It is a test-injection seam. For contrast, historyLimit in the same file does read from cfg.channels?.whatsapp?.historyLimit. Patching the bundle is the only current option, which does not survive openclaw update.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: whatsapp-web Channel integration: whatsapp-web docs Improvements or additions to documentation merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

4 participants