Repository navigation
fix(auto-reply): recover failed streamed reply tails without replaying prefixes - #148301
Conversation
|
🦞👀 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, 5:28 PM ET / 21:28 UTC (Revision 6). ClawSweeper reviewWhat this changesThe PR tracks streamed reply completion and delivery receipts so failed tails can recover without repeating safely matched prefixes or already sent attachments. Merge readiness✅ Ready for maintainer review This remains a useful recovery fix absent from inspected main. No blocking introduced defect was found, and the merged prerequisite does not supersede this work. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw’s reply dispatcher turns assistant output into channel messages. Streamed blocks and final replies share delivery evidence to decide what remains safe to send. flowchart TD
A[Assistant output] --> B[Streamed blocks]
B --> C[Speech directive cleaner]
C --> D[Source delivery receipts]
D --> E[Channel delivery]
A --> F[Final reply recovery]
D --> F
F --> G[Send remaining text and media]
F --> H[Suppress completed or uncertain text]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +274, Tests +487. Total +761 across 17 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep source completion with the existing delivery owner, recover only safely matched unsent text, and preserve independent media and uncertain-send accounting. Do we have a high-confidence way to reproduce the issue? Yes at source level: the cleaner can retain text after a delivered prefix while main's final filtering lacks source-completion evidence. The focused tests isolate this mechanism; this review did not execute a current-main reproduction. Is this the best way to solve the issue? Yes. Extending existing delivery receipts is a coherent repair, and the implementation preserves the established conservative fallback when formatted prefixes cannot be matched safely. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 3d21b1dce1d6. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
|
landpr-approve-admin-merge |
|
landpr-approve-unrelated-red |
Move-only refactor; no behavior change. Existing tests are unchanged. ## What Problem This Solves Separates existing delivery code so the streamed-tail fix in #148301 can be reviewed without module movement. ## Why This Change Was Made Moves the normal block handler and ACP declarations into their own modules, and extracts the existing send bodies. Moved statements and literal content are token-identical; only imports, function/module boundaries, and calls change. ## User Impact Reply delivery, ordering, recovery, and cancellation behave as before. ## Evidence `git diff --color-moved=dimmed-zebra --color-moved-ws=allow-indentation-change` shows the moved bodies; the remaining lines are import and call scaffolding. A token comparison confirms unchanged normal/ACP bodies and all four moved declarations. All 824 existing owner tests passed unchanged. Type-aware preflight passed on this head. ## Compatibility No public API, configuration, dependency, or state changes. ## Consumers Normal block dispatch and ACP delivery retain their existing registrations. ## Invalidation No state or lifecycle changes. ## Tests No test files or assertions changed. Co-authored-by: Ayaan Zaidi <[email protected]>
|
landpr-approve-admin-merge |
|
landpr-approve-admin-merge |
|
landpr-approve-admin-merge |
|
Proof: A real Gateway and Discord adapter against a local mock server recovered the missing tail once after transport refusal, preserving prefix order and sending the image bytes once.
|
…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]>
…148318) Move-only refactor; no behavior change. Existing tests are unchanged. ## What Problem This Solves Separates existing delivery code so the streamed-tail fix in openclaw#148301 can be reviewed without module movement. ## Why This Change Was Made Moves the normal block handler and ACP declarations into their own modules, and extracts the existing send bodies. Moved statements and literal content are token-identical; only imports, function/module boundaries, and calls change. ## User Impact Reply delivery, ordering, recovery, and cancellation behave as before. ## Evidence `git diff --color-moved=dimmed-zebra --color-moved-ws=allow-indentation-change` shows the moved bodies; the remaining lines are import and call scaffolding. A token comparison confirms unchanged normal/ACP bodies and all four moved declarations. All 824 existing owner tests passed unchanged. Type-aware preflight passed on this head. ## Compatibility No public API, configuration, dependency, or state changes. ## Consumers Normal block dispatch and ACP delivery retain their existing registrations. ## Invalidation No state or lifecycle changes. ## Tests No test files or assertions changed. Co-authored-by: Ayaan Zaidi <[email protected]>
…g prefixes (openclaw#148301) Depends on openclaw#148318. ## What Problem This Solves A streamed prefix could mark the complete reply sent. If its deferred tail then failed, the final reply was already gone. ## Why This Change Was Made One source receipt owns completion, ordered sends, and final recovery; this state has one writer. Completed sources, including fenced code, are not replayed. Pending sends retain custody. ## User Impact Missing tails recover once, in order. Completed finals are cleared. Safe text and media still send immediately. Final-only media still sends when text is ambiguous, without changing its unknown state. ## Evidence `node scripts/run-vitest.mjs src/auto-reply/reply/dispatch-from-config.source-completion.test.ts`: before, `See `; after, `See [` once. Fifteen producer cases and 410 sibling tests passed, including ambiguous text with unsent media. With a real Gateway and Discord adapter against a local mock server, main lost a buffered literal tail; this head retained it for one queue recovery after the final send was refused, without replaying the prefix or its image bytes. Live Discord closing proof was composed with openclaw#144161's parser commit `8b02f015`; that dependency is excluded here. ## Compatibility No configuration, protocol, storage, or SDK export changes. Parser and terminal drains remain separate work. ## Consumers Normal dispatch, ACP delivery, and direct/final reply accounting share the receipt. ## Invalidation Receipts live for one source and remain reachable through its final settlement. ## Tests Existing split-text fixtures now provide actual delivery settlements. Their assertions are unchanged. ## Contention A concurrent suffix stays behind a failed prefix; safe block admission does not await transport settlement. 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]>
Depends on #148318.
What Problem This Solves
A streamed prefix could mark the complete reply sent. If its deferred tail then failed, the final reply was already gone.
Why This Change Was Made
One source receipt owns completion, ordered sends, and final recovery; this state has one writer. Completed sources, including fenced code, are not replayed. Pending sends retain custody.
User Impact
Missing tails recover once, in order. Completed finals are cleared. Safe text and media still send immediately. Final-only media still sends when text is ambiguous, without changing its unknown state.
Evidence
node scripts/run-vitest.mjs src/auto-reply/reply/dispatch-from-config.source-completion.test.ts: before,See; after,See [once. Fifteen producer cases and 410 sibling tests passed, including ambiguous text with unsent media.With a real Gateway and Discord adapter against a local mock server, main lost a buffered literal tail; this head retained it for one queue recovery after the final send was refused, without replaying the prefix or its image bytes.
Live Discord closing proof was composed with #144161's parser commit
8b02f015; that dependency is excluded here.Compatibility
No configuration, protocol, storage, or SDK export changes. Parser and terminal drains remain separate work.
Consumers
Normal dispatch, ACP delivery, and direct/final reply accounting share the receipt.
Invalidation
Receipts live for one source and remain reachable through its final settlement.
Tests
Existing split-text fixtures now provide actual delivery settlements. Their assertions are unchanged.
Contention
A concurrent suffix stays behind a failed prefix; safe block admission does not await transport settlement.