Repository navigation
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. |
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Close as superseded by #195612, which addresses the same delayed Stop failure at the producer, supplies Gateway evidence, and passes the current CI gate. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Canonical path: Consolidate the delayed Stop repair in #195612, preserving command history and existing replay barriers. So I’m closing this here and keeping the remaining discussion on #195612. Review detailsBest possible solution: Consolidate the delayed Stop repair in #195612, preserving command history and existing replay barriers. Do we have a high-confidence way to reproduce the issue? Current source and the reporter's fixture establish how a delayed command exchange displaces the persisted replay anchor; this read-only review executed no target code. Is this the best way to solve the issue? Repairing Stop ordering through existing source retention is more complete than broadly crossing all command exchanges during replay. Security review: Security review cleared: No concrete credential, authorization, dependency, or supply-chain regression was identified. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning medium; reviewed against 2f199387d3dc. |
|
Answering the intent question first, since it decides whether the change is even allowed to look like this. What the change does and does not touch. Why it cannot swallow an ordinary command's turn. Why keying on the context-free marker instead would not fix the bug. The The recovery path. The walk from the tail now steps over
On the remaining ask (a shipped Gateway trace): I will add one showing a queued follow-up being answered across |
|
Adding what I can and being explicit about what I cannot, so nobody waits on me for a trace I am not able to produce. What I cannot produce here. A live Gateway trace needs an agent turn that is still running when the follow-up is How to verify in about two minutes with a configured provider (any channel or the Control UI both work):
What the committed fixture does prove. On If the maintainer would rather have the Gateway trace as a merge condition and cannot run it either, I am fine with this |
|
@clawsweeper re-review Answering the second item, and being explicit about the first. Ordinary versus context-free command behavior (#192585 intent preserved).
Real behavior proof (still not producible here). Two reproducible environment limits, both unrelated to this change:
To capture the trace elsewhere: start a Gateway with the mock provider ( |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review Corrected the proof-gap explanation in the body: my earlier note blamed e2e process-supervisor failures, which was not the I did build the stack and drive it: an isolated gateway from a built worktree plus the repo's mock model server returns That also means I cannot claim a gateway trace for this fix. What stands is the predicate-level proof in the PR's fixture, |
|
🦞👀 Re-review progress:
|
acd1279 to
ba38416
Compare
…a-stop-exchange-admission-194303
…a-stop-exchange-admission-194303
…a-stop-exchange-admission-194303
|
Closing this myself rather than leaving it open indefinitely. State of the change: the fix is complete and green (the predicate is covered by a regression test that fails on the base Since a proof I cannot produce would otherwise keep the PR parked forever, the honest outcome is to close it and leave the
If a maintainer wants the change, the branch and its tests are intact and can be reopened on request. |
|
Closing: fix verified at the predicate boundary, but the requested Gateway/channel trace is not producible in this environment (see comment above). Reopenable as-is. |
…Stop reply is delivered late (#195612) Root cause: src/auto-reply/reply/dispatch-from-config.prepare-operation.ts:217 (on main 1680f54) the fast-abort path lets Stop cancel and release its own message source at once, while a direct Stop reply records its `/stop` exchange only later, at dispatcher settlement after delivery. A turn accepted while that reply is still being sent persists its user row first, so the Stop exchange lands after it and the follow-up can fail replay admission ("Persisted user turn changed before replay admission") and go unanswered. Fixes #194303 Thanks @amittell for the report, the root-cause analysis and this fix. Thanks @arcabotai for #195358, which reported the same unanswered follow-up; this PR fixes the Stop path at the producer instead of relaxing replay admission. ## What Problem This Solves Fixes: a message sent right after `/stop` is recorded ahead of the Stop exchange in session history, and can go unanswered, when the Stop reply reaches the channel late. ## User Impact User impact: after `/stop`, the next message waits until the Stop reply is delivered and recorded, then runs and is answered once, with the Stop exchange first in history. Input already waiting when Stop arrived is still cancelled, as before. ## Why This Change Was Made Once a stop request is recognized, before Stop selects anything, dispatch retains the Stop message's own source until the Stop reply settles (dispatcher settlement, bounded by the existing follow-up admission barrier timeout). The mailbox does not select past a source with unsettled work, so the next turn starts after the Stop rows. If the abort resolver throws or the message is not handled as a stop, the retention is released immediately. Unchanged: what Stop cancels, command classification, the command history format, and replay admission (a command row written before a turn still refuses a stale replay). #194336, #194396 and #195358 instead make command exchanges traversable for replay admission, which reverses the `c2cb56c665e` boundary; this PR touches neither replay predicate. Maintainer edits on top of @amittell's commits: merged current main, rewrote the retention without re-indenting the fast-abort branch (`.catch`/`.finally` instead of `try/finally`), and kept one red-on-base regression (dispatch order) in place of the two test files and the test-lines allocation. ## Evidence Observed proof lines (base and head): #195612 (comment) - Regression `dispatch-from-config.command-transcript.test.ts` > "records a late-delivered /stop before the next turn's row" (active run false/true): main 1680f54 fails 2/2 with `expected [ 'next-turn', 'command-input', …(1) ] to deeply equal [ 'command-input', …(2) ]`; this head passes 4/4. - Real Gateway (`ocx src --node`) with the Telegram plugin, a local Bot API that holds the Stop reply, and a local chat-completions model: on main the follow-up's user row and answer are written before `/stop` / `Agent was aborted.`; here the Stop exchange is recorded first, then the follow-up row and one answer. `/stop` alone behaves the same on both. - Replay admission still refuses a genuinely out-of-order replay: `attempt-session-replay-cohort.test.ts` (including `completed-after-preparation`), the steering replay test and `abort.test.ts` pass, 48/48. ## Merge danger Two-way door: no stored data, config or contract change; a revert restores the old ordering. Blast radius: channels that send `/stop` as a message; a hung Stop delivery delays the next turn by at most the existing follow-up admission barrier timeout. Co-authored-by: Ayaan Zaidi <[email protected]>
…Stop reply is delivered late (openclaw#195612) Root cause: src/auto-reply/reply/dispatch-from-config.prepare-operation.ts:217 (on main 5cd28bd) the fast-abort path lets Stop cancel and release its own message source at once, while a direct Stop reply records its `/stop` exchange only later, at dispatcher settlement after delivery. A turn accepted while that reply is still being sent persists its user row first, so the Stop exchange lands after it and the follow-up can fail replay admission ("Persisted user turn changed before replay admission") and go unanswered. Fixes openclaw#194303 Thanks @amittell for the report, the root-cause analysis and this fix. Thanks @arcabotai for openclaw#195358, which reported the same unanswered follow-up; this PR fixes the Stop path at the producer instead of relaxing replay admission. ## What Problem This Solves Fixes: a message sent right after `/stop` is recorded ahead of the Stop exchange in session history, and can go unanswered, when the Stop reply reaches the channel late. ## User Impact User impact: after `/stop`, the next message waits until the Stop reply is delivered and recorded, then runs and is answered once, with the Stop exchange first in history. Input already waiting when Stop arrived is still cancelled, as before. ## Why This Change Was Made Once a stop request is recognized, before Stop selects anything, dispatch retains the Stop message's own source until the Stop reply settles (dispatcher settlement, bounded by the existing follow-up admission barrier timeout). The mailbox does not select past a source with unsettled work, so the next turn starts after the Stop rows. If the abort resolver throws or the message is not handled as a stop, the retention is released immediately. Unchanged: what Stop cancels, command classification, the command history format, and replay admission (a command row written before a turn still refuses a stale replay). openclaw#194336, openclaw#194396 and openclaw#195358 instead make command exchanges traversable for replay admission, which reverses the `1bcf6c36036` boundary; this PR touches neither replay predicate. Maintainer edits on top of @amittell's commits: merged current main, rewrote the retention without re-indenting the fast-abort branch (`.catch`/`.finally` instead of `try/finally`), and kept one red-on-base regression (dispatch order) in place of the two test files and the test-lines allocation. ## Evidence Observed proof lines (base and head): openclaw#195612 (comment) - Regression `dispatch-from-config.command-transcript.test.ts` > "records a late-delivered /stop before the next turn's row" (active run false/true): main 5cd28bd fails 2/2 with `expected [ 'next-turn', 'command-input', …(1) ] to deeply equal [ 'command-input', …(2) ]`; this head passes 4/4. - Real Gateway (`ocx src --node`) with the Telegram plugin, a local Bot API that holds the Stop reply, and a local chat-completions model: on main the follow-up's user row and answer are written before `/stop` / `Agent was aborted.`; here the Stop exchange is recorded first, then the follow-up row and one answer. `/stop` alone behaves the same on both. - Replay admission still refuses a genuinely out-of-order replay: `attempt-session-replay-cohort.test.ts` (including `completed-after-preparation`), the steering replay test and `abort.test.ts` pass, 48/48. ## Merge danger Two-way door: no stored data, config or contract change; a revert restores the old ordering. Blast radius: channels that send `/stop` as a message; a hung Stop delivery delays the next turn by at most the existing follow-up admission barrier timeout. Co-authored-by: Ayaan Zaidi <[email protected]>
…Stop reply is delivered late (#195612) Root cause: src/auto-reply/reply/dispatch-from-config.prepare-operation.ts:217 (on main 1680f54) the fast-abort path lets Stop cancel and release its own message source at once, while a direct Stop reply records its `/stop` exchange only later, at dispatcher settlement after delivery. A turn accepted while that reply is still being sent persists its user row first, so the Stop exchange lands after it and the follow-up can fail replay admission ("Persisted user turn changed before replay admission") and go unanswered. Fixes #194303 Thanks @amittell for the report, the root-cause analysis and this fix. Thanks @arcabotai for #195358, which reported the same unanswered follow-up; this PR fixes the Stop path at the producer instead of relaxing replay admission. ## What Problem This Solves Fixes: a message sent right after `/stop` is recorded ahead of the Stop exchange in session history, and can go unanswered, when the Stop reply reaches the channel late. ## User Impact User impact: after `/stop`, the next message waits until the Stop reply is delivered and recorded, then runs and is answered once, with the Stop exchange first in history. Input already waiting when Stop arrived is still cancelled, as before. ## Why This Change Was Made Once a stop request is recognized, before Stop selects anything, dispatch retains the Stop message's own source until the Stop reply settles (dispatcher settlement, bounded by the existing follow-up admission barrier timeout). The mailbox does not select past a source with unsettled work, so the next turn starts after the Stop rows. If the abort resolver throws or the message is not handled as a stop, the retention is released immediately. Unchanged: what Stop cancels, command classification, the command history format, and replay admission (a command row written before a turn still refuses a stale replay). #194336, #194396 and #195358 instead make command exchanges traversable for replay admission, which reverses the `c2cb56c665e` boundary; this PR touches neither replay predicate. Maintainer edits on top of @amittell's commits: merged current main, rewrote the retention without re-indenting the fast-abort branch (`.catch`/`.finally` instead of `try/finally`), and kept one red-on-base regression (dispatch order) in place of the two test files and the test-lines allocation. ## Evidence Observed proof lines (base and head): #195612 (comment) - Regression `dispatch-from-config.command-transcript.test.ts` > "records a late-delivered /stop before the next turn's row" (active run false/true): main 1680f54 fails 2/2 with `expected [ 'next-turn', 'command-input', …(1) ] to deeply equal [ 'command-input', …(2) ]`; this head passes 4/4. - Real Gateway (`ocx src --node`) with the Telegram plugin, a local Bot API that holds the Stop reply, and a local chat-completions model: on main the follow-up's user row and answer are written before `/stop` / `Agent was aborted.`; here the Stop exchange is recorded first, then the follow-up row and one answer. `/stop` alone behaves the same on both. - Replay admission still refuses a genuinely out-of-order replay: `attempt-session-replay-cohort.test.ts` (including `completed-after-preparation`), the steering replay test and `abort.test.ts` pass, 48/48. ## Merge danger Two-way door: no stored data, config or contract change; a revert restores the old ordering. Blast radius: channels that send `/stop` as a message; a hung Stop delivery delays the next turn by at most the existing follow-up admission barrier timeout. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit b42a8ff) Co-authored-by: RomneyDa <[email protected]>
…Stop reply is delivered late (openclaw#195612) Root cause: src/auto-reply/reply/dispatch-from-config.prepare-operation.ts:217 (on main 1680f54) the fast-abort path lets Stop cancel and release its own message source at once, while a direct Stop reply records its `/stop` exchange only later, at dispatcher settlement after delivery. A turn accepted while that reply is still being sent persists its user row first, so the Stop exchange lands after it and the follow-up can fail replay admission ("Persisted user turn changed before replay admission") and go unanswered. Fixes openclaw#194303 Thanks @amittell for the report, the root-cause analysis and this fix. Thanks @arcabotai for openclaw#195358, which reported the same unanswered follow-up; this PR fixes the Stop path at the producer instead of relaxing replay admission. ## What Problem This Solves Fixes: a message sent right after `/stop` is recorded ahead of the Stop exchange in session history, and can go unanswered, when the Stop reply reaches the channel late. ## User Impact User impact: after `/stop`, the next message waits until the Stop reply is delivered and recorded, then runs and is answered once, with the Stop exchange first in history. Input already waiting when Stop arrived is still cancelled, as before. ## Why This Change Was Made Once a stop request is recognized, before Stop selects anything, dispatch retains the Stop message's own source until the Stop reply settles (dispatcher settlement, bounded by the existing follow-up admission barrier timeout). The mailbox does not select past a source with unsettled work, so the next turn starts after the Stop rows. If the abort resolver throws or the message is not handled as a stop, the retention is released immediately. Unchanged: what Stop cancels, command classification, the command history format, and replay admission (a command row written before a turn still refuses a stale replay). openclaw#194336, openclaw#194396 and openclaw#195358 instead make command exchanges traversable for replay admission, which reverses the `c2cb56c665e` boundary; this PR touches neither replay predicate. Maintainer edits on top of @amittell's commits: merged current main, rewrote the retention without re-indenting the fast-abort branch (`.catch`/`.finally` instead of `try/finally`), and kept one red-on-base regression (dispatch order) in place of the two test files and the test-lines allocation. ## Evidence Observed proof lines (base and head): openclaw#195612 (comment) - Regression `dispatch-from-config.command-transcript.test.ts` > "records a late-delivered /stop before the next turn's row" (active run false/true): main 1680f54 fails 2/2 with `expected [ 'next-turn', 'command-input', …(1) ] to deeply equal [ 'command-input', …(2) ]`; this head passes 4/4. - Real Gateway (`ocx src --node`) with the Telegram plugin, a local Bot API that holds the Stop reply, and a local chat-completions model: on main the follow-up's user row and answer are written before `/stop` / `Agent was aborted.`; here the Stop exchange is recorded first, then the follow-up row and one answer. `/stop` alone behaves the same on both. - Replay admission still refuses a genuinely out-of-order replay: `attempt-session-replay-cohort.test.ts` (including `completed-after-preparation`), the steering replay test and `abort.test.ts` pass, 48/48. ## Merge danger Two-way door: no stored data, config or contract change; a revert restores the old ordering. Blast radius: channels that send `/stop` as a message; a hung Stop delivery delays the next turn by at most the existing follow-up admission barrier timeout. Co-authored-by: Ayaan Zaidi <[email protected]> Release adaptation: Add callback to existing abort parameter type; defer Stop transcript through existing dispatcher lifecycle barrier. (cherry picked from commit b42a8ff) Co-authored-by: RomneyDa <[email protected]>
What Problem This Solves
A follow-up message queued while a run is active is dropped when
/stopis used. The dispatcher mirrors the stop'scommand exchange into the transcript, and the queued follow-up's replay admission then resolves the command row as
the current turn, refuses with
Persisted user turn changed before replay admission, and the message is never answered.Reproduced with the reporter's fixture (
extensions-free, real session manager + real transcript): onmainthe queuedfollow-up ends with
0model calls and that error; with this change it is answered.Why This Change Was Made
src/agents/sessions/session-manager-current-turn.tsdecides which transcript entries the current-turn walk may stepover. It already treats context metadata, compaction markers and runtime/system custom messages as traversable because
they are not model-facing turns. A delivered command exchange is the same kind of row — a transcript mirror of the
dispatcher's reply — but it was not listed, so the walk stopped on it.
The fix marks rows whose
idempotencyKeyiscommand-input:*orcommand-reply:*as traversable. Nothing else changes:real user turns still stop the walk, and the admission still requires the prepared user message to match exactly.
User Impact
A queued follow-up survives
/stop: it is persisted once and gets answered instead of silently disappearing behind ageneric "couldn't finish this reply". Commands that are not mirrored (
/newetc. still write their exchange the sameway) behave the same, and no transcript bytes change.
Evidence
Reporter's fixture, run with
node scripts/test-projects.mts <file>:/stopexchange interposedPersisted user turn changed before replay admission, 0 model callsFOLLOWUP_ANSWERED2 failed | 4 passed(both reader modes fail on the interposed case). Fixed:6 passed.attempt-session-replay.test.ts61 passed;session-manager-bounded.test.ts28 passed;session-manager-async-entries.test.ts9 passed.oxlint: 0 warnings, 0 errors. The new test file carries an allocation inconfig/test-lines-allocations/stop-exchange-replay-admission.txt.Why there is no gateway-level trace here
I built the full isolated stack and tried to drive the reported race, then stopped when the attempt could not reach
the state the report describes. What works, and what does not:
gateway run --port 3099with a--profile-isolated config,/health200) plus the repo's mock model server (scripts/e2e/mock-openai-server.mjs) really does run agent turns —openclaw --profile … agent -m "…"returns the mock's marker.openclaw agent -m "/stop"is delivered as an ordinary user message, not as a slashcommand. In my runs the long first turn reported
aborted: falseandstopReason: "stop", and the/stopcall wasqueued and answered like any other turn. Without an actual command-path stop there is no command exchange mirrored
into the transcript, which is precisely the precondition this fix changes.
trace is missing. The accurate reason is the one above: the CLI agent channel does not exercise the command path.
What a reviewer can run instead, given a channel that delivers commands (the report used Telegram): queue a follow-up
during an active turn, send
/stop, and confirm the queued message still reaches a model request instead of failing withPersisted user turn changed before replay admission. The reporter's fixture in this PR covers the same predicate withouta channel: it fails on base with that error and passes with the change.
Scope
One production file (the traversal predicate), the reporter's regression test registered next to
attempt-session-replay.test.tsintest/vitest/vitest.database-worker-core-paths.mjs, and the allocation file.AI Assistance
This PR was prepared with AI assistance from the issue report and its attached fixture; the author reviewed the change
and its evidence.
Gateway-level proof: what a CI-shaped test would need
I could not produce this here (no provider endpoint on this machine), but the pieces are in the repo:
test/helpers/openclaw-test-instance.tsstarts a real Gateway with isolated state without Playwright(
startGateway/port/url/cli), so the queue/stop sequence can be driven over the Gateway API.scripts/e2e/mock-openai-server.mjsis an OpenAI-compatible mock withMOCK_RESPONSE_CHUNK_DELAY_MS, which keeps a turnrunning long enough to queue a follow-up and send
/stop— that is the whole sequence this PR changes.*.real-gateway.e2e.test.tscan assert: first turn streaming -> secondchat.sendqueues ->/stop-> the queued message receives an assistant reply (base: user row only, no reply).The existing
ui/src/e2e/*.real-gateway.e2e.test.tssuites do not run a model (they append to the transcript directly), sothere is no fixture to copy for this yet.