Repository navigation
fix: clean up queued chat turns on abort - #102995
MonkeyLeeT wants to merge 2 commits into
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 9, 2026, 1:54 PM ET / 17:54 UTC. Summary PR surface: Source +11, Tests +75. Total +86 across 3 files. Reproducibility: yes. source-level: current main stores the queued entry after checking only whether the signal is already aborted, and the caller passes the active run controller. I did not execute a current-main failing test in this read-only review. Review metrics: none identified. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review detailsBest possible solution: Land this guarded helper-level cleanup as the canonical fix for #102914, then close or retire #102935 as superseded. Do we have a high-confidence way to reproduce the issue? Yes, source-level: current main stores the queued entry after checking only whether the signal is already aborted, and the caller passes the active run controller. I did not execute a current-main failing test in this read-only review. Is this the best way to solve the issue? Yes. Registering cleanup in AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 9f248969f6c8. Label changesLabel justifications:
Evidence reviewedPR surface: Source +11, Tests +75. Total +86 across 3 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (3 earlier review cycles) |
|
Added real Gateway queue behavior proof to the PR body. Key output now included there: This was run against PR head @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
Dependency GuardThis PR changes dependency-related files. Maintainers should confirm these changes are intentional. Changed files:
Maintainer follow-up:
|
Dependency graph changes are blockedOpenClaw does not accept dependency graph changes through PRs unless a repository admin or security explicitly authorizes the current head SHA. Dependency updates are generated internally by maintainers so external PRs cannot change the resolved graph. Detected dependency graph changes:
Auto-scrub was not attempted because this PR changes package manifest dependency graph fields:
Dependency graph changes must be reviewed by security or handled by maintainers internally. Please remove lockfile changes manually if they are not needed. To remove lockfile changes, restore them from the target branch: git fetch origin
git checkout 'origin/main' -- 'extensions/codex/npm-shrinkwrap.json' 'extensions/meta/npm-shrinkwrap.json' 'pnpm-lock.yaml'
git commit -m 'chore: remove dependency lockfile change'
git pushIf this PR intentionally needs a dependency graph change, ask a repository admin or member of The action will approve the current head SHA ( |
|
Thanks @MonkeyLeeT for the diagnosis and initial regression work. The repaired, clean-history version landed in #103194 as The landed rewrite also binds completion, collect retirement, and abort cleanup to the exact queued-turn controller/entry, so delayed callbacks cannot delete a replacement that reused the same run ID. The fork branch's ancestry became unsuitable for a safe merge during maintainer synchronization, so the final patch was rebuilt on Proof: exact-head hosted CI 29061297665 green; 160 focused Gateway tests and path-scoped gates green on Testbox; three live TUI/Gateway cancellation/collect scenarios green; post-merge current-main focused tests and gates green. Closing as superseded by the credited landed rewrite. Thank you. |
Closes #102914
AI-assisted: yes
What Problem This Solves
Fixes an issue where queued chat followup turns could remain in Gateway memory when the owning abort signal fired before queue completion. This affected the queued chat/followup lifecycle and could leave stale run identities in
chatQueuedTurnsuntil the turn was otherwise processed.Why This Change Was Made
The Gateway now attaches a once-only abort listener when a queued chat turn is registered. The listener removes only the exact current queued entry that still owns cancellation, so stale listeners cannot remove a reused run id and retired collect-mode entries remain as idempotency guards until aggregate completion.
User Impact
Gateway queued chat turns clean up promptly after owner aborts without allowing duplicate dispatches for retired collect entries. This reduces stale in-memory queue state while preserving existing idempotency behavior.
Evidence
Real Gateway queue behavior proof from the production queue module, run against PR head
3aecbe6bf2e443db0cff0ab4df473293dbb3fe80:The proof script imported
registerQueuedChatTurn,retireQueuedChatTurnCancellation,completeQueuedChatTurn, andgetQueuedChatTurnfromsrc/gateway/chat-queued-turns.ts, then exercised the runtime queue map directly. It shows the queued turn is registered, the owner abort signal fires, the entry is removed, stale aborts do not remove reused run ids, and retired collect identities survive abort until completion.Additional validation:
git diff --checknode scripts/run-vitest.mjs src/gateway/chat-queued-turns.test.ts src/gateway/server.chat.gateway-server-chat-b.test.tspassed after final rebase: 6 files, 148 tests.autoreviewpass found a collect-retirement blocker; this PR includes the fix and a regression test for retired collect identities surviving abort until completion.