Skip to content

fix(auto-reply): keep native /new and /reset from preempting their own turn - #178649

Merged
VACInc merged 1 commit into
openclaw:mainfrom
VACInc:fix/reset-command-self-preempt
Oct 20, 2026
Merged

VACInc merged 1 commit into
openclaw:mainfrom
VACInc:fix/reset-command-self-preempt

Conversation

@VACInc

@VACInc VACInc commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes native /new and /reset cancelling 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:reset hooks. 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

  • Three regression cases cover idle-topic /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.
  • Independent P0–P3 Auto Review completed with no actionable findings for 4111b886507ed2fc17b82db25e89478ab2b699d9. Full diff and surrounding source review identified no hostile behavior.
  • git diff --check passed. Exact-head CI passed, and the required CI/security gate is green.
  • No live Gateway/Telegram test was performed. Results above were verified from CI job logs, not a separate local rerun. The trigger-handling file took 92.85 seconds in CI (95.83 seconds including wrapper verification); full dispatch/rollover composition is needed to catch self-preemption that the fast bootstrap skips. ClawSweeper has acknowledged the PR but has not posted its review; that remains pending.
  • This pass does not authorize or perform a merge.
Original diagnosis and regression evidence

Summary

High Level TLDR

Since 2026.10.5, a native /new or /reset sent 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:reset never fire, and every reset hook (bundled session-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

  • Before: a native /new in an idle group topic ends with visible channel turn dispatched with no queued reply payloads ... cause=skipped:reply_operation_aborted, and the diagnostics timeline shows reply.init_session_state span errors reading agent 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.
  • Mechanism: initSessionState performs the rollover through runReplySessionRolloverMutation, which uses runSessionMutation with policy: "preempt", activeRun: "abort", waitingInputs: "cancel". For an explicit reset there is no requiredSessionId, 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), createDispatchReplyOperationCoordinator ran 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, so emitResetCommandHooks / triggerInternalHook (src/auto-reply/reply/commands-reset-hooks.ts) never emit.
  • This is an unintended regression: the shipped bundled session-memory hook still subscribes to command:new / command:reset.

Fix

src/auto-reply/reply/dispatch-from-config.lifecycle.ts: when no dispatch reply operation exists, run the work inside withSessionControllerSource(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 hook
  • commits native /reset in an idle group topic and fires its command hook
  • still preempts another active run when native /new resets its topic

Before (fix reverted):

 × commits native /new in an idle group topic and fires its command hook
   → expected { queuedFinal: false, …(2) } to match object { queuedFinal: true }
 × commits native /reset in an idle group topic and fires its command hook
   → expected { queuedFinal: false, …(2) } to match object { queuedFinal: true }
 × still preempts another active run when native /new resets its topic
   → expected [] to deeply equal [ ObjectContaining{…} ]

After (fix applied): ✓ src/auto-reply/reply.triggers.trigger-handling.e2e.test.ts (22 tests), all passing.

What was not tested

  • Not exercised against a live Gateway or real Telegram bot; proof is the e2e trigger-handling harness.
  • No before/after performance benchmark was recorded. The change wraps one async call in an existing context helper on the reset/no-operation path only.

Verification

  • node scripts/test-projects.mts src/auto-reply/reply.triggers.trigger-handling.e2e.test.ts (red without the fix, green with it)

@clawsweeper

clawsweeper Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 20, 2026
@clawsweeper

clawsweeper Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This 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.

  • Before: Rollover cancels the command’s own input before committing the reset or emitting command:new.
  • After: The reset commits, emits command:new, and replies “✅ New session started.” while competing work remains subject to cancellation.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, useful repair with meaningful dispatch integration coverage and successful exact-head gates; behavioral evidence remains limited to an in-process harness.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; supplied validation exercises real dispatch and rollover with mocked provider execution, and explicitly claims no live Gateway or Telegram proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Native /new and /reset commands in idle Telegram group topics can produce no acknowledgement, leave the reset uncommitted, and suppress reset hooks.
Reason: The maintainer-authored direction restores documented reset behavior through an existing owner without adding configuration, APIs, or persisted formats.

Regression provenance

Regression provenance — suspected predecessor, not a causality claim: source commit 668e5e8096ad by Peter Steinberger; no PR verified.

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
Reviewed head: 4111b886507ed2fc17b82db25e89478ab2b699d9

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: A live native Telegram topic reset, acknowledgement, and hook emission were not exercised; the body explicitly limits its evidence to the dispatch harness.
Agent review details

How this fits together

The 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]
Loading

Technical review

Best 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

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Focused introduced change: The pinned introduction adds the existing source-context wrapper only to dispatch without an operation; operation-owned dispatch retains its existing admission path. (src/auto-reply/reply/dispatch-from-config.lifecycle.ts:176, 4111b886507e)
  • Current-main defect remains: Fetched main still runs operation-free dispatch without binding the input as the current source. (src/auto-reply/reply/dispatch-from-config.lifecycle.ts:179, 1c4b27072712)
  • Cancellation and authority boundary: The existing helper sets source identity while preserving operation, claim, effect, and mutation context; rollover excludes the current input through isCurrentSessionControllerTurnInput without granting execution authority. (src/sessions/session-controller.context.ts:78, 4111b886507e)
  • Distinct regression coverage: The additions exercise both command aliases through full dispatch and rollover, asserting acknowledgement, hook emission, and a changed lifecycle revision; a separate case verifies cancellation of another active producer. (src/auto-reply/reply.triggers.trigger-handling.e2e.test.ts:568, 4111b886507e)
  • Verified CI status: The exact-head CI run completed successfully, and commit statuses report successful CI, dependency-review, and security-sensitive-review gates. Job-log download was blocked by the proxy’s Azure-host restriction, so individual test totals were not independently verified. (4111b886507e)
  • Discussion and proof scope: The full PR body explicitly reports harness-only validation and no live Gateway or Telegram run; both discussion comments contain review-status updates rather than additional behavioral evidence.

Likely related people:

  • Josh Avant: Raw commit aeba204 adds src/auto-reply/reply/dispatch-from-config.lifecycle.ts:645 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: aeba20460e36; files: src/auto-reply/reply/dispatch-from-config.lifecycle.ts)

PR surface

Source +4, Tests +160. Total +164 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 7 3 +4
Tests 1 160 0 +160
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 167 3 +164

Labels

Label changes:

  • add P1: Native Telegram topic resets can silently cancel themselves, breaking session reset acknowledgements and reset hooks in an active channel workflow.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P1: Native Telegram topic resets can silently cancel themselves, breaking session reset acknowledgements and reset hooks in an active channel workflow.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 20, 2026, 3:16 PM ET / 19:16 UTC.

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

Labels

P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant