Repository navigation
fix(chat): keep cancelled responses from ending newer turns - #1440
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: blocked before merge. Reviewed September 30, 2026, 3:36 PM ET / 19:36 UTC (Revision 6). ClawSweeper reviewWhat this changesThe branch carries Gateway response run IDs into native chat, fences late output and completion notifications from older turns, and adds regression tests and routing documentation. Merge readiness⛔ Blocked before merge - 2 items remain Keep open. Current main does not solve the cancelled-response problem, and the prior exact-head human-test requirement remains unmet despite extensive compiled coverage. Priority: P2 Review scores
Verification
How this fits togetherWindows Companion receives chat and agent events from a paired Gateway. Its chat state decides which response owns each event before updating the conversation and allowing completion notifications that can reach toast and speech. flowchart LR
A[Gateway chat events] --> B[Event parser]
B --> C[Session and run identity]
C --> D[Chat admission decision]
D --> E[Conversation timeline]
D --> F[Completion notifications]
Before merge
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep run ownership in the existing chat state boundary, preserve no-run-ID compatibility and known late tool repair, and verify the resulting timeline and notification behavior in the native product path. Do we have a high-confidence way to reproduce the issue? Yes, at source level: current main omits payload run identity from incoming chat admission, and the submitted old-run/new-run regression sequence targets that path. This read-only review did not execute a live reproduction. Is this the best way to solve the issue? Yes, the branch uses the existing conversation and lifecycle owners and retains legacy no-ID handling. Native Gateway and WinUI evidence is still needed to establish merge readiness. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 04a880fe9488. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
|
Global repo triage reviewed exact head Decision: NEEDS_HUMAN_TEST. Take confidence: 82%. Recommendation confidence: 98%. Risk: High. Independent source review found no blocking defect. Chat state/provider ownership matches Complete |
|
This pull request has been automatically marked as stale due to inactivity. |
After Stop completed, a cancelled run's late chat frames could still render into the next turn, end it, and fire a completion toast/TTS, because chat frames carried no run identity and the aborted-run state was cleared when the cancelled run's terminal arrived. - Parse the chat payload runId into ChatMessageInfo.RunId. - Fence assistant/tool chat frames from runs cancelled by Stop or session reset, before and after their terminal, via a bounded (64) retired set in ChatLifecycleState. Drop agent events of retired runs and replayed starts of aborted runs. Rolled-back aborts are not retired. - Add a per-frame SuppressNotification() veto so rejected frames do not reach notification history, toasts or TTS. Duplicate-frame dedupe and throwing consumers keep the existing notification behavior. - Frames without a runId keep legacy thread-level handling. Runs that completed normally are not fenced. Co-authored-by: Copilot App <[email protected]>
896d323 to
69cee2b
Compare
Global repo triage adversarial reviewDecision: Both independent reviewers completed against exact head
Required next action: repair failed-abort retirement without clearing an independent reset fence; allow matched terminal approval cleanup without admitting new requests or output; add ordering coverage; rerun exact-head validation; then provide No code changes or remote branch updates were made by this review. |
…cellation Address triage review on 69cee2b: - If a cancelled run's terminal arrives before the abort RPC fails, the rollback now releases the abort retirement so the uncancelled run's trailing final and notification are admitted again. Retirement reasons are tracked separately, so a failed abort cannot clear an independent reset fence. - A retired run may still deliver the terminal approval event (resolved, expired, etc.) that matches the currently pending permission, so the obsolete permission banner is cleared. New approval requests and output from the retired run stay blocked. Co-authored-by: Copilot App <[email protected]>
|
Thanks for the review. I've addressed both findings in
With either fix reverted, 4 of these tests fail and the controls pass. Validation on
The |
Keep restored older-run finals separate from active streaming turns and reject terminal-run replay. Add deferred-abort regressions and five isolated native cancellation scenarios. Co-authored-by: Copilot App <[email protected]> Copilot-Session: af5ac91e-d8cc-4635-82b8-9db6695a73ee
Preserve held chat-abort responses alongside interactive fixture acknowledgements, and keep interactive/cron scenario identities with chat-send version 2. Co-authored-by: Copilot App <[email protected]> Copilot-Session: af5ac91e-d8cc-4635-82b8-9db6695a73ee
Exact-head adversarial reviewPR #1440 (fix(chat): keep cancelled responses from ending newer turns). Decision: HOLD_FOR_AUTHOR. Take confidence: 70%. Recommendation confidence: 98%. Head: Both independent background HIGH consensus: independent overlap
The new background event inserts A before B. The metadata merge then updates the last assistant, B. The renderer consumes that media. Coordinator reproduction assigned A's image to both rows; the no-streaming-B control stayed correct. Narrowed to admitted finals, such as after failed-abort cleanup, not successfully cancelled A still fenced. Coordinator rates this MEDIUM and requests repair despite the models' blocking-status disagreement. Assign background metadata only to A and cover independent media on B. LOW consensus: one reviewer
The expanded agent gate rejects terminal A's tool completion even though existing coverage establishes late correlated recovery. Coordinator verified the rejection predicate and recovery-if-admitted with B still active. Permit only retained, identity-matched terminal tool updates for non-cancelled runs, not arbitrary old output. The background reducer always inserts. With B active and no message identity, the actual classifier returned Render twice and produced two A rows. Preserve retransmission dedupe without collapsing distinct equal-text messages. Both single-reviewer MEDIUM findings are conditionally verified source defects; real-Gateway frequency is unmeasured. Disputed and resolved itemsThe deferred terminal-before-abort-failure defect is fixed, including preservation of B and independent Reset fences. Direct rollback and matched terminal approval cleanup remain repaired. The approval exemption exists in the agent gate, not the non-final chat gate as one reviewer stated. The notification-policy concern is not a separate blocker. Do not restore ordinary completion during B's pre-start gap, which could end B. The prior already-discarded-final replay question remains disputed and non-blocking, not new independent overlap. Direct abort failure does publish an error, so the broader no-notification claim is narrowed. Validation and remaining proofCI run 39007373133 succeeded. CI commit
Repair the three MEDIUM issues, add the missing cross-run regressions, rerun exact-head validation, then supply both native proof pools. This review made no source or GitHub changes. |
Keep background media entry-scoped, repair only retained terminal tool outcomes, and deduplicate identityless background finals by run and content. Preserve upstream fixture gates and add transport, provider, and native regression coverage. Co-authored-by: Copilot App <[email protected]> Copilot-Session: af5ac91e-d8cc-4635-82b8-9db6695a73ee
karkarl
left a comment
There was a problem hiding this comment.
Approve at c6960a8. Take confidence: 90%.
The three verified cross-run defects are repaired: background-final media stays with its own entry, retained late tool outcomes repair only the matching older run, and identityless background-final retransmissions do not duplicate rows or disturb the newer turn. Independent P0-P3 review found no significant remaining issues.
Validation: full repository build passed; Shared tests 4,501 passed with 35 existing opt-in skips; Tray tests 4,341 passed without skips; all six isolated native UI cases passed. Inspected native captures show separate media, correct tool ownership, and continued newer-turn streaming. Owned runtime cleanup was independently verified.
Build and Test: https://github.com/openclaw/openclaw-windows-node/actions/runs/39453789707 (passed).
CodeQL: https://github.com/openclaw/openclaw-windows-node/actions/runs/39453789785 (passed).
Native proof used the real Companion with a synthetic loopback Gateway, not a live AI provider. The remaining uncertainty is production event ordering. The frozen binaries were built from the source tree later committed as c6960a8, with source/patch equality verified; assembly metadata retains the precommit revision da0f980.
Main has advanced and merge conflicts remain at submission time. This approval records the verified head above, not a claim that the subsequent conflict resolution is already validated.
Preserve cancellation fixture versioning alongside fractional voice history and session creation scenarios. Co-authored-by: Copilot App <[email protected]> Copilot-Session: af5ac91e-d8cc-4635-82b8-9db6695a73ee
karkarl
left a comment
There was a problem hiding this comment.
90% take confidence at 0222c798. Recommendation: take.
The merge conflicts are resolved, the PR is clean and mergeable, and there is no new blocking code finding. The conflict resolution preserves the cancellation fixture behavior alongside the incoming fractional-voice history and session-creation behavior.
Current-head hosted evidence:
- Build and Test and CodeQL passed, including CI Gate and all selected E2E lanes.
- The actual reports show 4,652 Shared tests passed with 8 skips, and 4,444 Tray tests passed with no skips.
- All 17 selected chat/voice regression cases passed.
Remaining proof gap: the required local rerun and seven-case native replay on this merged head are still pending, blocked by the shared test-controller issue and execution hold. The earlier six-case native pass was on pre-merge c6960a87 and exercised real Companion against a synthetic loopback Gateway, not live production Gateway/provider ordering. The selected native replay methods were skipped in hosted CI.
This approval is a positive code verdict, not a claim that the pending local/native proof closeout has completed. I would retain 90% confidence rather than raise it solely because hosted CI is green.
What Problem This Solves
Fixes: after you stop a response and send a new message, late text from the stopped response can show up in the new turn, end it early, and fire a "response complete" toast or TTS.
User Impact
User impact: stopping a response (or resetting the session) now reliably silences it. Its late text, completion, and notification can no longer interfere with the next response. Responses that finish normally, other sessions, and older gateways that omit
runIdbehave as before.Why This Change Was Made
Agent events were already suppressed by aborted run ID, but chat frames carried no run identity, and the aborted-run state was cleared as soon as the cancelled run's terminal arrived. So once Stop finished, nothing stopped that run's late
chat/session.messagefinal.This change:
runIdonChatMessageInfo.ChatLifecycleState. Agent events of those retired runs and a replayed start of an aborted run are dropped. A rolled-back abort is not retired.SuppressNotification()veto so rejected frames never reach notification history, toasts, or TTS. Duplicate-frame dedupe and a throwing chat consumer keep the existing notification behavior.Ownership is unchanged:
ChatConversationStatecoordinates under its lock,ChatLifecycleStateowns abort and retirement state,ChatResetStateowns reset admission, and the provider stays the IO/event facade. Notification ownership does not move intoApp.Scope was deliberately reduced in this revision. The earlier version also fenced completed and mismatched runs, which required same-run retry exceptions and late tool-repair exceptions. Review found that it also dropped legitimate finals that upstream sends after lifecycle end (reply-dispatch and ACP runs) once the tray's queued-send drain started the next turn. Fencing only cancelled runs fixes the reported bug without those special cases. Runs that complete normally are not fenced.
Evidence
openclaw/openclaw@eb82ef8bsrc/gateway/server-chat.ts):runId = chatLink.clientRunId, the same ID used bychatevents, so run correlation is consistent.endagent event is broadcast beforefinalizeLifecycleEventemits the chat final.ChatConversationStatereverted tomain, 13 of the new cancellation tests fail; with the change they pass. These are the provider-level stop → resend → late stale final/delta/terminal sequences, the parser-to-provider notification veto, reset fencing, and the aborted-start replay guard.Change Type
Scope
winnodeRequired proof pools
windows-winui-interactive: stop response A, send B, let A's late events arrive, and visibly confirm B stays active, ends only on its own final, and only B produces a toast/TTS.windows-wsl-gateway-e2e: the same sequence through a paired product Gateway, to confirm real wirerunIddelivery and ordering.Validation
Head
69cee2b4(basemainat9e4999c6), native Windows. Every process hadOPENCLAW_REPO_ROOTplus isolatedOPENCLAW_TRAY_DATA_DIR,OPENCLAW_TRAY_APPDATA_DIR, andOPENCLAW_TRAY_LOCALAPPDATA_DIRset before start. Metadata manifests of the real%APPDATA%\OpenClawTrayand%LOCALAPPDATA%\OpenClawTraywere identical before and after..\build.ps1dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restoredotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore--filterChatRunCorrelation, OpenClawChatDataProvider, ChatConversationState, ChatEventMapper, ChatTimelineReducer, ChatRuntimeOwnershipContractmainhas since moved 6 commits (setup and wizard-log changes). None touch files in this PR.Real Behavior Proof
69cee2b4.ChatMessageReceived_CancelledRunLateFinal_CannotEndANewerActiveRunandChatMessageReceived_RejectedWireFinalCannotEmitNotification. These send A, stop A, send and start B, inject A's late delta, final and terminal (before and after A's cleanup), then finish B. The second test drives rawchatandsession.messageJSON throughOpenClawGatewayClientinto the provider.main's gate.N/ASecurity Impact
Yes/No)NoYes/No)NoYes/No)NoYes/No)NoYes/No)NoYes, explain the risk and mitigation: N/ACompatibility and Migration
Yes/No)Yes. Frames withoutrunIdkeep the existing thread-level handling.Yes/No)NoYes/No)NoReview Conversations
There are no inline review threads.