Repository navigation
fix(sessions): keep one agent's queue cleanup from cancelling another agent's work - #162179
Conversation
Use the existing lifecycle queue owner for provider precautions, worker placement dispatch and move barriers, and transcript rewind/branch switches. Preserve other agents' work in shared raw-key lanes while cancelling the selected agent and session incarnation. Revalidate existing authority at cleanup and retain rewind's original session ID after history rotation. Boundary regressions exercise real settlement, barrier, and Gateway handler entry points and fail again when the production changes are temporarily reverted.
Cancel all incarnations only within the selected agent and conversation when no session ID is supplied. Keep dispatch, move, and rewind queue settlement unconditional after committed effects. Retain subagent raw-key cleanup pending target ownership in the registry.
|
🦞👀 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 30, 2026, 7:59 PM ET / 23:59 UTC (Revision 3). ClawSweeper reviewWhat this changesThe branch scopes pending follow-up and command-queue cancellation to the selected agent during provider review, worker placement, session rewind, broad abort, and interrupt admission. Merge readiness✅ Ready for maintainer review Keep open. Current main still has unscoped cleanup at the additional entry points, and the related merged PR explicitly deferred them. This is a distinct, coherent follow-up with no discrete introduced defect established in this review. Priority: P1 Review scores
Verification
How this fits togetherThe Gateway and reply runner place session work into shared follow-up and command queues. Cleanup receives an agent and session target, then removes pending work before later replies or commands run. flowchart LR
A[Stop, rewind, move, pause, or interrupt] --> B[Gateway or reply runner]
B --> C[Agent and session target]
C --> D[Shared queue cleanup]
D --> E[Selected work canceled]
D --> F[Other agent work preserved]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +46, Tests +674. Total +720 across 21 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: Use one agent-scoped cleanup owner across these entry points so a session action cancels its selected queued work while preserving other agents' work and the existing keyless interrupt behavior. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main still clears shared keys at the affected callers, and the PR supplies two-agent boundary regressions reported to fail before and pass after the change. This read-only review did not execute them. Is this the best way to solve the issue? Yes. Reusing the existing queue cleanup owner is a narrow repair for the remaining callers, and the tests check both selected cancellation and preservation of another agent's work. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 32680440ce92. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
The stale interrupt expectation is corrected to require The previous CI run's embedded Stop job failed these two cases in
The reported assertion was I compared a freshly fetched main, Each run used: pnpm test src/gateway/server-methods/sessions.abort-embedded.test.ts --maxWorkers=1
Per the maintainer's decision for a clean comparison on both sources, the original Stop failure is treated as flaky. These passing replays do not establish a fix for that failure; its original CI evidence remains recorded above. Provider: Blacksmith Testbox, lease |
|
Merged via squash.
|
#162179 (45a3d17) added an explained @ts-expect-error to get-reply-run-admission.session-file.test.ts so the test can exercise the runtime fallback for a missing session key. It did not register that suppression in the type-suppression inventory, so "keeps unchecked any casts at zero and negative type assertions explicit" saw 17 entries instead of 16 and turned scheduled main CI red (run 36800483241, checks-node-compact-small-49). Add the exact file:excerpt entry. The inventory still binds each suppression to its file and explanation text, and the any-cast counters stay at zero. Test cost: node scripts/run-vitest.mjs test/scripts/type-suppression-inventory.test.ts --maxWorkers=1 = 29.6s wall (4 tests). No new tests.
… agent's work (openclaw#162179) * fix(sessions): scope provider, placement, and rewind queue cleanup Use the existing lifecycle queue owner for provider precautions, worker placement dispatch and move barriers, and transcript rewind/branch switches. Preserve other agents' work in shared raw-key lanes while cancelling the selected agent and session incarnation. Revalidate existing authority at cleanup and retain rewind's original session ID after history rotation. Boundary regressions exercise real settlement, barrier, and Gateway handler entry points and fail again when the production changes are temporarily reverted. * fix(sessions): scope broad stop and interrupt queue cleanup Cancel all incarnations only within the selected agent and conversation when no session ID is supplied. Keep dispatch, move, and rewind queue settlement unconditional after committed effects. Retain subagent raw-key cleanup pending target ownership in the registry. * fix(sessions): keep keyless interrupt clearing its own lane * test(sessions): fail keyless interrupt regression fast * test(sessions): document keyless runtime fixture * test(sessions): expect scoped interrupt lane clear Co-authored-by: Peter Steinberger <[email protected]>
openclaw#162179 (88a22af) added an explained @ts-expect-error to get-reply-run-admission.session-file.test.ts so the test can exercise the runtime fallback for a missing session key. It did not register that suppression in the type-suppression inventory, so "keeps unchecked any casts at zero and negative type assertions explicit" saw 17 entries instead of 16 and turned scheduled main CI red (run 36800483241, checks-node-compact-small-49). Add the exact file:excerpt entry. The inventory still binds each suppression to its file and explanation text, and the any-cast counters stay at zero. Test cost: node scripts/run-vitest.mjs test/scripts/type-suppression-inventory.test.ts --maxWorkers=1 = 29.6s wall (4 tests). No new tests.
Related: #161736
What Problem This Solves
Fixes: one agent's worker placement move, rewind, provider-review pause, broad
sessions.abort, or interrupt-mode reply could cancel a different agent's queued follow-ups and session-lane commands when both agents used the same raw session key (for exampleglobal).User Impact
Stopping, rewinding, moving, or interrupting one agent's conversation now only cancels that agent's queued work. Other agents sharing a
globalor bare-alias session keep their queued follow-ups and commands. Behavior for a single agent is unchanged, except that a broad Stop now also cancels its own key-only queued follow-ups when no session row exists yet.Why This Change Was Made
#161736 added the agent-scoped queue cleanup owner (
clearSessionLifecycleQueues) for delete/reset/archive and/stop. Six production callers still used the raw-keyclearSessionQueuesor a whole-laneclearCommandLane, which wipe process-wide queues for every agent under that key. This PR moves them onto the same owner:main'sglobalqueue fromresearchmain's tagged + untagged lane commandssessions.abortfallbackmain's follow-ups under a shared bare keymain's lane commands onsession:globalclearSessionLifecycleLanes; keyless runs keep their own sessionId lane clearOwner contract change: an omitted
sessionIdinSessionLifecycleQueueTargetnow means "every incarnation of this agent's session" (previously: no follow-ups, untagged lanes only). All existing callers that can omit it were audited (reset, delete, drain, fast abort,/stop); none relied on the old behavior. Calls with asessionIdkeep exact-incarnation matching.Not changed: subagent kill and sweep still use
clearSessionQueues. Sweep only receives strict agent-qualified keys. Direct kill has a remaining gap for raw-key children registered by a watchedsessions_send, because the subagent registry doesn't record the target agent. That needs a registry schema decision and is tracked as a follow-up, soclearSessionQueuesstays for now.Evidence
Every boundary regression drives the real entry point with agents
mainandresearchsharing a raw key. Each one failed onmainand failed again when only the production changes were reverted. Proof ran on Blacksmith Testbox because the local host was saturated./stopsuites.pnpm tsgo, targeted oxlint, andoxfmt --checkall pass. Autoreview is scoped-clean at P2.Test cost (pnpm test <file> --maxWorkers=1, Testbox wall)
Most of each wall time is compilation. No real timers, sleeps, or per-test Gateway boots were added.