Skip to content

fix(whatsapp): stop reconnecting after terminal retry exhaustion - #118659

Merged
steipete merged 1 commit into
mainfrom
codex/auto-qa-whatsapp-terminal-retry-owner-96b
Aug 3, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/auto-qa-whatsapp-terminal-retry-owner-96b

Conversation

@steipete

@steipete steipete commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

After WhatsApp exhausted its bounded reconnect budget, its connection owner stopped correctly but the separate status owner did not record a terminal lifecycle. The production Gateway interpreted that clean exit as restartable, began another retry cycle, and could replace the original useful error with a generic disconnect.

Why This Change Was Made

The canonical terminal fact already belongs to the WhatsApp lifecycle owner. Map retry exhaustion to its existing blocked lifecycle and derive terminalDisconnect from that authoritative fact instead of separately guessing from legacy health labels. Ordinary repeated shutdown and recovery remain nonterminal. The production refactor removes one net line and introduces no Gateway/core, credential, config/default, dependency, SDK, schema, or protocol changes.

User Impact

Operators no longer get an endless WhatsApp reconnect storm after the configured retry budget is exhausted. Real openclaw channels status retains the original upstream failure and existing actionable openclaw doctor guidance; intentional stops and manual recovery keep working.

Existing shared Gateway terminal cleanup resets its generic reconnect-attempt projection to zero. The actual WhatsApp owner still exhausts all 12 attempts; this unchanged projection is not represented as retaining the owner count.

Evidence

  • Genuine owner-level regressions failed first: five failed before the canonical lifecycle repair.
  • WhatsApp owner, connection-controller, channel-status, and status-issue suites: 56 passed.
  • Gateway health-policy, channel lifecycle, channel server, and status-RPC suites: 141 passed.
  • Existing WhatsApp reconnect-exhaustion E2E: passed.
  • Complete exact-two-path remote repository gate: passed, including all three dead-export scans, extension and extension-test typechecking, formatting, lint, ownership/dependency guards, and runtime import-cycle checks; 359.358 seconds.
  • Four distinct complete hostile code reviews: no P0–P3 findings.
  • Separate genuine gpt-5.6-sol / high / P3 / no-web autoreview: clean, confidence 0.94; pinned TruffleHog 3.96.0: clean.

Real behavior proof

An actual authenticated loopback production Gateway, its real channels.status WebSocket RPC, and the public Commander CLI exercised the full owner-to-operator path on exact commit 2f5222eb6e2dd51d6660734a73d17af7727683cb:

  • The WhatsApp owner exhausted 12 attempts; the channel started exactly once.
  • Gateway recorded lifecycle: blocked, terminalDisconnect: true, and the original whatsapp-proof-2f522: upstream websocket timed out error.
  • Real public CLI output included the original failure and openclaw doctor remediation.
  • Repeated ordinary stops and recovered-account stops remained nonterminal.
  • The isolated, credential-free runtime observed zero external network attempts or connections on the exercised standard product paths. This is an observed runtime boundary, not an adversarial native-network or host-wide sandbox claim.

Maintainer decision

  • Maintainer accepts the low-risk WhatsApp-owner-only canonical lifecycle refactor after exact-head real Gateway/CLI proof, focused coverage, complete remote gate, and five independent clean reviews.
  • Maintainer authorizes repository-native landing of exact reviewed head 2f5222eb6e2dd51d6660734a73d17af7727683cb after all hosted checks and the completed ClawSweeper review pass.
  • Maintainer accepts the clean current-main merge result after confirming the required openclaw/ci-gate passed and authorizes the repository-native preparation and landing workflow.

@openclaw-barnacle openclaw-barnacle Bot added channel: whatsapp-web Channel integration: whatsapp-web size: S maintainer Maintainer-authored PR labels Aug 3, 2026
@steipete

steipete commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P1 High-priority user-facing bug, regression, or broken workflow. labels Aug 3, 2026
@clawsweeper

clawsweeper Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 3, 2026, 9:11 AM ET / 13:11 UTC.

ClawSweeper review

What this changes

The branch records exhausted WhatsApp reconnect retries as a blocked terminal lifecycle so Gateway preserves the original error and does not restart the channel again.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

This is a focused, correct repair for an owned WhatsApp lifecycle bug. It should remain open for protected maintainer landing because the branch is behind current main, but no code change or contributor follow-up is identified by this review.

Priority: P1
Reviewed head: 2f5222eb6e2dd51d6660734a73d17af7727683cb
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Strong exact-head operator-path proof and focused lifecycle coverage support a clean, owner-local repair.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body supplies exact-head after-fix Gateway WebSocket RPC and public CLI evidence, and the provided check context records successful Real behavior proof runs; it directly covers the terminal status, retained diagnostic, and nonterminal recovery paths.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body supplies exact-head after-fix Gateway WebSocket RPC and public CLI evidence, and the provided check context records successful Real behavior proof runs; it directly covers the terminal status, retained diagnostic, and nonterminal recovery paths.
Evidence reviewed 6 items Retry exhaustion has a distinct terminal source state: The WhatsApp connection controller increments the retry count and returns action: "stop" with healthState: "stopped" once the configured reconnect budget is exhausted.
Current lifecycle mapping loses the terminal fact: Current main maps stopped to lifecycle stopped, while markStopped marks a disconnect terminal only for logged-out or conflict health states; exhausted retries therefore do not reach Gateway as terminal.
Gateway consumes terminal status as the restart boundary: Gateway preserves terminal operator diagnostics on clean exit and clears pending restart state when terminalDisconnect is true, which directly addresses the reported reconnect loop.
Findings None None.
Security None None.

How this fits together

The WhatsApp plugin converts socket-close outcomes into a channel runtime status, which Gateway then uses to decide whether to restart the account and what diagnostic to show operators. This change corrects the lifecycle fact at the plugin owner before Gateway consumes it.

flowchart LR
  A[WhatsApp socket closes] --> B[Connection retry controller]
  B --> C[WhatsApp status lifecycle]
  C --> D[Gateway restart policy]
  D --> E[Channel status and doctor guidance]
  E --> F[Operator recovery]
Loading

Decision needed

Question Recommendation
Should this protected WhatsApp repair be landed through the current clean merge result once its required hosted checks are confirmed? Land after current-result checks: Merge the clean current-main result once required hosted checks confirm the exact landing state.

Why: The patch is correct and proof-backed, but the protected maintainer label and base drift reserve the final landing decision for a human on the current merge result.

Before merge

  • Resolve merge risk (P1) - The branch is behind current main; although the reviewed three-way merge is clean, landing should use the current merge result with required hosted checks for that result.
Agent review details

Security

None.

PR surface

Source -1, Tests +65. Total +64 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 2 3 -1
Tests 1 88 23 +65
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 90 26 +64

Review metrics

Metric Value Why it matters
Production versus regression coverage production -1 net, tests +65 net The owner-boundary repair reduces production code while adding focused coverage for exhaustion, recovery, and repeated-stop behavior.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Merge the current clean result after required hosted checks confirm it, keeping retry-exhaustion classification and terminal restart policy owned by the WhatsApp plugin.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Merge the current clean result after required hosted checks confirm it, keeping retry-exhaustion classification and terminal restart policy owned by the WhatsApp plugin.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: reach the configured reconnect maximum in extensions/whatsapp/src/connection-controller.ts:847, then follow noteClose and markStopped in extensions/whatsapp/src/auto-reply/monitor-state.ts. This review did not execute the failing current-main path because the checkout is read-only.

Is this the best way to solve the issue?

Yes. The patch records the terminal fact at the WhatsApp lifecycle owner and lets existing Gateway terminal handling consume it, rather than adding a downstream retry exception.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 096c929ecf6e.

Labels

Label justifications:

  • P1: A bounded retry exhaustion can otherwise restart an existing WhatsApp channel repeatedly and replace actionable diagnostics.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body supplies exact-head after-fix Gateway WebSocket RPC and public CLI evidence, and the provided check context records successful Real behavior proof runs; it directly covers the terminal status, retained diagnostic, and nonterminal recovery paths.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies exact-head after-fix Gateway WebSocket RPC and public CLI evidence, and the provided check context records successful Real behavior proof runs; it directly covers the terminal status, retained diagnostic, and nonterminal recovery paths.

Evidence

What I checked:

Likely related people:

  • joshavant: Git blame attributes the current mapping and terminal-disconnect predicate to the commit that introduced monitor-state.ts. (role: introduced current lifecycle implementation; confidence: high; commits: d0439b9ce0f4; files: extensions/whatsapp/src/auto-reply/monitor-state.ts)
  • steipete: The proposed repair is authored in the affected subsystem, and file-history shortlog shows substantial prior contribution across the WhatsApp monitor and connection-controller area. (role: recent WhatsApp lifecycle contributor; confidence: medium; commits: 2f5222eb6e2d; files: extensions/whatsapp/src/auto-reply/monitor-state.ts, extensions/whatsapp/src/connection-controller.ts, extensions/whatsapp/src/auto-reply/monitor.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-03T13:05:26.752Z sha 2f5222e :: needs maintainer review before merge. :: none

@steipete
steipete merged commit 3b6cad7 into main Aug 3, 2026
126 of 136 checks passed
@steipete
steipete deleted the codex/auto-qa-whatsapp-terminal-retry-owner-96b branch August 3, 2026 13:19
@steipete

steipete commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Aug 3, 2026
* origin/main: (57 commits)
  fix(media): fall back when providers return empty output (#118660)
  fix(nextcloud-talk): allow bounded parallel room deliveries (#118692)
  test(state): reuse current agent database fixture (#118677)
  fix(scripts): bound check-file-utils git lookup (#111582)
  fix(slack): scope interactive conversation bindings safely (#118662)
  fix(agents): avoid false compaction after mid-turn precheck (#117963)
  fix(ui): show original filename on chat history attachment cards instead of managed UUID suffix (#118628)
  fix(whatsapp): preserve terminal retry exhaustion lifecycle (#118659)
  fix(doctor): audit every agent workspace (#111840)
  fix(release): skip unavailable Buzz on frozen candidates (#118670)
  fix(ui): surface onboarding and pairing clipboard failures (#118651)
  fix(config): stop plugin schemas rejecting the channel key core writes (#117992)
  test(memory): isolate wiki plugin fixtures (#118654)
  fix(line): clear default access token when removing account (#118055)
  feat: enable rich setup controls in custodian chat (#114631)
  test(ui): reuse responsive browser fixtures (#118655)
  chore(tui): stabilize queued-turn admission in Gateway PTY test (#118638)
  fix(xai): classify exhausted credits as billing (#118615)
  fix(otel): fail closed when configured TLS material is invalid (#118648)
  fix(cli): preserve gateway request errors in health JSON (#118645)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 4, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 4, 2026
* origin/main: (57 commits)
  fix(media): fall back when providers return empty output (openclaw#118660)
  fix(nextcloud-talk): allow bounded parallel room deliveries (openclaw#118692)
  test(state): reuse current agent database fixture (openclaw#118677)
  fix(scripts): bound check-file-utils git lookup (openclaw#111582)
  fix(slack): scope interactive conversation bindings safely (openclaw#118662)
  fix(agents): avoid false compaction after mid-turn precheck (openclaw#117963)
  fix(ui): show original filename on chat history attachment cards instead of managed UUID suffix (openclaw#118628)
  fix(whatsapp): preserve terminal retry exhaustion lifecycle (openclaw#118659)
  fix(doctor): audit every agent workspace (openclaw#111840)
  fix(release): skip unavailable Buzz on frozen candidates (openclaw#118670)
  fix(ui): surface onboarding and pairing clipboard failures (openclaw#118651)
  fix(config): stop plugin schemas rejecting the channel key core writes (openclaw#117992)
  test(memory): isolate wiki plugin fixtures (openclaw#118654)
  fix(line): clear default access token when removing account (openclaw#118055)
  feat: enable rich setup controls in custodian chat (openclaw#114631)
  test(ui): reuse responsive browser fixtures (openclaw#118655)
  chore(tui): stabilize queued-turn admission in Gateway PTY test (openclaw#118638)
  fix(xai): classify exhausted credits as billing (openclaw#118615)
  fix(otel): fail closed when configured TLS material is invalid (openclaw#118648)
  fix(cli): preserve gateway request errors in health JSON (openclaw#118645)
  ...
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 maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant