Repository navigation
fix(agents): avoid extra cleanup waits after cancellation - #149755
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 20, 2026, 11:13 AM ET / 15:13 UTC (Revision 4). ClawSweeper reviewWhat this changesThe PR interrupts optional agent cleanup waits when cancellation arrives, while continuing to await transcript writes and runtime disposal. Merge readiness✅ Ready for maintainer review Keep open: the cancellation race remains on current main and the latest release. The focused patch has no actionable correctness or security findings; the broader provider-reload incident remains separately unresolved. Priority: P2 Review scores
Verification
How this fits togetherThe embedded agent runner cleans up completed or cancelled turns before releasing their resources. It drains transcript callbacks, flushes pending tool results through the database writer, and disposes the session and its runtimes. flowchart TD
A[Turn enters cleanup] --> B[Drain transcript callbacks]
B --> C[Check cancellation]
C --> D[Optional idle wait]
E[Cancellation signal] --> D
D --> F[Await transcript writer]
F --> G[Dispose session and runtimes]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +21, Tests +169. Total +190 across 10 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep cancellation confined to optional idle waiting while preserving writer admission and resource settlement, with broader reload recovery tracked separately. Do we have a high-confidence way to reproduce the issue? Yes, from source: cancel while transcript draining or a pending idle wait is in progress; current main can retain stale cancellation state or wait until the timer expires. This review did not execute a reproduction. Is this the best way to solve the issue? Yes. Extending the existing cleanup owner is a narrow repair, and the signal does not bypass required transcript persistence or runtime disposal. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 78f77e5006d3. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles) |
Read cancellation after transcript draining and interrupt only the optional idle wait. Keep pending transcript writes and runtime disposal awaited, and forward cancellation through preparation-failure and compaction cleanup. Related to #149612. Co-authored-by: RomneyDa <[email protected]>
6490a91 to
d245e36
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
…49755) Read cancellation after transcript draining and interrupt only the optional idle wait. Keep pending transcript writes and runtime disposal awaited, and forward cancellation through preparation-failure and compaction cleanup. Related to openclaw#149612. Co-authored-by: RomneyDa <[email protected]>
Related: #149612
What Problem This Solves
Fixes canceled agent turns waiting through an unnecessary idle timeout when cancellation arrives during cleanup.
User Impact
Canceled turns stop optional idle waits promptly while required transcript writes and runtime disposal still finish. This does not reset session lanes, replay completed actions, or change provider-generation authority.
This fixes the demonstrated cleanup races; the full provider-reload stall and high memory usage remain unverified.
Why This Change Was Made
Cleanup now rereads cancellation after draining transcript writes and forwards the cancellation signal into the optional idle wait, including preparation-failure and compaction cleanup. The signal interrupts only that wait; persistence and resource settlement retain their existing ownership and ordering.
Evidence
a37efbafbec59a00bb1c2e78ad1b2f5927bb01c1without conflicts. The prior Goal assertion and chat-pane lint error also failed on the exact tested base. Existing upstream repairs #149765 and #149826 are now included; the Goal tests and affected UI lint pass locally. No unrelated source workaround was added.aborted: falsestate, and the already-canceled / canceled-during-idle regressions failed.d245e363c8e6fe5aad0cf70dd57de79d0fe107f4, including the previously failing Goal case and covering cancellation timing, late rejection, timer/listener cleanup, actual SQLite write admission, runtime disposal, preparation failure, compaction, and lane timeout safeguards.git range-diffconfirms this refresh is a patch-identical rebase.Focused test command
Worked on by: @RomneyDa
Work sessions