Skip to content

fix(gateway): clean up aborted queued turns - #103194

Merged
steipete merged 1 commit into
mainfrom
codex/fix-queued-chat-abort-owner
Jul 10, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/fix-queued-chat-abort-owner

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Closes #102914

Supersedes #102995 and #102935.

What Problem This Solves

Fixes an issue where queued chat followup turns could remain in Gateway memory after their owner aborted. A delayed lifecycle callback could also mutate a newer queued turn if the protocol run ID had been reused.

Why This Change Was Made

Queued-turn registration now owns a once-only abort listener, and every completion, retirement, and abort cleanup mutation verifies the exact entry/controller identity before changing the map. This keeps retired collect identities as idempotency guards while preventing stale callbacks from deleting or retiring replacement turns.

This is a clean current-main rebuild of #102995 by @MonkeyLeeT. The commit preserves Ted Li's coauthor credit.

User Impact

Queued turns are removed promptly after cancellation without allowing stale queue state or reused run IDs to interfere with later chat turns. Followup and collect behavior otherwise remains unchanged.

Evidence

  • Blacksmith Testbox tbx_01kx4qhk8g3h74438h2d9dq1yx: 160 focused Gateway tests passed.
  • Same Testbox: real PTY TUI -> Gateway -> local OpenAI-compatible server scenarios passed for normal followup, Esc cancellation before model admission, and collect-mode aggregation.
  • Same Testbox: pnpm check:changed passed for core production and core-test lanes.
  • Fresh full-branch autoreview: no accepted/actionable findings; patch correct at 0.86 confidence.
  • git diff --check passed.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime size: S maintainer Maintainer-authored PR labels Jul 10, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof for exact head 9e30e2219835d377364ce739164463c80f1250d0:

  • Rebuilt cleanly on current main from fix: clean up queued chat turns on abort #102995's owner-cancellation diagnosis, with exact-entry identity guards for registration, completion, collect retirement, single abort, and bulk abort.
  • Sanitized AWS Crabbox cbx_5950e5240b03, run run_6d6b97905437: original contributor head, 148 focused tests passed; lease stopped.
  • Blacksmith Testbox tbx_01kx4qhk8g3h74438h2d9dq1yx: 160 focused Gateway tests passed; pnpm check:changed passed.
  • Live PTY TUI/Gateway proof on that Testbox: normal follow-up, Escape cancellation before model execution, and collect aggregation all passed against a deterministic local OpenAI-compatible server (3/3).
  • Fresh full-branch Codex autoreview: clean, no accepted/actionable findings (0.86 confidence).
  • Exact-head hosted CI run 29061297665, attempt 2: fully green after rerunning one runner-SIGKILL shard at the same SHA; no assertion or product failure was bypassed.
  • Native OPENCLAW_TESTBOX=1 scripts/pr prepare-run 103194: passed with exact PR/prep SHA and current review artifacts.

Known proof gap: the live provider was deterministic/local rather than a paid external model. The changed contract is Gateway/TUI cancellation ownership, so this directly exercises the race without adding provider variability.

Ready to merge.

@steipete
steipete merged commit 0d2db46 into main Jul 10, 2026
179 of 183 checks passed
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui gateway Gateway runtime maintainer Maintainer-authored PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

missing abort event listener on AbortSignal in registerQueuedChatTurn causes memory leak

1 participant