Skip to content

fix(delivery): preserve suppressed send outcomes - #122421

Merged
steipete merged 3 commits into
mainfrom
steipete/vibrant-feynman-601f59
Aug 12, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/vibrant-feynman-601f59

Conversation

@steipete

@steipete steipete commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where background task, subagent, and exec approval notifications could be reported as delivered after durable outbound sending had explicitly suppressed them. That false success could silently lose the notification; an ambiguous adapter dispatch could also invite a duplicate fallback.

Why This Change Was Made

The durable batch sender already records the authoritative aggregate suppression reason, but sendMessage dropped it when projecting MessageSendResult. This change preserves that typed reason at the outbound boundary and lets each owning caller map it into its existing domain outcome: intentional suppression may use the existing session fallback or retry path, while adapter_returned_no_identity is recorded as ambiguous/non-success without attempting a duplicate direct send. Task state changes advance their event cursor after adapter ambiguity but retain retry for intentional suppression. Callback-confirmed delivery still wins.

Gateway callers that return success without deliveryStatus remain compatible and continue to be treated as delivered. Subagent lifecycle cleanup is unchanged because it already consumes intentional_non_delivery and ambiguous outcomes correctly; the defect was in producing those outcomes from raw-text direct delivery.

No config, protocol, dependency, storage, changelog, version, package, or release surface changes. There is no exact code overlap with #121174 or #121180; #121180 is behavior-adjacent only upstream of outbound delivery.

User Impact

OpenClaw no longer claims successful delivery when durable sending explicitly suppressed a task, subagent, or exec followup. Intentional non-delivery can follow the established fallback path, while an adapter dispatch with no returned identity remains visibly ambiguous and avoids a potentially duplicate send.

Evidence

  • Pre-fix regressions failed for the intended reasons: aggregate suppression projection (2), task false-delivery/retry cursor behavior (3), subagent fabricated delivery (2), and exec followup false success (2).
  • Post-rebase focused tests: src/infra/outbound/message.test.ts 15 passed; src/tasks/task-registry.test.ts 127 passed; src/agents/subagents/announce/subagent-announce-delivery.test.ts 161 passed; src/agents/bash-tools.exec-approval-followup.test.ts 39 passed. Total: 342 passed. The adapter-ambiguity retry regression demonstrably failed on the old task branch with 2 sends instead of 1, then passed after the owner fix; intentional suppression still sends twice across two attempts.
  • Classifier dry-run selects core and coreTests. Targeted oxfmt and oxlint are clean; git diff --check is clean.
  • Blacksmith Testbox tbx_01kzt40s2874f3gaw5nan5x8f8: https://github.com/openclaw/openclaw/actions/runs/31563709500. The final task ambiguity correction passed pnpm tsgo:core, pnpm tsgo:core:test, and targeted oxfmt/oxlint (exit 0). The preceding final-tree API proof tbx_01kzt2q478rysj2bskjv6d06fx / https://github.com/openclaw/openclaw/actions/runs/31562487032 passed the plugin SDK API baseline plus the same type/format/lint gates.
  • Fresh Codex-backed high-reasoning autoreviews on the rebased branch, the API-surface correction, and the ClawSweeper ambiguity correction: TruffleHog clean; no accepted/actionable findings.
  • Production LOC: +64/-5 (net +59) across four files. Tests: +197/-31 (net +166) across four files. The production growth is the aggregate projection plus explicit owner outcome mappings needed to preserve the existing no-status Gateway compatibility path and prevent ambiguous duplicate state updates; no duplicate runtime path, shim, or new plugin SDK surface was added.
  • No live-channel proof is claimed. The behavior is covered at the outbound and consuming owner boundaries plus exact-head CI.

Preserve authoritative durable-send suppression outcomes so task, subagent, and exec followups no longer report false delivery or duplicate ambiguous adapter dispatches.
@clawsweeper

clawsweeper Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Aug 12, 2026
@steipete steipete self-assigned this Aug 12, 2026
@openclaw-barnacle openclaw-barnacle Bot added size: M maintainer Maintainer-authored PR labels Aug 12, 2026
@steipete
steipete marked this pull request as ready for review August 12, 2026 04:04
@clawsweeper clawsweeper Bot added merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 12, 2026
@clawsweeper

clawsweeper Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed August 12, 2026, 12:11 AM ET / 04:11 UTC.

ClawSweeper review

What this changes

The PR preserves durable-send suppression reasons so task, subagent, and exec follow-up callers no longer report suppressed notifications as delivered.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⛔ Blocked by patch quality or review findings - 6 items remain

Keep this PR open: its state-change path retries an adapter dispatch that may already be visible, creating the duplicate-send outcome the patch otherwise avoids.

Priority: P1
Reviewed head: a33235d73b84d05f558e08892bdc19bce8191f78

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The patch has a focused, repairable P1 delivery regression despite otherwise coherent owner-boundary coverage.
Proof confidence 🌊 off-meta tidepool Not applicable: This is a maintainer-authored PR, so the external-contributor real-behavior-proof gate does not apply; its focused test and Testbox claims remain supplemental.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This is a maintainer-authored PR, so the external-contributor real-behavior-proof gate does not apply; its focused test and Testbox claims remain supplemental.
Evidence reviewed 5 items Ambiguous sends must not retry: The durable sender emits adapter_returned_no_identity only after invoking the adapter with no identifiable result, and the canonical reply route treats that result as potentially visible to avoid a retry or fallback.
PR retry regression: The new state-change branch throws for every suppression; its catch leaves the event cursor unchanged, so a later call directly sends the same progress event again.
Missing regression coverage: The new retry test covers cancelled_by_message_sending_hook only, not adapter_returned_no_identity.
Findings 1 actionable finding [P1] Do not retry ambiguous state-change delivery
Security None None.

How this fits together

OpenClaw’s outbound message API converts durable channel-send results into a common result consumed by task and agent notification owners. Those owners then record delivery, queue a fallback, or stop to avoid duplicating an ambiguous send.

flowchart LR
  A[Task or agent completion] --> B[Outbound message API]
  B --> C[Durable channel sender]
  C --> D{Delivery outcome}
  D -->|Sent| E[Record delivery]
  D -->|Intentional suppression| F[Safe owner fallback]
  D -->|Ambiguous adapter result| G[Record non-retry ambiguity]
  F --> H[Task or agent state]
  G --> H
Loading

Before merge

  • Do not retry ambiguous state-change delivery (P1) - adapter_returned_no_identity means the adapter was invoked but no identity came back, so the message may already be visible. This throw reaches the catch without advancing lastNotifiedEventAt; a later call sends the same progress event again. Handle this reason as non-retryable ambiguity, as the terminal-task and reply-route paths do.
  • Resolve merge risk (P1) - An ambiguous state-change dispatch can become a duplicate progress notification because the new branch preserves the retry cursor for adapter_returned_no_identity.
  • Resolve merge risk (P1) - Production code grows by 52 net lines; the distinct task, subagent, and exec state machines justify owner-level mappings, but no shared abstraction should be added unless it removes real duplicate policy.
  • Complete next step (P2) - A narrow mechanical repair can preserve ambiguity without retrying the same state-change event.
  • Improve patch quality - Treat adapter_returned_no_identity as non-retryable in the task state-change path.
  • Improve patch quality - Add a focused regression that repeats the same ambiguous event and proves only one direct send occurs.

Findings

  • [P1] Do not retry ambiguous state-change delivery — src/tasks/task-registry-delivery.ts:454-457
Agent review details

Security

None.

PR surface

Source +52, Tests +155. Total +207 across 10 files.

View PR surface stats
Area Files Added Removed Net
Source 6 58 6 +52
Tests 4 186 31 +155
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 10 244 37 +207

Review metrics

Metric Value Why it matters
Production versus test LOC production +52/-6 (net +52); tests +186/-31 (net +155) The production growth adds a shared typed result plus three owner mappings; the task state-change mapping still needs the ambiguity correction.

Stored data model

Persistent data-model change detected: serialized state: src/infra/outbound/message.test.ts, vector/embedding metadata: src/infra/outbound/message.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Stop retrying ambiguous state updates (recommended)
    Advance the state-change event cursor for adapter_returned_no_identity while retaining a diagnostic, then add a regression proving the same event is sent only once.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Handle adapter_returned_no_identity in task state-change delivery as an ambiguous non-retry outcome, preserve its diagnostic, and add regression coverage that the event cursor advances without a second direct send.

Technical review

Best possible solution:

Map adapter_returned_no_identity in task state-change delivery to an ambiguity diagnostic that advances the event cursor, while retaining retries for intentional suppression; no clear net-neutral shared refactor exists because the three callers own distinct fallback policies.

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

Yes—source reproducible: an adapter result with no identity reaches the new throw at src/tasks/task-registry-delivery.ts:454, the catch retains lastNotifiedEventAt, and the next call re-sends the same event.

Is this the best way to solve the issue?

No—the shared typed projection is the right boundary, but the task state-change caller must treat adapter ambiguity as non-retryable, matching the existing durable and route-reply contract.

Full review comments:

  • [P1] Do not retry ambiguous state-change delivery — src/tasks/task-registry-delivery.ts:454-457
    adapter_returned_no_identity means the adapter was invoked but no identity came back, so the message may already be visible. This throw reaches the catch without advancing lastNotifiedEventAt; a later call sends the same progress event again. Handle this reason as non-retryable ambiguity, as the terminal-task and reply-route paths do.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 630aac9b25ae.

Labels

Label changes:

  • add P1: The patch can cause a user-visible duplicate background-task progress update after an adapter may already have sent it.
  • add merge-risk: 🚨 message-delivery: Merging changes suppression and retry handling for durable task, subagent, and approval notification delivery.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🌊 off-meta tidepool and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This is a maintainer-authored PR, so the external-contributor real-behavior-proof gate does not apply; its focused test and Testbox claims remain supplemental.

Label justifications:

  • P1: The patch can cause a user-visible duplicate background-task progress update after an adapter may already have sent it.
  • merge-risk: 🚨 message-delivery: Merging changes suppression and retry handling for durable task, subagent, and approval notification delivery.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🌊 off-meta tidepool and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This is a maintainer-authored PR, so the external-contributor real-behavior-proof gate does not apply; its focused test and Testbox claims remain supplemental.

Evidence

Acceptance criteria:

  • [P1] node scripts/run-vitest.mjs src/tasks/task-registry.test.ts.
  • [P1] node scripts/run-vitest.mjs src/infra/outbound/message.test.ts.
  • [P1] git diff --check.

What I checked:

Likely related people:

  • steipete: Authored this PR and the recent outbound refactor; current-main blame also attributes the shared result projection snapshot to Peter Steinberger. (role: recent delivery-path contributor; confidence: high; commits: a33235d73b84, 79c052499293, 723c7f9a7de4; files: src/infra/outbound/message.ts, src/tasks/task-registry-delivery.ts)
  • g515hoshino: Commit ff759b3 introduced the connected honest message-delivery status surface across the durable sender and outbound result projection. (role: honest-delivery result-surface contributor; confidence: medium; commits: ff759b3f1abf; files: src/channels/message/send.ts, src/infra/outbound/message.ts)
  • vincentkoc: Commit 602b575 touched the exec follow-up consumer and outbound result boundary; commit 2d75a2d is adjacent queue-lifecycle work but not a replacement for this PR. (role: recent adjacent exec/outbound contributor; confidence: medium; commits: 602b5759f281, 2d75a2d32814; files: src/agents/bash-tools.exec-approval-followup.ts, src/infra/outbound/message.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.

Derive the outbound projection from the existing durable batch result union so the repair does not change the public plugin SDK contract.
Advance the state-change event cursor after an adapter returns no identity so a possibly visible progress notification is not sent twice; intentional suppression remains retryable.
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready evidence for cf677d737ab5314ce6f622a9bc41b54c825aaa23:

ClawSweeper rank-up moves: all six applied. Adapter ambiguity now advances the task state-change cursor without retry; the duplicate-send merge risk is removed; intentional suppression remains retryable; the narrow owner repair is in place; the repeated-event regression proves one send; and the positive production delta is justified without adding an unnecessary shared abstraction.

Known proof gap: no live-channel proof is claimed. This deterministic repair is proven at the outbound and consuming owner boundaries plus exact-head CI.

@steipete
steipete merged commit b82ad64 into main Aug 12, 2026
128 checks passed
@steipete
steipete deleted the steipete/vibrant-feynman-601f59 branch August 12, 2026 04:47
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 13, 2026
* fix(delivery): preserve suppressed send outcomes

Preserve authoritative durable-send suppression outcomes so task, subagent, and exec followups no longer report false delivery or duplicate ambiguous adapter dispatches.

* fix(delivery): keep suppression reason internal

Derive the outbound projection from the existing durable batch result union so the repair does not change the public plugin SDK contract.

* fix(delivery): avoid retrying ambiguous task updates

Advance the state-change event cursor after an adapter returns no identity so a possibly visible progress notification is not sent twice; intentional suppression remains retryable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant