Repository navigation
fix(approvals): forwarded approval prompts are dropped while a channel's native approval handler is not running - #148228
Conversation
…t running Forwarding skipped a chat whenever the channel's approval capability said native delivery covers it, reading configuration only. While that account's native handler was not running (bootstrap deferred or disabled, or the account task stopped), the chat got neither the native prompt nor the text prompt and the approval waited until it expired. Honor the channel's suppression only while the owning Gateway's route coordinator has an active native runtime for that channel, account, and approval kind, the same fact the local prompt path already checks. The Gateway passes its instance coordinator to the forwarder, since the forwarder does not run inside a channel account task.
…kind of the runtime check
|
🦞👀 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, 11:51 AM ET / 15:51 UTC (Revision 2). ClawSweeper reviewWhat this changesKeeps forwarded approval prompts available when the destination account’s native approval handler is inactive, and adds Gateway delivery regression coverage. Merge readiness✅ Ready for maintainer review The fix remains necessary on current main. No blocking patch defect was found, and the supplied Telegram observations address the previous real-delivery proof request. Priority: P2 Review scores
Verification
How this fits togetherThe Gateway forwards execution and plugin approval requests to configured chat destinations. Channel plugins provide native approval interfaces; the Gateway’s runtime coordinator records which handlers are running so forwarding can avoid suppressing the only available prompt. flowchart TD
A[Approval request] --> B[Resolve configured chat destinations]
B --> C[Channel requests native suppression]
D[Owning Gateway handler registry] --> E{Matching handler active?}
C --> E
E -->|Yes| F[Native approval delivery]
E -->|No| G[Forward approval prompt]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +35, Tests +357. Total +392 across 12 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Keep native-handler activity owned by the Gateway coordinator and preserve configured forwarding whenever that destination lacks a running handler. Do we have a high-confidence way to reproduce the issue? Yes: current main suppresses configured native destinations even when their handler is absent, and the supplied Telegram baseline reports that exact failure. This review verified the source path without executing it. Is this the best way to solve the issue? Yes: the patch reuses the existing runtime owner and destination account resolver, preserves channel-specific suppression policy, and avoids changing the public plugin contract. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against fbaa870a01eb. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
landpr-approve-admin-merge |
|
landpr-approve-unrelated-red |
|
Thanks @edenfunf! Proof: A session-bound approval reached Telegram while native startup was deferred. With the native handler active, one native prompt appeared without a forwarded duplicate.
|
…pe is closed" before the agent replies (#148548) 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 - A self-signed POST to `/line/webhook` on an isolated Gateway reproduced `Async work scope is closed` on main `a81fd6123fdc`, 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 `62a4d0c547bc`. 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 `62a4d0c547bc`. 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. Co-authored-by: Ayaan Zaidi <[email protected]>
…penclaw#148228) Keep forwarded exec and plugin approval prompts available while the destination's native handler is unavailable. Check the owning Gateway's existing channel, account, and approval-kind runtime before applying native suppression. Cover registered Gateway delivery, native lifecycle, destination-default selection, and runtime isolation. Verify the session-bound request through real Telegram delivery with native startup deferred and with native delivery active. Co-authored-by: Ayaan Zaidi <[email protected]>
…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]>
Closes #148031
Related: #147255
What Problem This Solves
Fixes: when a channel is configured for native approval delivery but that account's native approval handler is not running (bootstrap still retrying, start given up, or the account stopped), approval forwarding still skips the chat, so prompts that only forwarding delivers never arrive; plugin approvals, which have no local prompt, wait silently until they time out.
User Impact
User impact: while a channel's native approval handler is not running, forwarded exec and plugin approval prompts are delivered as text instead of being dropped; while the handler is running nothing changes. This applies to every bundled channel that defers forwarded prompts to native delivery: Discord, Google Chat, iMessage, Matrix, Microsoft Teams, Signal, Slack, Telegram, and WhatsApp. No config or plugin API change. It also removes the reason LINE's native approval cards (#147255) keep every forwarded text prompt next to the card: that override exists only because the forwarder could not see whether the card handler runs, so LINE can stop sending the extra push to chats its cards already cover while still keeping prompts for forwarding targets cards never reach.
Tradeoffs: an exec approval raised by an agent turn in the same chat already gets the local
/approveprompt in that chat, so insessionmode that chat now also receives the forwarded text prompt, which is what channels without native approvals already do. If a handler that was only briefly deferred (for example in the first seconds of Gateway startup) comes up while an approval is still pending, it replays pending approvals, so that chat can additionally get the native card; either prompt resolves the same approval. Both follow the documented rule for native approval clients that are configured without an active runtime ("OpenClaw keeps the local deterministic/approveprompt visible"). Out of scope: the forwarding decision is still made once when the request arrives, so a handler that stops after it took a request is not re-evaluated here; a resolution that arrives with no pending forwarding entry re-checks the current handler state, so it may add one text outcome notice in that case.Why This Change Was Made
The forwarder honored a channel's
shouldSuppressForwardingFallbackfrom configuration alone. It now honors that suppression only while the owning Gateway's native route coordinator has an active runtime for the target's channel, account, and approval kind, which is the fact the local prompt path already passes asnativeRouteActive; both paths now read it through one helper. The Gateway passes a getter for its instance coordinator to the forwarder because the forwarder does not run inside a channel account task, so the async-local runtime scope is not available there; the parameter is required on the auxiliary handlers so that wiring cannot be dropped silently, which would otherwise read the always-empty process-default state and bring back duplicate prompts. Adding a runtime hint to the public suppressor contract instead would have required every channel suppressor, including third-party ones, to adopt it before the bug went away. The handler checked is the destination's: the target's own account, or that channel's default account when the target names none, which is the account native approval routing assigns to such a target; a request's source account is never applied to a different channel, so an approval from Telegram accountworkforwarded to a Discord target still sees Discord's running default handler.The getter also preserves startup order: auxiliary handlers are created before the Gateway instance. Native handler registration has one state owner: the Gateway's route coordinator. The owner accepted the +35 net production growth on 2026-09-14 14:50Z.
Evidence
Real Gateway → Telegram Test Server recordings, with a persisted session verified before each approval request. Native startup was deliberately deferred while ordinary chat transport remained available.
f8cd665c2b44ba887fb7b45ba887fb7b45All three accepted recordings completed with exit 0 and released their test credentials. The active control also recorded an unrelated mock heartbeat; approval counts use the requested approval's identity.
Recorder:
run-mock-sut-user-e2e.mjs --dm --scenario scenario.json --timeout-ms 50000 --record events.ndjson --output summary.json, with isolated ports and the native-start control. The scenario sends/status, verifiessessions.list, callsplugin.approval.requestwith the persisted session key, sends/statusagain, then resolves the request as denied.Sanitized observed sequence: main:
status reply → no approval prompt → status reply; candidate:status reply → approval prompt → status reply → denial notice.The registered Gateway regression now checks the actual outbound prompt, request ID and account field. It covers inactive, active and stopped routes, the configured destination default, and another Gateway instance's route. Existing tests retain other-account, other-channel and approval-kind cases. The earlier admission-only test and redundant fixture cast were removed.
A fresh merge with main
bcfe3383b87dproduced2dd260f67bb8: 133 tests passed across 11 owner/sibling files. Production and affected test types, changed-file type-aware lint, formatting, architecture, unused exports, assertion/line ratchets, and test ownership checks passed. Hosted CI owns the full matrix.Limits: this proves registered Gateway requests reaching real Telegram delivery. It does not claim a chat-originating tool turn, a natural startup incident, late native replay, or live delivery on every other channel.
Consumers
The Gateway auxiliary constructor, exec/plugin forwarder, local prompt path, native runtime lifecycle, and terminal delivery consumers were checked on the fresh merge. Both strategies share one suppression decision. Pending requests retain their original destinations; new routing decisions read current runtime state. No configuration, schema, plugin API or authorization contract changed.