Skip to content

fix(outbound): avoid duplicate replies after queued delivery failures - #139388

Merged
steipete merged 4 commits into
mainfrom
codex/deslop-delivery-custody
Sep 6, 2026
Merged

steipete merged 4 commits into
mainfrom
codex/deslop-delivery-custody

Conversation

@steipete

@steipete steipete commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

A reply that remains queued, has no platform identity, or may have been partially sent must not trigger another automatic copy. During Matrix CLI testing, a followup inherited a closed monitor context, retained its outbound queue row, and triggered a native fallback; recovery later sent the original again.

Queued delivery now has one owner from admission through claim, lease, execution, acknowledgement and retirement. Consumers carry pending delivery separately from confirmed visibility. Private command selection stops before another recipient and reports delivered, pending, suppressed or failed honestly. Native and ACP finalization preserve pending text while still delivering uncovered content or independent audio. Durable Signal finals stay with outbound recovery; replaying ingress does not regenerate the model turn or resend an earlier visible block. Direct, unqueued failures retain ingress retry.

ACP keeps generated history separate from delivery-only fallback fragments. Preparation survives dispatcher wrappers so channel transforms run once before TTS. One helper covers the actual answer-text snapshot across preparation, pending delivery, confirmation and intentional suppression. Settled fallback decisions reuse the canonical dispatcher retry policy: permanently rejected captions do not reappear as plaintext, while media-only suppression preserves separately deferred text. Cancellation retains confirmed output. Existing custom dispatcher and settled-count contracts remain supported. The new preparation method is optional; this retains the additive dispatcher contract recommended by review, with the legacy custom-dispatcher path and spread/abort wrappers tested. Independently distributed plugins have not been exercised.

The refactor removes duplicate private-recipient loops, redundant sender conversions, duplicate queue type definitions, the preparation registry and duplicate transcript accumulators. Integration with main retains its shared command approval/formatting helpers and ACP input persistence before runtime execution. No configuration option, database schema, stored format or protocol version changes.

Validation on integrated commit 98b7c4f: 437 distinct focused cases pass, covering ACP delivery/cancellation, private command routing and exports, assembled channel turns, Signal recovery and outbound custody. Regressions failed before repair, including private identityless fallback, wrapper preparation, Signal final recovery, selective transcript loss, caption suppression/permanent rejection, and deferred text after media-only suppression. The complete changed-code gate passes with the pinned dependencies: typechecks, lint, dead-export scans, SDK/storage guards and import-cycle checks. Independent P2 review passed all 14 sections with no actionable findings. The reviewed, tested and committed source trees match exactly.

An earlier CI run exposed a fixture timeout: the Telegram preparation-failure case omitted its Signal fallback plugin and synchronously loaded the real plugin. A five-line test-only correction declares both fixtures, preserving all assertions and the timeout. The exact 17-file CI group then passed all 313 tests, its changed gate and independent review passed, and CI passed on that revision. Integrated-head CI passed with all 125 jobs completed and no failures.

Production LOC relative to integrated main: +1,089/-924 (net +165). Tests and support: +2,897/-390 (net +2,507). Main independently landed some overlapping cleanup, so those deletions are not counted again. The remaining production growth records exact queue custody, per-enqueue pending receipts and independent text/audio/transcript obligations after removing connected duplicate paths.

The private-QA build passed on the integrated commit. Its fresh replay used a real isolated Gateway and the normal Matrix plugin against a local Crabline protocol server and mock model. CLI add, disable, restore and delete passed. After the original startup-abort condition, the restored reply produced one accepted deterministic transaction and one visible timeline event, zero native fallback, and retirement of the same queue row. The recorder observed another 15 seconds. All owned processes and ports stopped with no cleanup errors, and all 63 source hashes remained unchanged. This is protocol-server proof, not an external Matrix-account or live-model claim.

Telegram Test Server proof is unavailable in this execution environment: no authenticated Convex CLI or broker pair is present. The existing credentialed CI lane accepts main/release refs for manual dispatch, rejects this unmerged PR, and has no scenario observing both the private-command group acknowledgement and owner DM. No authentication setup or trust-gate bypass was attempted. Telegram-facing command text and wrapper behavior are covered by owner tests; a generic Telegram hello would not cover the changed claim. This is an explicit remaining integration-proof gap.

The ClawSweeper private-route finding is addressed in the shared routing owner and covered by identityless first acceptance with a second valid recipient available. Final-source replay evidence is recorded above. No actionable review finding is being skipped.

Follow-up: separate confirmed visibility from terminal retry suppression in the existing public dispatch receipts. This PR preserves their shipped count/phase semantics and uses exact pending and confirmation facts where needed; changing those public semantics is outside this repair.

@steipete steipete self-assigned this Sep 5, 2026
@clawsweeper

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels Sep 5, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 5, 2026
@clawsweeper

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 6, 2026, 4:54 AM ET / 08:54 UTC.

ClawSweeper review

What this changes

The PR keeps queued replies with their recovery owner and carries pending delivery separately from confirmed receipt through private commands, agent replies, and channel delivery.

Merge readiness

✅ Ready for maintainer review

This repair remains useful: current main and the latest release retain the duplicate-fallback path. The prior private-route finding is resolved, and no new blocking defect was identified.

Priority: P1
Reviewed head: 98b7c4fe69eb7c030e1bd50414ef67c7fe82d71a

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent owner-level repair with meaningful transport proof and focused regressions; no blocking introduced defect was identified.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The recorded Gateway/Matrix protocol-server replay exercises the production follow-up and queue owners through startup-abort recovery and observes one visible event with no fallback duplicate. Relevant core blobs match the replayed revision; Telegram private-command integration remains explicitly unproven.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The recorded Gateway/Matrix protocol-server replay exercises the production follow-up and queue owners through startup-abort recovery and observes one visible event with no fallback duplicate. Relevant core blobs match the replayed revision; Telegram private-command integration remains explicitly unproven.
Evidence reviewed 10 items Pinned scope and clean checkout: The checkout matches the supplied head. Its raw parents match the host-recorded original head parents; the introduced comparison is the pinned base to head. Initial and final status inspections were clean.
Current main still needs the repair: Current main sends a native fallback when route delivery fails without suppression, without checking whether the outbound queue still owns delivery.
Latest release retains the same fallback: The supplied latest release, v2026.9.2, also contains the unconditional failed-route fallback. No verified merged replacement was established.
Findings None None.
Security None None.

How this fits together

OpenClaw’s outbound pipeline turns agent replies and command results into channel messages. Its durable queue coordinates transport attempts and recovery, while delivery receipts determine whether callers may send a fallback.

flowchart TD
  A[Agent replies and command results] --> B[Prepare channel payload]
  B --> C[Durable delivery owner]
  C --> D[Channel transport]
  D --> E{Delivery outcome}
  E -->|Confirmed| F[Receipt and completion]
  E -->|Pending or ambiguous| G[Recovery or reconciliation]
  E -->|Proven unsent and released| H[Eligible fallback]
  G --> C
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +165, Tests +2507, Docs +11, Other -1. Total +2682 across 63 files.

View PR surface stats
Area Files Added Removed Net
Source 30 1089 924 +165
Tests 28 2897 390 +2507
Docs 4 18 7 +11
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 1 -1
Total 63 4004 1322 +2682

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +165 net lines; tests/support +2,507 net lines The pinned introduced delta adds explicit custody and delivery-obligation accounting, with most growth in regression coverage.
Dispatcher contract additions 1 optional preparation method; 1 optional pending-receipt field Existing custom dispatchers retain their required shape and legacy return contract.

Technical review

Best possible solution:

Retain one recovery owner per queued reply, preserve unqueued retries, and keep independent text and audio obligations distinct from confirmed delivery.

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

Yes: an admitted route failure can retain its queue row while current main sends a native fallback, allowing recovery to send another copy. Source inspection and the recorded Matrix replay establish the path; this review did not execute it.

Is this the best way to solve the issue?

Yes: carrying custody from the queue owner addresses the competing retry paths directly, while optional dispatcher fields preserve existing implementations.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: The reported Matrix recovery sequence duplicates real replies, and the unsafe fallback remains on current main.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The recorded Gateway/Matrix protocol-server replay exercises the production follow-up and queue owners through startup-abort recovery and observes one visible event with no fallback duplicate. Relevant core blobs match the replayed revision; Telegram private-command integration remains explicitly unproven.
  • proof: sufficient: Contributor real behavior proof is sufficient. The recorded Gateway/Matrix protocol-server replay exercises the production follow-up and queue owners through startup-abort recovery and observes one visible event with no fallback duplicate. Relevant core blobs match the replayed revision; Telegram private-command integration remains explicitly unproven.
  • proof: telegram-e2e: This PR needs Telegram Test Server proof with the repository E2E skill. Shared private commands change Telegram-visible group acknowledgements and owner-DM delivery status.

Evidence

What I checked:

  • Pinned scope and clean checkout: The checkout matches the supplied head. Its raw parents match the host-recorded original head parents; the introduced comparison is the pinned base to head. Initial and final status inspections were clean. (98b7c4fe69eb)
  • Current main still needs the repair: Current main sends a native fallback when route delivery fails without suppression, without checking whether the outbound queue still owns delivery. (src/auto-reply/reply/followup-delivery.ts:431, 7b481f3e2e38)
  • Latest release retains the same fallback: The supplied latest release, v2026.9.2, also contains the unconditional failed-route fallback. No verified merged replacement was established. (src/auto-reply/reply/followup-delivery.ts:431, 3928bad9badf)
  • Queue custody blocks duplicate fallback: The introduced guard stops fallback for held custody or ambiguous delivery. Queue ownership projects errors through admission and execution, while acknowledgement and retirement retain the existing claim-fenced storage operations. (src/auto-reply/reply/followup-delivery.ts:431, 98b7c4fe69eb)
  • Prior private-route finding resolved: Private routing now stops on held or ambiguous acceptance before trying another recipient. The MCP regression covers identityless first acceptance with another valid recipient available, and checks that the group receives only a pending notice. (src/auto-reply/reply/commands-mcp.test.ts:405, 98b7c4fe69eb)
  • Additive dispatcher compatibility: Preparation and pending-receipt fields are optional; legacy return types and count methods remain. Core, spread, and abort-wrapper tests exercise preparation before TTS. The removed recoveryOwnedRetry field is internal, not exported by the inspected Plugin SDK error surface. These checks do not establish the earlier warning as a concrete compatibility defect. (src/auto-reply/reply/reply-dispatcher.types.ts:58, 98b7c4fe69eb)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • gaoanze888: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (3 earlier review cycles)
  • reviewed 2026-09-05T21:05:48.663Z sha dd4a1af :: blocked before merge. :: [P2] Preserve pending delivery through private-route fallback
  • reviewed 2026-09-06T07:28:18.028Z sha 78324e3 :: blocked before merge. :: none
  • reviewed 2026-09-06T07:56:07.787Z sha 0f97a2f :: blocked before merge. :: none

Carry exact pending state through native, ACP and private-command fallback.
Keep queue custody distinct from ambiguous or partial sends and confirmed
visibility. Preserve independent text/audio obligations and confirmed output
when a turn is cancelled.

Keep durable Signal finals with outbound recovery without replaying the model
turn or an earlier visible block. Preserve direct-send ingress retry. Carry
preparation through dispatcher wrappers so channel transforms run before TTS.
Honor intentional text suppression before and after admission while preserving
independent audio/text delivery.

Remove duplicate private routing, diagnostics forwarding, sender conversions,
queue type copies, preparation registry and transcript accumulators.
@openclaw-barnacle openclaw-barnacle Bot added the channel: signal Channel integration: signal label Sep 6, 2026
@steipete

steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The private-route finding and rank-up move are fixed in 78324e3: pending or identityless acceptance stops alternate-recipient fallback without claiming delivery. The rewrite also carries custody through native/ACP consumers, preserves canonical transcripts and independent text/audio obligations, and honors preparation and terminal retry decisions. All 320 final owner tests pass, the changed-code gates are green, and the independent P2 review returned no findings across nine sections. The PR body records the full scope and production/test LOC split. Final committed build, Matrix replay and exact-head CI are in progress before landing.

@clawsweeper

clawsweeper Bot commented Sep 6, 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 exact_review_queue).
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 merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 6, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. and removed merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Sep 6, 2026
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Sep 6, 2026
@steipete

steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

Ready to land at 98b7c4f. The reported merge conflicts are resolved while retaining main's shared command helpers and ACP input persistence. The integrated tree passed 437 focused cases, the complete changed-code gate, a 14-section independent review, a fresh private-QA build, and exact-head CI. Native preparation verified the same remote tree without rewriting the head.

The fresh Gateway/Matrix replay reproduced the startup-abort queue row, then observed one accepted transaction, one visible reply, no native fallback and retirement of that same row. The additional 15-second observation and all process/port cleanup passed. Source hashes were unchanged. The test uses the normal plugin against a local protocol server and mock model.

Review dispositions: retain the recommended additive dispatcher contract, including optional preparation and existing custom-dispatcher and spread/abort wrapper behavior. Those paths have passing coverage; independently distributed plugins were not exercised. Telegram's group acknowledgement plus owner DM remains the concrete integration-proof gap disclosed in the body: authenticated Convex/broker access is absent, and the existing trusted CI lane does not accept this PR ref or provide that dual-chat scenario. No trust-gate bypass or substitute hello test is claimed. The prior private-route finding and final-source replay request are addressed; no actionable code finding remains.

@steipete
steipete merged commit bf07988 into main Sep 6, 2026
189 checks passed
@steipete
steipete deleted the codex/deslop-delivery-custody branch September 6, 2026 08:59
@steipete

steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 7, 2026
…openclaw#139388)

* fix(outbound): preserve queue custody and reply obligations

* fix(delivery): preserve pending replies and canonical transcripts

Carry exact pending state through native, ACP and private-command fallback.
Keep queue custody distinct from ambiguous or partial sends and confirmed
visibility. Preserve independent text/audio obligations and confirmed output
when a turn is cancelled.

Keep durable Signal finals with outbound recovery without replaying the model
turn or an earlier visible block. Preserve direct-send ingress retry. Carry
preparation through dispatcher wrappers so channel transforms run before TTS.
Honor intentional text suppression before and after admission while preserving
independent audio/text delivery.

Remove duplicate private routing, diagnostics forwarding, sender conversions,
queue type copies, preparation registry and transcript accumulators.

* test(mcp): declare both private routing fixtures
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling channel: signal Channel integration: signal docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL 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