Repository navigation
fix(advisor): cancel stale guidance after abort or new turn - #173459
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: needs maintainer review before merge. What this changesThis PR cancels stale Advisor reviews after aborts or replacement user turns and suppresses fallback guidance for duplicate steering outcomes. Example: Advisor is reviewing run-1 when the user aborts it.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: the feature owner repairs current Advisor lifecycle defects that remain on main, and no concrete introduced bug was found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherAdvisor consumes admitted user-run lifecycle and tool events, reviews and verifies session context through service-owned forks, and sends approved guidance through existing session workflow APIs. flowchart TD
A[User run events] --> B[Advisor subscription]
B --> C[Session controller]
C --> D[Review and verification forks]
D --> E[Active run steering]
E --> F[Next turn fallback]
B --> G[Abort or replacement turn]
G --> C
Technical reviewBest possible solution: Keep cancellation in the Advisor controller while preserving ordinary completion fallback and the existing session workflow delivery owner. Do we have a high-confidence way to reproduce the issue? Current-main source exposes both cancellation omissions, and the body reports failing baseline assertions for those paths; no target code was executed during this read-only review. Is this the best way to solve the issue? The patch fixes the owning lifecycle transitions, reuses existing abort propagation, and treats duplicate steering as terminal without adding configuration or competing state. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 26da73bf2aa8. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +18, Tests +55, Docs +2. Total +75 across 4 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed October 15, 2026, 5:09 PM ET / 21:09 UTC (Revision 2). |
|
@clawsweeper review |
|
🦞👀 Re-review progress:
|
## What Problem This Solves Fixes repeated plugin steering reaching the model twice, and rejected native guidance being retained as if it had been delivered. ## User Impact Plugins can retry steering without injecting the same guidance twice, including after a successor run starts. A native steer rejected before dispatch leaves no guidance in subsequent model context and can be retried after plugin reload. No configuration, schema, or stored-row shape change is required. ## Why This Change Was Made Transcript idempotency alone did not protect the active-run input queue. The existing run registration now joins pending/accepted admissions after authority validation, and the plugin host checks the durable session/key owner before dispatch. Stored steering receipts replay the original run ID, matching `src/gateway/server-methods/inflight.ts:38-51`; older rows without a receipt return terminal `duplicate`. Rejected queue reservations are released. Codex previously appended internal guidance before the final physical-send authority check. It now retains preceding tool-result mirroring and inbound user persistence, but appends internal plugin guidance only after native acceptance or accepted-unconfirmed delivery. Accepted history can still be recorded if the plugin is subsequently disposed; session/storage identity guards remain. This prevents rejected guidance from poisoning both replay and same-key retry without adding stored fields. The independent fork snapshot repair moved to #173489. Advisor cancellation and duplicate-fallback handling are in #173459. ## Evidence - Baseline `5678421c757`: sequential/concurrent duplicate-key regressions persisted one row but admitted two model-input messages. - Successor-run regression: before the durable check, the same key was accepted by a later run rather than deduplicated. - Native regression: before the producer fix, pre-wire disposal left a hidden transcript row, included it in `SessionManager` model context, and caused a reloaded plugin's retry to return `duplicate`. Afterward, rejected guidance is absent from both transcript and context; retry reaches native `turn/steer` once. Accepted-then-disposed guidance still persists once. - Focused steering, native admission/authority/settlement, recorder, and recorder-persistence tests passed. Changed-file oxfmt/oxlint, scoped tsgo, Madge (0 cycles), and diff checks passed. - The pre-review-fix combined raw-evidence campaign tested integration `04a5747760d1e9655b73fac511ddb81fad7a3c97`: **80 PASS / 5 FAIL → 86 PASS / 0 FAIL / 0 UNPROVED**. Shared case/invariant pairs: **59 PASS / 5 FAIL → 64 PASS / 0 FAIL**. Totals include added successor/channel coverage rather than an identical inventory. - That campaign proves same-run and successor-run idempotency, abort/overlap handling, display isolation, and built-in/native minutes verification. The later rejected-guidance producer fix is separately covered by the focused native regression above, not claimed as part of that campaign. - Focused native follow-up tested `0903019c1131cfa29a81b4e192c3353fb65a3def` (integration `998ff42a15f` plus the display fix): **36 PASS / 0 FAIL / 0 UNPROVED**. Live Codex tool-call, minutes, abort, overlap, and same-key within/across runs passed; every accepted steer row preceded its first provider request. A controlled native-transport probe separately proved pre-wire rejection leaves no row or wire request, then same-key retry delivers exactly once. The controlled rejection probe is not claimed as live-daemon fault injection. Co-authored-by: Ayaan Zaidi <[email protected]>
|
Landed as 330c27e. Advisor cancels an in-flight review when its run is aborted and when a new user turn replaces the run, and treats a duplicate steer as terminal, so no stale or duplicate correction is delivered. Proof: abort/overlap/duplicate regressions failing before; raw-evidence campaign 86/0; exact-head CI green. |
…aw#173458) ## What Problem This Solves Fixes repeated plugin steering reaching the model twice, and rejected native guidance being retained as if it had been delivered. ## User Impact Plugins can retry steering without injecting the same guidance twice, including after a successor run starts. A native steer rejected before dispatch leaves no guidance in subsequent model context and can be retried after plugin reload. No configuration, schema, or stored-row shape change is required. ## Why This Change Was Made Transcript idempotency alone did not protect the active-run input queue. The existing run registration now joins pending/accepted admissions after authority validation, and the plugin host checks the durable session/key owner before dispatch. Stored steering receipts replay the original run ID, matching `src/gateway/server-methods/inflight.ts:38-51`; older rows without a receipt return terminal `duplicate`. Rejected queue reservations are released. Codex previously appended internal guidance before the final physical-send authority check. It now retains preceding tool-result mirroring and inbound user persistence, but appends internal plugin guidance only after native acceptance or accepted-unconfirmed delivery. Accepted history can still be recorded if the plugin is subsequently disposed; session/storage identity guards remain. This prevents rejected guidance from poisoning both replay and same-key retry without adding stored fields. The independent fork snapshot repair moved to openclaw#173489. Advisor cancellation and duplicate-fallback handling are in openclaw#173459. ## Evidence - Baseline `4bf119f2359`: sequential/concurrent duplicate-key regressions persisted one row but admitted two model-input messages. - Successor-run regression: before the durable check, the same key was accepted by a later run rather than deduplicated. - Native regression: before the producer fix, pre-wire disposal left a hidden transcript row, included it in `SessionManager` model context, and caused a reloaded plugin's retry to return `duplicate`. Afterward, rejected guidance is absent from both transcript and context; retry reaches native `turn/steer` once. Accepted-then-disposed guidance still persists once. - Focused steering, native admission/authority/settlement, recorder, and recorder-persistence tests passed. Changed-file oxfmt/oxlint, scoped tsgo, Madge (0 cycles), and diff checks passed. - The pre-review-fix combined raw-evidence campaign tested integration `04a5747760d1e9655b73fac511ddb81fad7a3c97`: **80 PASS / 5 FAIL → 86 PASS / 0 FAIL / 0 UNPROVED**. Shared case/invariant pairs: **59 PASS / 5 FAIL → 64 PASS / 0 FAIL**. Totals include added successor/channel coverage rather than an identical inventory. - That campaign proves same-run and successor-run idempotency, abort/overlap handling, display isolation, and built-in/native minutes verification. The later rejected-guidance producer fix is separately covered by the focused native regression above, not claimed as part of that campaign. - Focused native follow-up tested `0903019c1131cfa29a81b4e192c3353fb65a3def` (integration `998ff42a15f` plus the display fix): **36 PASS / 0 FAIL / 0 UNPROVED**. Live Codex tool-call, minutes, abort, overlap, and same-key within/across runs passed; every accepted steer row preceded its first provider request. A controlled native-transport probe separately proved pre-wire rejection leaves no row or wire request, then same-key retry delivers exactly once. The controlled rejection probe is not claimed as live-daemon fault injection. Co-authored-by: Ayaan Zaidi <[email protected]>
…#173459) ## What Problem This Solves Fixes Advisor guidance arriving after an aborted run, or remaining queued from a stale review after a new user turn starts. ## User Impact Aborting work also cancels its in-flight Advisor review and verification. Starting a new user turn drops unfinished advice based on the preceding turn instead of delivering it later. A duplicate steering outcome never creates fallback guidance. Normal run-end fallback remains supported. ## Why This Change Was Made The lifecycle subscription treated aborted terminal events like ordinary completion, ignoring their `aborted` flag. The controller also retained in-flight reviews when a new user run replaced the previous one. These transitions now cancel the stale review at the owning controller, preventing both active delivery and fallback queueing. Duplicate keys are terminal no-ops rather than unavailable steering, so the fallback path now leaves them alone. ## Evidence - Reproduced on `4bf119f2359`: aborted `end` and `error` events left the review signal active; regression assertions failed with `expected false to be true`. - Reproduced active delivery followed by another pending review spanning a new user turn; its cancellation assertion failed on the baseline. - A duplicate-result regression also demonstrated an unwanted fallback queue entry before its repair. - All 51 Advisor tests passed, including cancellation, duplicate handling, normal run-end fallback, tool settlement, verification, and interval accounting. Combined owner checks covered 127 distinct tests; changed-file oxfmt/oxlint, scoped tsgo, Madge (0 cycles), and diff checks passed. - Final raw-evidence campaign combined this head `1fac8ffa671`, core head `5677912be70` (openclaw#173458), and display fix `07c940c6959` (openclaw#173460); tested integration `04a5747760d1e9655b73fac511ddb81fad7a3c97`. - Executable invariants: **before 80 PASS / 5 FAIL; after 86 PASS / 0 FAIL / 0 UNPROVED**. Shared case/invariant pairs improved **59 PASS / 5 FAIL → 64 PASS / 0 FAIL**; totals include different commissioning/channel coverage and the new successor-run case. - The accepted abort left zero queued notes. The overlapping user turn retained one active correction and zero queued copies. Built-in minutes review completed verification and delivered once. Provider requests, SQLite rows, and events independently establish these outcomes. - A/B behavior stayed unchanged: Advisor-on 4 tool calls / 2 repeated actions, solved; off 8 / 7, unresolved. Actual Codex tool/minutes and late-snapshot Telegram persistence/display/recipient checks passed. No active-session compaction occurred; that RPC remained refused. - The fork slice from the tested core revision is now isolated in openclaw#173489; openclaw#173458 retains steering deduplication and the later native rejected-guidance producer repair. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
Fixes Advisor guidance arriving after an aborted run, or remaining queued from a stale review after a new user turn starts.
User Impact
Aborting work also cancels its in-flight Advisor review and verification. Starting a new user turn drops unfinished advice based on the preceding turn instead of delivering it later. A duplicate steering outcome never creates fallback guidance. Normal run-end fallback remains supported.
Why This Change Was Made
The lifecycle subscription treated aborted terminal events like ordinary completion, ignoring their
abortedflag. The controller also retained in-flight reviews when a new user run replaced the previous one. These transitions now cancel the stale review at the owning controller, preventing both active delivery and fallback queueing.Duplicate keys are terminal no-ops rather than unavailable steering, so the fallback path now leaves them alone.
Evidence
5678421c757: abortedendanderrorevents left the review signal active; regression assertions failed withexpected false to be true.1fac8ffa671, core head5677912be70(fix: deduplicate steering without replaying rejected guidance #173458), and display fix07c940c6959(fix(gateway): keep private model prompt projections out of display output #173460); tested integration04a5747760d1e9655b73fac511ddb81fad7a3c97.