Repository navigation
fix(channels): LINE, SMS, and Zalo messages fail with "Async work scope is closed" before the agent replies - #148548
Conversation
…ed pump's work scope drains
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 14, 2026, 9:57 PM ET / September 15, 2026, 01:57 UTC (Revision 3). ClawSweeper reviewWhat this changesThe PR lets inbound channel deliveries and queued follow-ups outlive the webhook pump’s temporary work scope, with regression coverage for restart and plugin cleanup. Merge readiness✅ Ready for maintainer review This remains a useful, focused fix: current main still inherits the completed pump’s work scope. No blocking defect was found, the recorded Gateway proof covers the changed boundary, and the previous draft-only blocker is resolved. Priority: P1 Review scores
Verification
How this fits togetherOpenClaw’s shared ingress monitor accepts durable channel events and dispatches them to agent turns. The pump can finish before those turns and their replies, so delivery lifetime must remain independently owned. flowchart TD
A[Channel webhook] --> B[Durable ingress queue]
B --> C[Short-lived pump]
C --> D[Dispatch outside pump scope]
D --> E[Agent turn and queued replies]
D --> F[Retained Gateway work]
E --> G[Channel delivery]
F --> H[Release after dispatch settles]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +8, Tests +251. Total +259 across 4 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep dispatch lifetime with the ingress owner while preserving explicit cancellation, Gateway admission, and independently owned plugin cleanup. Do we have a high-confidence way to reproduce the issue? Yes: current source exposes the pump-closure race, and the captured evidence records a failing signed LINE webhook flow before repair. This review inspected source and supplied results without executing a current-main reproduction. Is this the best way to solve the issue? Yes: exiting the incidental pump scope at the existing dispatch owner is narrow and preserves the separate admission and cancellation contracts without introducing another lifetime manager. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 1b017767133a. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
Sorry, I marked this ready by mistake. It's back in draft now. |
|
landpr-approve-admin-merge |
|
Thanks @edenfunf! Proof: Signed synthetic LINE webhooks through a real Gateway completed the approval-denial and queued-follow-up sequence, with all six sends recorded at a local receiver. Real LINE recipient delivery remains unproved.
|
…pe is closed" before the agent replies (openclaw#148548) Related: openclaw#144801, openclaw#148025 ## What Problem This Solves Fixes LINE messages failing with “Something went wrong while processing your request” before the agent replies. SMS and Zalo use the same webhook pump. ## User Impact Turns can answer, wait for an exec approval, and answer queued follow-ups after the first turn ends. No configuration or migration is required. ## Why This Change Was Made The ingress drain starts dispatches that outlive the pump. Dispatch now leaves the pump's async-work scope while retaining its existing Gateway root until the task settles. Claim settlement and cancellation are unchanged. Cleanup after dispatch no longer holds the incidental webhook root; independently owned plugin cleanup keeps its own lifetime. ## Evidence - A self-signed POST to `/line/webhook` on an isolated Gateway reproduced `Async work scope is closed` on main `4e8dd8e1859f`, with a failed transcript turn and no inference request. - The repaired dispatch completed the same flow with synthetic credentials and a local receiver: ordinary reply, approval prompt, denial, approval-turn answer, queued answer, and next answer. All six sends arrived. The dedicated `openclaw approvals pending` and `openclaw approvals resolve <id> deny` commands drove the real approval. - 251 tests across 23 owner/channel files passed on merge `5384b5a718a2` with main `d229f4a2ba41`. Both new lifetime tests fail with the original production code. Type, lint, format, export, architecture and test-partition checks pass. - The original Bash CI timeout did not reproduce in six focused head/base/merge/parent controls. Full CI remains pending on the repaired head. This pass proves the Gateway and delivery boundary, not live LINE service delivery. The contributor also recorded real LINE push receipts at `138cd4fb4b1b`. ## Consumers The shared monitor and plugin state API use the drain. LINE, SMS and Zalo supply detached webhook pumps; boot-started Discord is a scope-free sibling. Public plugin signatures stay unchanged. ## Dispatch and cleanup ownership The owner's intended boundary is: “the completed pump must not be held open for unrelated follow-ups.” Dispatch leaves the pump's async-work scope and retains an existing live Gateway root until dispatch settles. The incidental webhook root then releases. Required plugin cleanup keeps its separate owner and existing shutdown bounds. The decision to leave the pump scope is made once, by `runClaimed` in `src/channels/message/ingress-drain.ts`. Production changes are +10/−2 lines, net +8, across the dispatch owner and its private storage helper. Claim settlement, cancellation, restart admission, and completed-message deduplication remain unchanged. ## Evidence boundaries The signed `/line/webhook` experiment used a real isolated Gateway, synthetic credentials, deterministic inference, and a local LINE request receiver. It captured an ordinary answer, approval prompt, denial notice, approval-turn answer, queued answer, and next answer. Recipient delivery through the real LINE service is not proved by this experiment. The live green build was `6c7067918343`; production bytes are identical at `2b94019ae275`. The final commit changes only an optional test callback invocation. All 251 selected tests passed on merge `5384b5a718a2`, with parents `2b94019ae275` and main `d229f4a2ba41`. Restoring the original production code makes both new lifetime tests fail. The live approval sequence includes openclaw#148228. The fresh merge also includes openclaw#148301; its reply-source receipt uses separate state that the dispatch scope exit preserves. The live sequence does not include openclaw#148301, and this validation does not claim a new streamed-tail recovery experiment. The earlier Bash failure remains classified as a non-reproduced child startup/import timeout. Six focused head, base, merge, and relevant-parent controls passed. Different hosted runtime and shard conditions prevent treating those local passes as proof that the timeout cannot recur. Hosted CI remains a separate landing check. Co-authored-by: Ayaan Zaidi <[email protected]>
Related: #144801, #148025
What Problem This Solves
Fixes LINE messages failing with “Something went wrong while processing your request” before the agent replies. SMS and Zalo use the same webhook pump.
User Impact
Turns can answer, wait for an exec approval, and answer queued follow-ups after the first turn ends. No configuration or migration is required.
Why This Change Was Made
The ingress drain starts dispatches that outlive the pump. Dispatch now leaves the pump's async-work scope while retaining its existing Gateway root until the task settles. Claim settlement and cancellation are unchanged. Cleanup after dispatch no longer holds the incidental webhook root; independently owned plugin cleanup keeps its own lifetime.
Evidence
/line/webhookon an isolated Gateway reproducedAsync work scope is closedon maina81fd6123fdc, with a failed transcript turn and no inference request.openclaw approvals pendingandopenclaw approvals resolve <id> denycommands drove the real approval.5384b5a718a2with main62a4d0c547bc. Both new lifetime tests fail with the original production code. Type, lint, format, export, architecture and test-partition checks pass.This pass proves the Gateway and delivery boundary, not live LINE service delivery. The contributor also recorded real LINE push receipts at
138cd4fb4b1b.Consumers
The shared monitor and plugin state API use the drain. LINE, SMS and Zalo supply detached webhook pumps; boot-started Discord is a scope-free sibling. Public plugin signatures stay unchanged.
Dispatch and cleanup ownership
The owner's intended boundary is: “the completed pump must not be held open for unrelated follow-ups.” Dispatch leaves the pump's async-work scope and retains an existing live Gateway root until dispatch settles. The incidental webhook root then releases. Required plugin cleanup keeps its separate owner and existing shutdown bounds.
The decision to leave the pump scope is made once, by
runClaimedinsrc/channels/message/ingress-drain.ts. Production changes are +10/−2 lines, net +8, across the dispatch owner and its private storage helper. Claim settlement, cancellation, restart admission, and completed-message deduplication remain unchanged.Evidence boundaries
The signed
/line/webhookexperiment used a real isolated Gateway, synthetic credentials, deterministic inference, and a local LINE request receiver. It captured an ordinary answer, approval prompt, denial notice, approval-turn answer, queued answer, and next answer. Recipient delivery through the real LINE service is not proved by this experiment.The live green build was
6c7067918343; production bytes are identical at2b94019ae275. The final commit changes only an optional test callback invocation. All 251 selected tests passed on merge5384b5a718a2, with parents2b94019ae275and main62a4d0c547bc. Restoring the original production code makes both new lifetime tests fail.The live approval sequence includes #148228. The fresh merge also includes #148301; its reply-source receipt uses separate state that the dispatch scope exit preserves. The live sequence does not include #148301, and this validation does not claim a new streamed-tail recovery experiment.
The earlier Bash failure remains classified as a non-reproduced child startup/import timeout. Six focused head, base, merge, and relevant-parent controls passed. Different hosted runtime and shard conditions prevent treating those local passes as proof that the timeout cannot recur. Hosted CI remains a separate landing check.