fix(auto-reply): suppress stale foreground replies#76970
Conversation
|
Codex review: needs maintainer review before merge. Summary Reproducibility: yes. source-reproducible: current main routes WhatsApp-style contexts through the shared buffered dispatcher and delivery awaits beforeDeliver/deliver without a same-target freshness guard. I did not run a live WhatsApp or WebChat provider race in this read-only review. Real behavior proof Next step before merge Security Review detailsBest possible solution: Land the shared buffered-dispatch freshness fence after maintainer review and green relevant checks, keeping the guard scoped to channel/account/session/chat-target facts. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: current main routes WhatsApp-style contexts through the shared buffered dispatcher and delivery awaits beforeDeliver/deliver without a same-target freshness guard. I did not run a live WhatsApp or WebChat provider race in this read-only review. Is this the best way to solve the issue? Yes: a shared buffered-dispatch freshness fence is narrower than a WhatsApp-only workaround and covers the async beforeDeliver window. The remaining issue is merge/CI readiness, not a known defect in the proposed code. Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against afe26f51a3f8. |
bb86df0 to
819d1d4
Compare
@clawsweeper, addressed in 819d1d4. The foreground freshness fence now rechecks supersession after async Added regression coverage for that hook race in Verified:
|
|
Awesome! Looking forward to getting this fix. |
|
Hi @sbmilburn — we're hitting this same bug class on WebChat (same |
|
@christian-lallo I didn't write the PR or code the fix, that would be @MkDev11. I just filed Bug #76905. |
|
Apologies @sbmilburn, my mistake — and thanks for the redirect. @MkDev11 — would you mind re-syncing this PR from main? It was about ~9 hours behind 2026.5.7 when 2026.5.7 was published, so building from the current branch would inadvertently roll back some of the 2026.5.7 fixes when we apply the patched dist locally. Happy to share our WebChat-side reproduction details if useful for review acceleration. Appreciate the work. |
sure |
|
Thanks @MkDev11 — much appreciated, fast turn. Will report back if our local build surfaces anything worth flagging. |
25e8a81 to
3d26832
Compare
|
Landed via rebase onto main.
Thanks @MkDev11! |
Summary
Change Type
Scope
Linked Issue/PR
Real behavior proof
/root/mkdev11/openclaw, Node v22.22.1, pnpm 10.33.2, PR branchfix/issue-76905-whatsapp-stale-finalat92148e40c818bdca1d9e5ef3554712159eddae40.node --import tsx -ethat imported the realdispatchInboundMessageWithBufferedDispatcher, created two finalized WhatsApp-style inbound contexts for the same session target, held the older reply resolver until after the newer dispatch completed, then released the older final.{ "newerResult": { "queuedFinal": true, "counts": { "tool": 0, "block": 0, "final": 1 } }, "olderResult": { "queuedFinal": false, "counts": { "tool": 0, "block": 0, "final": 0 } }, "deliveries": [ { "kind": "final", "text": "new final" } ] }queuedFinal=falsewithcounts.final=0.Root Cause
Regression Test Plan
src/auto-reply/dispatch.freshness.test.tsUser-visible / Behavior Changes
Older stale foreground replies are suppressed when a newer inbound message starts for the same channel/account/session/target before the older dispatch finalizes.
Diagram
Security Impact
Yes/No) NoYes/No) NoYes/No) NoYes/No) NoYes/No) NoYes, explain risk + mitigation: N/ARepro + Verification
Environment
Steps
Expected
Actual
Evidence
Human Verification (required)
Review Conversations
Compatibility / Migration
Yes/No) YesYes/No) NoYes/No) NoRisks and Mitigations