Skip to content

fix(whatsapp): queued messages show an error reaction after successful handling - #172771

Merged
steipete merged 22 commits into
mainfrom
fix/whatsapp-status-reaction-queued-message
Oct 15, 2026
Merged

steipete merged 22 commits into
mainfrom
fix/whatsapp-status-reaction-queued-message

Conversation

@steipete

@steipete steipete commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #172708

What Problem This Solves

Fixes WhatsApp showing the wrong final reaction when a message arrives during an active run and is handled by a queued follow-up.

User Impact

Queued messages keep their acknowledgment until their follow-up settles delivery. They show ✅ only when a reply was visibly delivered to their source; a settled turn with no visible reply, including silent or NO_REPLY turns, shows ❌ just like direct dispatch. Execution failures, terminal admission skips, Stop cancellations, and queue-cap rejection or eviction show ❌ immediately, even if a later error notice is delivered. Collected and summarized messages retain their individual reaction targets; evicting a compacted summary source also reports failure. When transport retains an unconfirmed send, the reaction is cleared to neutral rather than leaving permanent activity or claiming success/failure. No configuration change or migration is needed.

Why This Change Was Made

The original dispatch has no visible reply when it hands a message to the queue. That handoff is not a failure, and successful agent execution is not proof of delivery either. WhatsApp now uses the existing source-bound queued delivery correlation to finalize its reaction after transport and presentation settlement. Core reports confirmed routing or dispatcher receipts, excluding failure notices delivered to a different channel. Deferred source retries retain ownership rather than reporting a terminal result; consumed pre-admission cancellations settle as failures instead of stranding the acknowledgment. Immediate execution or queue-cap failure cannot be replaced by later success. Summary compaction and synthetic overflow runs preserve source callbacks, and the cap owner reports actual eviction through the existing disposition notification. Canceled summary sources use the same no-execution cleanup as canceled ordinary entries. Stop settles the exact detached source correlations even if a callback throws. Pending routed or dispatcher delivery remains distinct from a terminal no-visible-reply result; an execution failure still wins immediately.

The existing optional onFollowupQueueDisposition callback is exposed through public GetReplyOptions, and the existing delivery-correlation cleanup receives an optional settlement argument. These documented, additive SDK changes carry queue-owned facts to the reaction owner; no new export, subpath, configuration, or schema is introduced. Existing no-argument correlation consumers remain compatible. Separate source-owned Gateway batches retain their own outcome owner and do not report an unverified visibility result through this callback. Direct steering without a source terminal/delivery callback remains acknowledged; this does not add a steering completion notification. The optional settlement now carries transportPending so the reaction owner can clear activity when transport takes custody. Source retries remain distinct and retain their correlation for the next queued run.

Held-delivery decision: the durable queue has no generic source terminal-callback subscription. DurableDeliveryCompletion supports persisted conversation and pending-final owners; onDeliveryIntent reports identity, and live result commit hooks cannot survive recovery or report terminal failure. This uses the explicitly requested neutral fallback: clear the WhatsApp reaction at held/ambiguous transport handoff. A later retry success or terminal failure remains visible through the delivery owner but does not update the cleared reaction. Direct WhatsApp dispatch currently has no held-specific neutral state; its normal visible-reply and silent-turn behavior is unchanged. No new callback registry, polling, persistence field, schema, or durability semantics are added.

Deferred-effect facts: account, chat, message ID, participant, and fromMe remain the immutable admitted message target; emoji, eligibility, and configuration retain that message's feedback policy. Each reaction send or clear resolves the active account listener through the existing transport owner. Delivery visibility comes from the current follow-up's source route or dispatcher receipt. Stop notifications use only the cleanup owner's revalidated, detached source set, and callback errors cannot prevent lifecycle settlement. No new session binding lookup, paths, limits, authority, or retained Gateway handle is introduced.

Production delta is +173/-65 (net +108); tests +377/-72; docs +19/-0. The standalone finalizer was removed. The remaining growth carries delivery settlement, receipt evidence, and Stop notification through the existing owners; unrelated deletion would not improve this fix.

Evidence

PR CI is the test gate per maintainer policy. It covers the WhatsApp boundary regressions, follow-up delivery/runner tests, production and test types, lint, formatting, and SDK boundary checks. Local tests, negative controls, typechecks, and live Gateway/Crabbox/Testbox proof were intentionally skipped per that policy; no leases were created.

Regression coverage includes:

  • waits for queued delivery before showing $emoji (visible=$visibleReplySent) — successful execution stays pending until delivery, including no-visible-reply failure.
  • preserves queued delivery settled before the original dispatch finalizes.
  • shows execution failure immediately and does not replace it with delivery success.
  • keeps a deferred retry pending and matches direct dispatch for a settled silent turn.
  • Queue-cap rejection and eviction cases, including a visibly delivered rejection notice.
  • settles evicted summary sources and retains surviving delivery correlations — real enqueue/summary compaction with four sources at cap one. Existing queue regressions also verify synthetic-summary correlation handoff and canceled elided-source cleanup.
  • retains pending transport ownership for $route / $fallback, and distinguishes transport handoff from source retry ($kind, failed=$failed).
  • leaves held delivery neutral after a later $outcome receipt covers delivered and terminally failed receipts at the source-correlation boundary using the actual shared reaction controller. This tests neutral finality, not a durable queue replay or a new recovery callback.
  • The existing Stop cleanup regression now verifies failure settlement for owned pending/summary/elided sources, excludes foreign sources, and contains callback errors.
  • reports settled source visibility for $origin: $route / $fallback — real channel routing plus delivered, failed, transformed, and cross-channel fallback receipts.
  • settles a terminal admission skip (%s) and releases its operation, plus already-aborted and active-lane deferral cases.
  • settles source delivery correlations with visible=%s, plus the existing ordering regression extended to assert cleanup waits for the separate source owner and presentation settlement.

The queue.dedupe.test.ts retained-summary and elided-summary cancellation test oracles now require exactly one cleanup callback carrying the original, already-aborted source. The existing redelivery/deduplication and dormant-queue assertions remain; source inspection of dropAbortedFollowups and the runner's early-abort branch verifies that this is cleanup, not model execution.

Changed-file oxlint with the repository/core config, oxfmt, and git diff --check passed. Deslop completed. Fresh independent P0–P2 autoreview is scoped-clean with no actionable findings.

Exact-head CI 38700231720 passed for cfca9457191050a102ff9df797ed15205422eb23: 49 successful jobs, 26 skipped, no failures. The completed run and head were verified live with OCTOPOOL_FRESH=1. All selected test jobs, production/test typechecks, lint, formatting, baseline, and SDK boundary checks passed. No CI rerun was needed.

The WhatsApp test job 116306984004 passed 82 tests across 11 WhatsApp files in 30.56 seconds. The new neutral-state regressions passed for a later delivered receipt (2 ms) and terminally failed receipt (9 ms). Local test wall time is not applicable because local tests were intentionally not run under maintainer policy. Live Gateway/Crabbox/Testbox proof was also intentionally skipped; no leases were created.

The held-transport review finding is addressed with the documented neutral fallback, and the review thread is resolved. ClawSweeper has no code findings. The PR remains open and ready; it has not been merged.

@steipete
steipete marked this pull request as ready for review October 15, 2026 03:15
@clawsweeper

clawsweeper Bot commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper reviews are opt-in for maintainers. If a review is required, finish the work and validation first, then comment @clawsweeper review. Please avoid repeated requests while a review is queued or running; agents should not request reviews automatically.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-15T07:44:56.001082Z cfca945 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: whatsapp-web Channel integration: whatsapp-web size: S labels Oct 15, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2932c547ec

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1f4e965e63

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8defedd969

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/auto-reply/reply/followup-runner.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 370c2b3fde

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b622386a99

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cb4d5ee7a0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/auto-reply/reply/followup-runner.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 54a66ba618

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/auto-reply/reply/followup-runner.ts Resolved
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 15, 2026
@clawsweeper

clawsweeper Bot commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR settles queued WhatsApp reactions from source delivery outcomes and handles cancellation, eviction, and unconfirmed transport custody.

Example: With status reactions enabled, message B arrives while message A is running and receives a queued follow-up reply.

  • Before: B briefly shows ❌ because its initial dispatch delivered no reply, despite the later successful follow-up.
  • After: B retains 👀 while queued and shows ✅ after confirmed visible delivery; an unconfirmed transport handoff clears its reaction.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful, scoped repair with green exact-head CI and no actionable findings; validation remains test-based rather than a shipped WhatsApp flow.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary proof gate; exact-head CI exercises reaction and queue contracts with simulated transport outcomes, and the body explicitly claims no shipped WhatsApp validation.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A WhatsApp message can show an error reaction even though its queued follow-up successfully delivers a reply.
Reason: This repairs a reported release bug through existing owners, and the maintainer-authored PR explicitly accepts the neutral held-delivery behavior.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR addresses a current WhatsApp reaction bug, and the reviewed head has no actionable correctness findings.

Priority: P2
Reviewed head: cfca9457191050a102ff9df797ed15205422eb23

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No shipped WhatsApp overlapping-message run or failing-base regression execution is supplied; the maintainer-authored PR is outside the ordinary contributor proof gate.
Agent review details

How this fits together

WhatsApp inbound dispatch supplies source-bound feedback callbacks to the shared follow-up queue, whose execution, delivery, and cleanup owners report facts back to the original message's reaction controller.

flowchart TD
  A[WhatsApp inbound message] --> B[Inbound reply plan]
  B --> C[Shared follow-up queue]
  C --> D[Agent execution]
  D --> E[Source delivery owner]
  C --> F[Cancellation and eviction cleanup]
  E --> G[Original message reaction]
  F --> G
Loading

Technical review

Best possible solution:

Use the existing source correlation to settle queued reactions after delivery, preserving immediate failures and the accepted neutral transport fallback.

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

Yes at source level: accepted deferred dispatch can return without immediate delivery, while current main maps that absence to an error reaction; the reporter also supplies release-specific steps and reaction logs.

Is this the best way to solve the issue?

The implementation uses the existing queue, delivery, and reaction owners, retains source identity through collection and summaries, and avoids adding durable reaction machinery for the explicitly accepted neutral fallback.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against cd3eb90f8752.

Provenance checked

  • WhatsApp lifecycle reactions and semantic failures keeps the original intent (83b8289: Lifecycle reactions show queued activity and terminal outcomes; the later failed-run repair preserves semantic failure even when an error payload is delivered.)
  • Canonical queued execution and source completion keeps the original intent (f8cc39c: Queued turns became adapters into canonical execution, while source completion remains ordered after delivery and presentation settlement.)
  • Canceled queue and summary cleanup keeps the original intent (d872690: Cancellation releases abandoned source identities before asynchronous cleanup without executing canceled model work or starting healthy siblings.)
  • Summary capacity and source ownership keeps the original intent (1b8d837: Queued prompts retain cancellation, collection, overflow, and completion ownership; the PR adds terminal feedback without changing capacity or replay policy.)
  • Operator authority during queued cleanup keeps the original intent (715077a: Accepted queued work retains its originating operator and authorization ceiling; terminal bookkeeping remains available without executing canceled work.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit f8cc39c adds src/auto-reply/reply/followup-runner.ts:31 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: f8cc39ce6213; files: src/auto-reply/reply/followup-runner.ts)
  • Gado: Raw commit 83b8289 adds docs/channels/whatsapp.md:493 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 83b8289ee274; files: docs/channels/whatsapp.md)
  • Finn763: Raw commit aa0f0c0 adds src/auto-reply/reply/followup-runner.ts:102 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: aa0f0c0f9e1a; files: src/auto-reply/reply/followup-runner.ts)

PR surface

Source +108, Tests +305, Docs +19. Total +432 across 19 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 10 173 65 +108
Tests 7 377 72 +305
Docs 2 19 0 +19
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 19 569 137 +432

Review metrics

Metric Value Why it matters
Production versus test LOC Production +173/-65; tests +377/-72 Production growth carries source delivery receipts and terminal cleanup through existing owners; tests cover distinct delivery, cancellation, summary, and reaction contracts.

Labels

Label changes:

  • add P2: An opt-in WhatsApp status indicator incorrectly reports failure after successful queued handling, causing confusion and repeated requests.
  • add merge-risk: 🚨 compatibility: The PR changes public SDK callback contracts; the maintainer-authored, documented additions preserve existing no-argument consumers and introduce no unresolved compatibility blocker.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: An opt-in WhatsApp status indicator incorrectly reports failure after successful queued handling, causing confusion and repeated requests.
  • merge-risk: 🚨 compatibility: The PR changes public SDK callback contracts; the maintainer-authored, documented additions preserve existing no-argument consumers and introduce no unresolved compatibility blocker.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 15, 2026, 4:29 AM ET / 08:29 UTC.

@steipete
steipete merged commit 774f7ed into main Oct 15, 2026
153 checks passed
@steipete
steipete deleted the fix/whatsapp-status-reaction-queued-message branch October 15, 2026 08:40
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

steipete added a commit that referenced this pull request Oct 15, 2026
Name the reply-plan return through existing public SDK contracts so the
queued-reaction changes in #172771 (774f7ed) do not expose the private
PLUGIN_COMMAND_DISPATCH symbol during package declaration emission.

Extract the equivalent annotation from #172883. Keep the return contract
and existing input aliases in a type-only sibling to avoid growing the
oversized implementation. The dependency refresh can rebase over this
repair. Runtime JavaScript and queued-reaction behavior are unchanged.
steipete added a commit that referenced this pull request Oct 15, 2026
Complete the consumer migrations from #172887, #172992, #172771 and #172989. Keep local schemas and callback types private and remove redundant barrel exports. Session sharing authority remains in its policy owner and is still enforced by production callers.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 16, 2026
…l handling (openclaw#172771)

* fix(whatsapp): follow queued message outcomes in status reactions

* fix(whatsapp): report queued message eviction in status reactions

* fix(whatsapp): wait for queued reply delivery before success

* fix: preserve separate queued delivery outcome ownership

* fix(whatsapp): settle queued reactions after terminal admission skips

* fix(whatsapp): retain reaction settlement through queue summarization

* fix(whatsapp): settle summarized follow-up source reactions

* test: distinguish canceled summary cleanup from execution

* test: expect aborted summary cleanup without replay

* fix(whatsapp): distinguish stopped turns from pending deliveries

* fix(whatsapp): clear reactions after transport custody handoff
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 16, 2026
Name the reply-plan return through existing public SDK contracts so the
queued-reaction changes in openclaw#172771 (7ebc6d0) do not expose the private
PLUGIN_COMMAND_DISPATCH symbol during package declaration emission.

Extract the equivalent annotation from openclaw#172883. Keep the return contract
and existing input aliases in a type-only sibling to avoid growing the
oversized implementation. The dependency refresh can rebase over this
repair. Runtime JavaScript and queued-reaction behavior are unchanged.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 16, 2026
Complete the consumer migrations from openclaw#172887, openclaw#172992, openclaw#172771 and openclaw#172989. Keep local schemas and callback types private and remove redundant barrel exports. Session sharing authority remains in its policy owner and is still enforced by production callers.
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: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L 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.

[Bug]: WhatsApp status reaction ends on ❌ for a message that arrives during an active run, though the next run succeeds

1 participant