Skip to content

fix: retry delivery when outbound adapter is unavailable - #119371

Merged
fuller-stack-dev merged 4 commits into
openclaw:mainfrom
fuller-stack-dev:codex/fix-outbound-adapter-pre-dispatch-20260804
Aug 5, 2026
Merged

fuller-stack-dev merged 4 commits into
openclaw:mainfrom
fuller-stack-dev:codex/fix-outbound-adapter-pre-dispatch-20260804

Conversation

@fuller-stack-dev

Copy link
Copy Markdown
Member

Closes #119370

What Problem This Solves

Fixes an issue where queued channel deliveries could become unrecoverable when
an outbound adapter was unavailable before platform dispatch. The queue
persisted those definitely-unsent failures as ambiguous send attempts, so
restart recovery refused to replay them.

Why This Change Was Made

Channel adapter loading now honors the Gateway request-scoped plugin registry,
and lazy outbound adapter/runtime resolution failures are reported through the
canonical definitely-not-dispatched error. Provider method invocation remains
outside that classification boundary, preserving the existing no-blind-replay
safety rule after a send may have begun.

This is generic channel behavior rather than a Discord-specific workaround. It
does not rewrite historical ambiguous rows.

User Impact

Deliveries that fail before provider dispatch because their outbound adapter is
temporarily unavailable remain safely retryable after restart. Deliveries whose
provider send actually began remain protected from duplicate replay.

Evidence

  • Red reproduction on canonical main through the real queue, lazy runtime
    loader, Discord and Telegram adapters, and SQLite:
    • unavailable-adapter rows retained send_attempt_started
    • restart recovery made zero dispatch calls
  • Green packaged proof:
    • unavailable-adapter rows retained no send-start evidence
    • restart recovery dispatched each delivery exactly once and completed
    • a generic failure after provider invocation retained
      send_attempt_started and was not replayed
  • Focused local tests:
    • 22 adapter, registry, and runtime-forwarder tests
    • 42 queue integration and migration tests
  • Blacksmith Testbox packaged build and focused tests passed.
  • Source-blind behavior validation: satisfies contract, confidence 0.98.
  • Autoreview: no accepted or actionable findings.

AI-assisted: implementation, investigation, and validation were performed with
Codex. The change and its delivery-safety boundary were independently reviewed
and exercised through packaged runtime proof.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: M maintainer Maintainer-authored PR labels Aug 4, 2026
@fuller-stack-dev fuller-stack-dev self-assigned this Aug 4, 2026
@clawsweeper clawsweeper Bot added 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. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Aug 4, 2026
@clawsweeper

clawsweeper Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 4, 2026, 11:18 PM ET / August 5, 2026, 03:18 UTC.

ClawSweeper review

What this changes

The PR makes outbound adapter lookup and lazy-runtime failures retryable when they occur before a channel provider send begins.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open for normal maintainer merge handling. The exact head repairs the pre-dispatch retry boundary; the earlier Feishu payload concern is unreachable on this head, but the remaining exact-head build check should finish before merge.

Priority: P1
Reviewed head: f77616051fade7e42bd2e2d575179b33816747fc

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The exact-head source and focused regression coverage support the repair, with only the in-progress packaged build gate remaining.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The author is a repository member, so the external-contributor proof gate does not apply; the PR body nevertheless documents packaged queue and SQLite behavior proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The author is a repository member, so the external-contributor proof gate does not apply; the PR body nevertheless documents packaged queue and SQLite behavior proof.
Evidence reviewed 5 items Current-main defect: Current main resolves lazy channel adapters only from the process-global registry, so a request-scoped registry can be ignored before any provider call.
Correct dispatch boundary: The channel lifecycle preflight runs before the send closure invokes the platform-send start callback; queue replay protection is marked only at the dispatch callback.
Exact-head recovery coverage: The added integration test asserts that an unavailable scoped adapter leaves no send-start evidence, then is replayed once after its registry is restored; the companion case preserves ambiguity after provider failure.
Findings None None.
Security None None.

How this fits together

The Gateway delivery queue routes queued messages through channel-plugin outbound adapters and records whether provider dispatch may have started. Restart recovery replays only entries with proven pre-dispatch failure, avoiding duplicate messages.

flowchart LR
A[Queued outbound message] --> B[Gateway delivery queue]
B --> C[Request-scoped channel adapter]
C --> D{Provider send began?}
D -->|No| E[Retryable queue entry]
D -->|Yes or uncertain| F[Protected replay state]
E --> G[Restart recovery]
F --> G
Loading

Before merge

  • Resolve merge risk (P1) - The supplied check state still has the exact-head build-artifacts job in progress; wait for it before merging this message-delivery change.
  • Complete next step (P2) - No repair is needed; a maintainer should wait for the remaining exact-head build result and make the protected PR's merge decision.
Agent review details

Security

None.

PR surface

Source +64, Tests +382. Total +446 across 10 files.

View PR surface stats
Area Files Added Removed Net
Source 5 87 23 +64
Tests 5 387 5 +382
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 10 474 28 +446

Review metrics

Metric Value Why it matters
Production vs test delta production +87/-23; tests +387/-5 The net production growth implements one generic registry and pre-dispatch ownership boundary, with substantially larger regression coverage for queue recovery.

Merge-risk options

Maintainer options:

  1. Complete exact-head packaged validation (recommended)
    Wait for the in-progress build-artifacts check to pass on the reviewed head, then merge the source-verified replay-boundary repair.

Technical review

Best possible solution:

Land the generic request-scoped adapter lookup and typed pre-dispatch classification once the exact head has completed its remaining packaged build validation.

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

Yes, source-reproducible: current main ignores the request-scoped registry at the lazy adapter loader, and the linked queue/restart scenario follows that path; this read-only review did not rerun it.

Is this the best way to solve the issue?

Yes. Resolving the adapter from the request-scoped registry and classifying only pre-invocation resolution failures preserves the queue owner's single replay-safety boundary.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 1f3d45b76f51.

Labels

Label justifications:

  • P1: The affected failure can make definitely-unsent queued channel messages unrecoverable after restart.
  • merge-risk: 🚨 message-delivery: The patch changes the persisted distinction between safe retry and potentially duplicate provider delivery.
  • 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. Not applicable: The author is a repository member, so the external-contributor proof gate does not apply; the PR body nevertheless documents packaged queue and SQLite behavior proof.

Evidence

What I checked:

  • Current-main defect: Current main resolves lazy channel adapters only from the process-global registry, so a request-scoped registry can be ignored before any provider call. (src/channels/plugins/registry-loader.ts:28, 1f3d45b76f51)
  • Correct dispatch boundary: The channel lifecycle preflight runs before the send closure invokes the platform-send start callback; queue replay protection is marked only at the dispatch callback. (src/infra/outbound/deliver-channel.ts:119, f77616051fad)
  • Exact-head recovery coverage: The added integration test asserts that an unavailable scoped adapter leaves no send-start evidence, then is replayed once after its registry is restored; the companion case preserves ambiguity after provider failure. (src/infra/outbound/deliver.queue-adapter-availability.test.ts:49, f77616051fad)
  • Prior payload finding disproved: Feishu's later runtime-delegate spread supplies its own undefined sendPayload property, overwriting the preceding explicit property; production Feishu therefore cannot enter the alleged structured-payload path. The same arrangement is already on the base and current main. (extensions/feishu/src/channel.ts:1886, f77616051fad)
  • Release context: The latest release commit predates this August PR, so this candidate fix is neither shipped nor already implemented on current main. (0790d9f593ad)

Likely related people:

  • Vincent Koc: Current-main blame attributes the registry loader, runtime forwarder, lifecycle, and queue dispatch boundary to this commit. (role: introduced affected loader and delivery-boundary paths; confidence: high; commits: aa07d55ec98f; files: src/channels/plugins/registry-loader.ts, src/channels/plugins/runtime-forwarders.ts, src/infra/outbound/deliver-channel.ts)
  • Peter Steinberger: Current main's latest plugin lifecycle refactor is authored by this contributor and is adjacent to the request-scoped registry behavior. (role: recent plugin lifecycle contributor; confidence: medium; commits: 1f3d45b76f51; files: src/plugins/runtime.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Wait for the exact-head build-artifacts check to complete successfully.

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 (2 earlier review cycles)
  • reviewed 2026-08-04T23:23:36.570Z sha c156a87 :: found issues before merge. :: [P1] Classify Feishu direct-adapter failures before dispatch
  • reviewed 2026-08-05T03:04:34.617Z sha f776160 :: found issues before merge. :: [P1] Classify Feishu payload resolution before replay gating

@openclaw-barnacle openclaw-barnacle Bot added the channel: feishu Channel integration: feishu label Aug 5, 2026
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

ClawSweeper follow-up on the structured-payload finding: the cited path is not reachable on f77616051fade7e42bd2e2d575179b33816747fc. createRuntimeOutboundDelegates({ sendText, sendMedia }) returns own renderPresentation and sendPayload properties with value undefined, and that object is spread after Feishu’s explicit fields in extensions/feishu/src/channel.ts. The exact-head runtime therefore reports typeof feishuPlugin.outbound.sendPayload === "undefined"; extensions/feishu/index.ts registers that feishuPlugin object as the production channel. A queued structured payload cannot enter the alleged lazy sendPayload lookup or persist the described ambiguous attempt without first changing Feishu registration behavior. That separate registration issue may deserve its own fix, but adding a new reachable payload transport is outside this PR’s adapter-availability invariant. I am therefore skipping those two rank-up moves for this PR.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 5, 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 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 Aug 5, 2026
@fuller-stack-dev
fuller-stack-dev merged commit ab7b3ff into openclaw:main Aug 5, 2026
128 of 138 checks passed
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Merged via squash.

@fuller-stack-dev
fuller-stack-dev deleted the codex/fix-outbound-adapter-pre-dispatch-20260804 branch August 5, 2026 03:22
vincentkoc added a commit that referenced this pull request Aug 5, 2026
* origin/main:
  fix(channels): honor explicit preview streaming settings
  refactor(telegram): consolidate outbound contracts and targets (#119438)
  fix(qa): retry transport cleanup and always stop owned labs (#119442)
  fix(mcp): guard stdio stdout frame parsing against oversized-buffer crash (#119379)
  refactor(auto-reply): centralize delivery deduplication and routing (#119436)
  fix(qa): preserve scenario isolation in serial suites (#119439)
  perf(xai): lazy-load optional capability runtimes (#119374)
  refactor(browser): consolidate browser CLI and normalization helpers (#119432)
  fix(qa): require ready transport accounts (#119431)
  refactor(media): share image and video geometry normalization (#119416)
  fix(config): preserve plugin metadata for missing config (#119421)
  fix: retry delivery when outbound adapter is unavailable (#119371)
  fix(cli): retire invalid secret flags and prove doctor recovery (#118926)
  refactor(signal): share outbound and reaction transport (#119415)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 5, 2026
…9371)

* fix(outbound): preserve pre-dispatch retryability

* test(outbound): assert lazy runtime sender

* fix(feishu): preflight direct message runtime

* test(gateway): preserve scoped registry fixture
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: feishu Channel integration: feishu cli CLI command changes gateway Gateway runtime 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: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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]: Outbound adapter lookup failures become ambiguous send attempts

1 participant