Repository navigation
fix: keep automations running when you open another chat - #200314
Merged
Merged
Conversation
OpenClaw-Publication: 32b47532-55cb-833e-81ae-998326d7f0bf
Contributor
|
🦞👀 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. |
Co-authored-by: hannesrudolph <[email protected]>
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Nov 17, 2026
…0314) Co-authored-by: roboclaw-bot <[email protected]>
obviyus
added a commit
that referenced
this pull request
Nov 17, 2026
…0396) ## Problem Automations created from a chat stop, and recurring watchers are disabled, when that chat changes while the automation runs. - A running automation restores its creator's authority through `restoreGatewayOperatorSource`. Its session-identity subscriber revoked that authority on any identity mutation that named the chat's key: a message edit (`sessions.rewind`), a reset, a compaction successor or a key move. Before #200314, creating any unrelated chat for the same agent also matched (`undefined === undefined`, #200307). - A revoked condition or script ends as code `aborted`. `classifyCronScriptFailure` mapped `aborted` to `permanent`, and `applyJobResult` disables an `operatorSource` job on its first `permanent` error. One interrupted check therefore turned a recurring watcher off for good. #180891 intended the opposite: "Aborts (restarts, cancellation) are rethrown unchanged and stay retryable." - Failure-repair turns compared the restored target's transcript id with the source's. Since #199512, key-linked sources no longer record that id, so the comparison was always unequal and every repair turn was silently downgraded to a non-owner. Observed in production: a watcher was disabled twice in one day. Each time its condition aborted ~3.4 s in, ~0.1 s after another job started an isolated run (a new session). ## Fix - `restoreGatewayOperatorSource` revokes only when the target chat is deleted (`kind === "delete"` for the target key). Edits, branch switches, resets and compaction keep the chat's authority; device, token, role, profile and grant revocation still end it through their existing subscriptions. The target type drops `sessionId`; the cron callers stop passing it. - `classifyCronScriptFailure` maps `aborted` to `{ kind: "aborted" }`. The scheduler already treats that as an interrupted attempt: it does not count toward the failure streak and the next occurrence runs. Real script failures stay `permanent`. If the creator's authority was genuinely revoked, the next occurrence's source restore refuses it and that refusal still retires the job. - `captureCronJobTurnTarget` drops the transcript-id comparison and links the repair turn to its chat by key. Not changed here: sandboxed stream automations pin the exact transcript in `cron-stream-sandbox-authority.ts` (follow-up). Plugin session work (`service-session-work.ts`) shares the subscriber but keeps its own transcript/lifecycle check at each use. Production code: +13 / −20. ## User impact - Editing a message, switching branches, resetting a chat or compacting it no longer stops the automations it created. - A watcher whose condition is interrupted runs again at its next occurrence instead of being disabled. - Deleting the chat still stops its running automations. - Already-disabled jobs are not re-enabled; run `openclaw automations enable <id>`. ## Evidence - Regression tests, red on the merge base `b4fc0534`, green on this head: - `operator-run-recovery.test.ts`: key-linked authority stays current across an unrelated chat, a new transcript id and a reset, and is revoked when the chat is deleted (base: revoked at the edit). - `timer-outcomes.regression.test.ts`: a key-linked watcher whose condition ends `aborted` stays enabled and scheduled; `internal_error` still disables it (base: `aborted` disabled it). - Touched and consumer suites pass on this head (`ocx test`): operator recovery, operator cancellation, cron operator source, repair notifications, isolated operator continuation/child/bind-parent, trigger evaluation, failure alerts, failure text, server-cron, outcome regressions. `operator-run-cancellation.test.ts` now cleans up the sender's run session with the real delete (`run-continuation-cleanup.ts` deletes it) instead of a transcript-id replacement. - `config/session-identity-allowlist.txt` shrinks 6584 → 6580 pins: `cron-job-turn-target.ts` no longer compares an identity, and `operator-run-recovery.ts` drops two comparisons. - Real Gateway from source (`ocx src`, isolated state, `openai/gpt-5.6-luna`), base vs head. The agent creates a 30 s condition watcher (`sleep 20` in the condition) from its own chat; the harness waits until a condition is `running`, then mutates the owner chat: | Event while a condition is running | Base `b4fc0534` | Head | |---|---|---| | Message edit (`sessions.rewind` + resend) | condition `aborted`; watcher disabled after 1 evaluation | condition completes (×3) | | Reset (`sessions.reset`) | not reached (already disabled) | condition completes | | Another chat created | not reached | condition completes | | Final job state | `enabled=0`, `cron trigger evaluation failed (aborted)` | `enabled=1`, 0 errors, 6 evaluations | A second, unsynchronized base run reproduced the same disable at the first edit that landed during a condition (abort in the same second as the edit). Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Nov 18, 2026
…nclaw#200396) ## Problem Automations created from a chat stop, and recurring watchers are disabled, when that chat changes while the automation runs. - A running automation restores its creator's authority through `restoreGatewayOperatorSource`. Its session-identity subscriber revoked that authority on any identity mutation that named the chat's key: a message edit (`sessions.rewind`), a reset, a compaction successor or a key move. Before openclaw#200314, creating any unrelated chat for the same agent also matched (`undefined === undefined`, openclaw#200307). - A revoked condition or script ends as code `aborted`. `classifyCronScriptFailure` mapped `aborted` to `permanent`, and `applyJobResult` disables an `operatorSource` job on its first `permanent` error. One interrupted check therefore turned a recurring watcher off for good. openclaw#180891 intended the opposite: "Aborts (restarts, cancellation) are rethrown unchanged and stay retryable." - Failure-repair turns compared the restored target's transcript id with the source's. Since openclaw#199512, key-linked sources no longer record that id, so the comparison was always unequal and every repair turn was silently downgraded to a non-owner. Observed in production: a watcher was disabled twice in one day. Each time its condition aborted ~3.4 s in, ~0.1 s after another job started an isolated run (a new session). ## Fix - `restoreGatewayOperatorSource` revokes only when the target chat is deleted (`kind === "delete"` for the target key). Edits, branch switches, resets and compaction keep the chat's authority; device, token, role, profile and grant revocation still end it through their existing subscriptions. The target type drops `sessionId`; the cron callers stop passing it. - `classifyCronScriptFailure` maps `aborted` to `{ kind: "aborted" }`. The scheduler already treats that as an interrupted attempt: it does not count toward the failure streak and the next occurrence runs. Real script failures stay `permanent`. If the creator's authority was genuinely revoked, the next occurrence's source restore refuses it and that refusal still retires the job. - `captureCronJobTurnTarget` drops the transcript-id comparison and links the repair turn to its chat by key. Not changed here: sandboxed stream automations pin the exact transcript in `cron-stream-sandbox-authority.ts` (follow-up). Plugin session work (`service-session-work.ts`) shares the subscriber but keeps its own transcript/lifecycle check at each use. Production code: +13 / −20. ## User impact - Editing a message, switching branches, resetting a chat or compacting it no longer stops the automations it created. - A watcher whose condition is interrupted runs again at its next occurrence instead of being disabled. - Deleting the chat still stops its running automations. - Already-disabled jobs are not re-enabled; run `openclaw automations enable <id>`. ## Evidence - Regression tests, red on the merge base `a0d35bd4`, green on this head: - `operator-run-recovery.test.ts`: key-linked authority stays current across an unrelated chat, a new transcript id and a reset, and is revoked when the chat is deleted (base: revoked at the edit). - `timer-outcomes.regression.test.ts`: a key-linked watcher whose condition ends `aborted` stays enabled and scheduled; `internal_error` still disables it (base: `aborted` disabled it). - Touched and consumer suites pass on this head (`ocx test`): operator recovery, operator cancellation, cron operator source, repair notifications, isolated operator continuation/child/bind-parent, trigger evaluation, failure alerts, failure text, server-cron, outcome regressions. `operator-run-cancellation.test.ts` now cleans up the sender's run session with the real delete (`run-continuation-cleanup.ts` deletes it) instead of a transcript-id replacement. - `config/session-identity-allowlist.txt` shrinks 6584 → 6580 pins: `cron-job-turn-target.ts` no longer compares an identity, and `operator-run-recovery.ts` drops two comparisons. - Real Gateway from source (`ocx src`, isolated state, `openai/gpt-5.6-luna`), base vs head. The agent creates a 30 s condition watcher (`sleep 20` in the condition) from its own chat; the harness waits until a condition is `running`, then mutates the owner chat: | Event while a condition is running | Base `a0d35bd4` | Head | |---|---|---| | Message edit (`sessions.rewind` + resend) | condition `aborted`; watcher disabled after 1 evaluation | condition completes (×3) | | Reset (`sessions.reset`) | not reached (already disabled) | condition completes | | Another chat created | not reached | condition completes | | Final job state | `enabled=0`, `cron trigger evaluation failed (aborted)` | `enabled=1`, 0 errors, 6 evaluations | A second, unsynchronized base run reproduced the same disable at the first edit that landed during a condition (abort in the same second as the edit). Co-authored-by: Ayaan Zaidi <[email protected]>
RomneyDa
added a commit
that referenced
this pull request
Nov 19, 2026
Co-authored-by: roboclaw-bot <[email protected]> (cherry picked from commit 809b07c) Release adaptation: Direct required companion to ChatRef cutover; absent transcript IDs no longer revoke unrelated automation roots. Follow-up disposition: Presence-check ratchet and operator-source regression included; no broader authority policy change. Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 24fc3d405f99acb29c46d0cb4db947eadcb73d4a)
RomneyDa
added a commit
that referenced
this pull request
Nov 19, 2026
Release adaptation: Regenerate the shrink-only ratchet after composing #200328 with #200191 and #200314. Only the obsolete update-doctor-result allowance is removed. Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit cfcd57db7ed4758d2a6013f8f66fe1a84e13d015)
RomneyDa
pushed a commit
that referenced
this pull request
Nov 19, 2026
…0396) Automations created from a chat stop, and recurring watchers are disabled, when that chat changes while the automation runs. - A running automation restores its creator's authority through `restoreGatewayOperatorSource`. Its session-identity subscriber revoked that authority on any identity mutation that named the chat's key: a message edit (`sessions.rewind`), a reset, a compaction successor or a key move. Before #200314, creating any unrelated chat for the same agent also matched (`undefined === undefined`, #200307). - A revoked condition or script ends as code `aborted`. `classifyCronScriptFailure` mapped `aborted` to `permanent`, and `applyJobResult` disables an `operatorSource` job on its first `permanent` error. One interrupted check therefore turned a recurring watcher off for good. #180891 intended the opposite: "Aborts (restarts, cancellation) are rethrown unchanged and stay retryable." - Failure-repair turns compared the restored target's transcript id with the source's. Since #199512, key-linked sources no longer record that id, so the comparison was always unequal and every repair turn was silently downgraded to a non-owner. Observed in production: a watcher was disabled twice in one day. Each time its condition aborted ~3.4 s in, ~0.1 s after another job started an isolated run (a new session). - `restoreGatewayOperatorSource` revokes only when the target chat is deleted (`kind === "delete"` for the target key). Edits, branch switches, resets and compaction keep the chat's authority; device, token, role, profile and grant revocation still end it through their existing subscriptions. The target type drops `sessionId`; the cron callers stop passing it. - `classifyCronScriptFailure` maps `aborted` to `{ kind: "aborted" }`. The scheduler already treats that as an interrupted attempt: it does not count toward the failure streak and the next occurrence runs. Real script failures stay `permanent`. If the creator's authority was genuinely revoked, the next occurrence's source restore refuses it and that refusal still retires the job. - `captureCronJobTurnTarget` drops the transcript-id comparison and links the repair turn to its chat by key. Not changed here: sandboxed stream automations pin the exact transcript in `cron-stream-sandbox-authority.ts` (follow-up). Plugin session work (`service-session-work.ts`) shares the subscriber but keeps its own transcript/lifecycle check at each use. Production code: +13 / −20. - Editing a message, switching branches, resetting a chat or compacting it no longer stops the automations it created. - A watcher whose condition is interrupted runs again at its next occurrence instead of being disabled. - Deleting the chat still stops its running automations. - Already-disabled jobs are not re-enabled; run `openclaw automations enable <id>`. - Regression tests, red on the merge base `b4fc0534`, green on this head: - `operator-run-recovery.test.ts`: key-linked authority stays current across an unrelated chat, a new transcript id and a reset, and is revoked when the chat is deleted (base: revoked at the edit). - `timer-outcomes.regression.test.ts`: a key-linked watcher whose condition ends `aborted` stays enabled and scheduled; `internal_error` still disables it (base: `aborted` disabled it). - Touched and consumer suites pass on this head (`ocx test`): operator recovery, operator cancellation, cron operator source, repair notifications, isolated operator continuation/child/bind-parent, trigger evaluation, failure alerts, failure text, server-cron, outcome regressions. `operator-run-cancellation.test.ts` now cleans up the sender's run session with the real delete (`run-continuation-cleanup.ts` deletes it) instead of a transcript-id replacement. - `config/session-identity-allowlist.txt` shrinks 6584 → 6580 pins: `cron-job-turn-target.ts` no longer compares an identity, and `operator-run-recovery.ts` drops two comparisons. - Real Gateway from source (`ocx src`, isolated state, `openai/gpt-5.6-luna`), base vs head. The agent creates a 30 s condition watcher (`sleep 20` in the condition) from its own chat; the harness waits until a condition is `running`, then mutates the owner chat: | Event while a condition is running | Base `b4fc0534` | Head | |---|---|---| | Message edit (`sessions.rewind` + resend) | condition `aborted`; watcher disabled after 1 evaluation | condition completes (×3) | | Reset (`sessions.reset`) | not reached (already disabled) | condition completes | | Another chat created | not reached | condition completes | | Final job state | `enabled=0`, `cron trigger evaluation failed (aborted)` | `enabled=1`, 0 errors, 6 evaluations | A second, unsynchronized base run reproduced the same disable at the first edit that landed during a condition (abort in the same second as the edit). Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 346d231) Release adaptation: preserve retired session identity allowlist; apply deletion-only key guard to baseline subscriber and retain new regression. Co-authored-by: RomneyDa <[email protected]> Follow-up disposition: bounded pinned-main same-path audit recorded in the lane report; cross-lane changes remain parent-owned. (cherry picked from commit 75f490aee889734669c4d8d718e4cbec0934491f)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #200307
What Problem This Solves
Opening another chat while an automation is checking for updates can interrupt that check and turn the automation off. The CI checker also rejected the missing-ID safety check needed to repair this bug.
User Impact
Opening a separate chat no longer stops affected automations in this way. No settings changes are needed. Automations already switched off still need to be re-enabled.
The CI correction allows direct null/undefined presence checks while continuing to reject growth in real identity comparisons and explicit identity pins. No authorization rules, retry policy, or intended cancellation behavior are changed.
Why This Change Was Made
Two missing IDs were treated as a match, so creating an unrelated chat could cancel the automation. The existing guard prevents that false match. This PR now also corrects the CI checker: asking whether an ID exists is not the same as comparing it with another identity.
The allowlist is regenerated downward only, removing 318 false-positive counts across 205 entries. No allowance is increased, and the earlier session-continuity improvements are not reverted.
Evidence
check:session-identity-ratchetpasses locally against the PR base: 1,674 files, 6,587 grandfathered counts. All 205 changed allowlist entries strictly shrink.git diff --checkpassed.Exact-head GitHub CI is pending. No full scheduled, model-driven Gateway run or production deployment is claimed.
Scope, provenance, and validation details
node scripts/run-vitest.mjs src/gateway/operator-run-recovery.test.ts src/gateway/cron-operator-source.test.ts --maxWorkers=1— 41 passed; runner wall time 107.38 seconds; new runtime regression 956 ms.node scripts/run-vitest.mjs test/scripts/check-session-identity-ratchet.test.ts test/scripts/ci-baseline-ratchets.test.ts --maxWorkers=1— 6 passed; runner wall time 1.35 seconds; new checker file 77 ms. CI timings are not yet available.pnpm check:session-identity-ratchet --base df315eb3bb99eeb23e5395893e61a9e9daba80e3 --no-merge-basepasses after generated pruning, without--prune.node scripts/run-tsgo.mjs -p tsconfig.scripts.json --noEmitandnode scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.test.root.tooling.json --incremental.df315eb3bb99eeb23e5395893e61a9e9daba80e3, committed asa706a5d9fbde3350c548c91e9e5c96ff9dc36b40. The reviewer assessed the supplied code and context; repository test execution and count validation were performed separately as recorded above.Contributor: @hannesrudolph reported the issue, authored the original repair, and requested the expanded scope.
Work sessions
Linked for team reference; these sessions aren’t public.