Repository navigation
fix(auto-reply): keep native /new and /reset from preempting their own turn - #178649
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 preserves the current input’s identity during operation-free dispatch so native session resets do not cancel themselves. Example: An authorized user sends /new in Telegram group -1001234567890, topic 42.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenanceRegression provenance — suspected predecessor, not a causality claim: source commit Possible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR repairs a current dispatch ownership bug with a focused change; no actionable patch defects were found. Priority: P1 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe auto-reply dispatcher passes inbound commands through session initialization and command handling; the session controller coordinates cancellation, rollover, and ownership before acknowledgement delivery. flowchart TD
A[Native Telegram command] --> B[Inbound reply dispatch]
B --> C[Existing source context]
C --> D[Session rollover]
D --> E[Cancel competing work]
D --> F[Commit reset]
F --> G[Emit hook and acknowledgement]
Technical reviewBest possible solution: Bind operation-free dispatch to its existing source input while retaining the session controller’s cancellation and admission owners. Do we have a high-confidence way to reproduce the issue? Source tracing establishes the self-cancellation path: native commands skip operation acquisition, unbound dispatch starts rollover, and preemption selects its unclaimed input; the author reports red/green harness results, but no reproduction was run during this read-only review. Is this the best way to solve the issue? This is the smallest complete production repair: reuse the existing source-context helper at dispatch rather than weakening preemption or creating another ownership mechanism. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 1c4b27072712. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +4, Tests +160. Total +164 across 2 files. Added test files: 0. View PR surface stats
LabelsLabel 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 Reviewed October 20, 2026, 3:16 PM ET / 19:16 UTC. |
…n turn (openclaw#178649) Co-authored-by: VACInc <[email protected]>
What Problem This Solves
Fixes native
/newand/resetcancelling themselves in idle Telegram group topics, leaving the reset uncommitted and reset hooks silent.User Impact
Native topic resets can complete, acknowledge the command, and emit
command:new/command:resethooks. Other active runs are still preempted. No configuration or migration is required.Why This Change Was Made
Run dispatch work under its existing reply source when no reply operation exists, so rollover recognizes its own input without granting new execution authority. The existing operation-owned path is unchanged.
Evidence
/new, idle-topic/reset, and cancellation of a competing active run through the dispatch boundary. Exact-head CI passed all 22 trigger-handling tests and all 74 dispatch lifecycle tests. The author also reports all three new cases failing with the production fix reverted.4111b886507ed2fc17b82db25e89478ab2b699d9. Full diff and surrounding source review identified no hostile behavior.git diff --checkpassed. Exact-head CI passed, and the required CI/security gate is green.Original diagnosis and regression evidence
Summary
High Level TLDR
Since 2026.10.5, a native
/newor/resetsent in an idle Telegram group topic cancels itself. The rollover it starts preempts the turn that issued it, so the reset never commits,command:new/command:resetnever fire, and every reset hook (bundledsession-memory, workspace hooks) stays silent. This change runs that turn under its own reply source, so the rollover recognizes it as the owner and stops cancelling it. Other active runs are still preempted.Root Cause
/newin an idle group topic ends withvisible channel turn dispatched with no queued reply payloads ... cause=skipped:reply_operation_aborted, and the diagnostics timeline showsreply.init_session_statespan errors readingagent run aborted for restart. No[hooks/session-memory]save line follows. The last successful reset hook run on the affected install was immediately before upgrading to 2026.10.5.initSessionStateperforms the rollover throughrunReplySessionRolloverMutation, which usesrunSessionMutationwithpolicy: "preempt",activeRun: "abort",waitingInputs: "cancel". For an explicit reset there is norequiredSessionId, so preemption targets every active operation and waiting input on the session, including the current turn's own input. When the turn has neither a dispatch reply operation nor a claim (the idle native-command path),createDispatchReplyOperationCoordinatorran it without any session-controller source, so nothing marks the input as the turn's own and the rollover cancels it.maybeHandleResetCommand(src/auto-reply/reply/commands-reset.ts) then never runs, soemitResetCommandHooks/triggerInternalHook(src/auto-reply/reply/commands-reset-hooks.ts) never emit.session-memoryhook still subscribes tocommand:new/command:reset.Fix
src/auto-reply/reply/dispatch-from-config.lifecycle.ts: when no dispatch reply operation exists, run the work insidewithSessionControllerSource(input, run)so the reset's preemption identifies the turn's own input and skips it. Behavior when a reply operation exists is unchanged.Real behavior proof
Regression tests in
src/auto-reply/reply.triggers.trigger-handling.e2e.test.ts:commits native /new in an idle group topic and fires its command hookcommits native /reset in an idle group topic and fires its command hookstill preempts another active run when native /new resets its topicBefore (fix reverted):
After (fix applied):
✓ src/auto-reply/reply.triggers.trigger-handling.e2e.test.ts (22 tests), all passing.What was not tested
Verification
node scripts/test-projects.mts src/auto-reply/reply.triggers.trigger-handling.e2e.test.ts(red without the fix, green with it)