Repository navigation
fix(cron): a chat-created automation's failure notice reaches that chat - #203056
Conversation
…ts own conversation Co-authored-by: obviyus <[email protected]>
…lves Co-authored-by: obviyus <[email protected]>
|
🦞👀 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 changesRecords failure notices for chat-created automations without an external route in the creating conversation. Example: The chat-created automation “Thrower fix” encounters a trigger error on a Gateway with Telegram configured.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR fixes a current routing defect with a focused change and no identified correctness findings. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe scheduler produces failure-notification intents; the Gateway resolves their destinations and delivers them through an external transport or the existing conversation-result writer. flowchart TD
A[Automation failure] --> B[Scheduler notification intent]
B --> C[Gateway delivery resolver]
C --> D[External delivery obligation]
D --> E[Channel transport]
C --> F[Current conversation without external route]
F --> G[Canonical conversation writer]
Technical reviewBest possible solution: Land the focused resolver-and-writer repair while preserving explicit external delivery obligations and separate completion and failure-notice identities. Do we have a high-confidence way to reproduce the issue? Current main's resolver call omits the conversation-bound sessionTarget that prevents unrelated channel selection; the PR also records a matching base-versus-fix Gateway reproduction. Is this the best way to solve the issue? The patch restores the existing routing invariant using established owners, and its two tests cover local conversation delivery and rejection of a false local success for an explicit recipient. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 86b7d4044522. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +29, Tests +137. Total +166 across 3 files. Added test files: 1. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. 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 November 21, 2026, 6:13 AM ET / 11:13 UTC. |
Co-authored-by: obviyus <[email protected]>
…3044 * origin/main: refactor(test): remove duplicate token startup wait case (#203087) fix: keep Plugin SDK declarations within the build limit fix(ci): remove unused hook type exports (#203074) fix(test): exercise the sign-in callback path guard (#203075) refactor(tts): separate caption eligibility from text helpers (#203068) test: reuse worker preload options (#203058) refactor(test): share Bun native-policy test launcher (#203064) fix(cron): a chat-created automation's failure notice reaches that chat (#203056) refactor(test): remove duplicate claw origin rejection case (#203067) refactor(channels): move chunk-mode lookup to streaming readers (#203047) refactor: separate skill queries from workspace discovery (#203045) fix: resume new chat turns in retained tasks after a restart refactor: separate usage pricing preparation from formatting (#203043) fix: avoid repeated filesystem probes before agent turns (#203057) perf(agents): preserve sealed history during endpoint compaction (#203037) fix(test): give deferred identity fixtures read scope (#203053) refactor(test): remove redundant channel catalog facade (#203052) refactor(cli): isolate daemon port presentation (#203020) refactor(cron): isolate CLI input parsing (#203031)
* feat: open shared sessions in their source Control UI * feat: open shared sessions in their source Control UI OpenClaw-Publication: a3826b6b-5899-8ff2-a1b5-84961c64219f * Merge remote-tracking branch 'origin/main' into land/open-original-203044 * origin/main: fix(ci): decouple boundary fixture from timing inventory (#203026) fix(ci): shard capable compatibility UI targets (#203042) perf(agents): restore selected subagent payloads once (#203039) fix: keep standalone context from completing QA tool steps perf(sessions): reuse sealed ownership for context projections (#203040) refactor(hooks): separate event predicates from hook registry (#203017) fix(ci): align update export audits with their consumers (#203030) fix: keep cold baseline checks within the existing heap limit * fix(session-share): accept the runtime config snapshot in the source link resolver The stored-session link resolver took a mutable config, so the plugin's readonly runtime snapshot failed production and test typechecks. Accept the snapshot type. Document the real Open original setup: allow the link command on the receiver Gateway, set the source Control UI origin, reinstall the source node with all three commands, then approve the widened surface. Move the section ahead of Security boundary and add a troubleshooting entry. Assert through the Gateway catalog list that a provider-supplied link survives streamed and final rows, and drop the menu unit test the browser fixture covers. * Merge remote-tracking branch 'origin/main' into land/open-original-203044 * origin/main: refactor(test): remove duplicate token startup wait case (#203087) fix: keep Plugin SDK declarations within the build limit fix(ci): remove unused hook type exports (#203074) fix(test): exercise the sign-in callback path guard (#203075) refactor(tts): separate caption eligibility from text helpers (#203068) test: reuse worker preload options (#203058) refactor(test): share Bun native-policy test launcher (#203064) fix(cron): a chat-created automation's failure notice reaches that chat (#203056) refactor(test): remove duplicate claw origin rejection case (#203067) refactor(channels): move chunk-mode lookup to streaming readers (#203047) refactor: separate skill queries from workspace discovery (#203045) fix: resume new chat turns in retained tasks after a restart refactor: separate usage pricing preparation from formatting (#203043) fix: avoid repeated filesystem probes before agent turns (#203057) perf(agents): preserve sealed history during endpoint compaction (#203037) fix(test): give deferred identity fixtures read scope (#203053) refactor(test): remove redundant channel catalog facade (#203052) refactor(cli): isolate daemon port presentation (#203020) refactor(cron): isolate CLI input parsing (#203031) * chore(plugin-sdk): record the approved session-discussion surface growth Open original adds two exports to openclaw/plugin-sdk/session-discussion: the stored-session Control UI path resolver and the session path parser. Raise the public export and callable budgets by two for them. Use neutral fixtures for the rejected-origin and rejected-query URL tests so the fixtures do not resemble credentials; the same rejections are covered. Co-authored-by: Vincent Koc <[email protected]> Co-authored-by: vincentkoc <[email protected]>
…at (openclaw#203056) ## Problem An automation created in a chat (`sessionTarget: "current"`, `delivery: { mode: "announce" }`, no channel) sends its results back to that chat. Its failure notice did not go there. The failure-alert transport called `resolveDeliveryTarget` without the job's `sessionTarget` (`src/gateway/server-cron-notifications.ts:488`). The resolver's rule "a conversation-bound job with no external route completes in its conversation" (`src/cron/isolated-agent/delivery-target.ts:281`) did not apply. The resolver then took whatever channel was configured. On a Gateway that has Telegram configured, it chose Telegram with no recipient and failed with `Delivering to Telegram requires target <chatId>`. The job recorded `lastFailureNotificationDeliveryStatus: not-delivered`. The in-app fallback did put a notice in the chat, but as a new user turn. The result path does the right thing: it passes `sessionTarget`, gets "Channel is required when delivery.channel=last has no previous channel.", and commits the result to the creating conversation (`fallbackUsed: true`, `delivered: true`). ## Solution The failure-alert transport now: - Passes the job's `sessionTarget` to the same resolver, so the resolver does not pick an unrelated channel. - When a `current` job has no external route, commits the notice to its conversation through `commitCronConversationResult`, the same writer that results use. The notice uses its own idempotency key, so it cannot collide with that run's result row. - Keeps an explicit recipient, account or thread owed. `requiresExternalCronDelivery` (the existing obligation check) blocks the conversation fallback in that case, so an explicit target never becomes a local write recorded as delivered. ## Evidence - **Regression test** in `src/cron/service/failure-alerts.owner-conversation.test.ts`. It runs the real `CronService` and the real Gateway transport: an owned `current` job, announce with no channel, a trigger that throws, and a run that comes due. It fails on `main` with `Channel is required (no configured channels detected)`. With the fix, it passes and shows `delivered` plus the notice in the owner transcript. - **Control test:** an explicit `to` with channel `last` and no channel that can be selected stays `not-delivered` and writes nothing to the conversation. It fails on the first revision of this fix and passes now. - **Isolated Gateway E2E** (`ocx`, Telegram configured, a trigger that throws, a schedule that comes due by itself, job created by the owner chat with the automations tool): - On base: `lastFailureNotificationDeliveryStatus: not-delivered` with `Delivering to Telegram requires target <chatId>`. The log shows `cron: failure alert delivery failed`. The notice appears in the chat only as a fallback user turn. - On the fix: `lastFailureNotificationDelivered: true` with status `delivered`. The owner's `chat.history` has `Automation "Thrower fix" failed / Cause: trigger script failed internally / Run started: 2026-11-21 16:09 GMT+5:30` with key `cron-failure-alert:…`. No Telegram send was tried. - `pnpm tsgo` and oxlint are clean. The notifications, completion, failure-repair and failure-alert suites pass (103 tests). - The local ClawSweeper review is clean at `e00b1e658363`. The first round's P2 about explicit recipients is fixed and has its own test. - `src/cron/cron-delivery-outcomes.e2e.test.ts` still expected the old two-failure threshold; f0db8f9 made the first failure alert by default. CI's changed-test shard ran it here and failed; the expectation now matches main's default and the file passes locally. ## Follow-ups (not in this PR) - A chat-created job with `operatorSource` is turned off after one permanent trigger error (`timer-outcomes.ts:341`). Its failure therefore skips the owner repair turn and takes the plain alert path. That is what happened here. - Isolated jobs bound by `sourceConversation` have the same gap for failure notices, because the notification job does not carry `sourceConversation`. Co-authored-by: Ayaan Zaidi <[email protected]>
* feat: open shared sessions in their source Control UI * feat: open shared sessions in their source Control UI OpenClaw-Publication: a3826b6b-5899-8ff2-a1b5-84961c64219f * Merge remote-tracking branch 'origin/main' into land/open-original-203044 * origin/main: fix(ci): decouple boundary fixture from timing inventory (openclaw#203026) fix(ci): shard capable compatibility UI targets (openclaw#203042) perf(agents): restore selected subagent payloads once (openclaw#203039) fix: keep standalone context from completing QA tool steps perf(sessions): reuse sealed ownership for context projections (openclaw#203040) refactor(hooks): separate event predicates from hook registry (openclaw#203017) fix(ci): align update export audits with their consumers (openclaw#203030) fix: keep cold baseline checks within the existing heap limit * fix(session-share): accept the runtime config snapshot in the source link resolver The stored-session link resolver took a mutable config, so the plugin's readonly runtime snapshot failed production and test typechecks. Accept the snapshot type. Document the real Open original setup: allow the link command on the receiver Gateway, set the source Control UI origin, reinstall the source node with all three commands, then approve the widened surface. Move the section ahead of Security boundary and add a troubleshooting entry. Assert through the Gateway catalog list that a provider-supplied link survives streamed and final rows, and drop the menu unit test the browser fixture covers. * Merge remote-tracking branch 'origin/main' into land/open-original-203044 * origin/main: refactor(test): remove duplicate token startup wait case (openclaw#203087) fix: keep Plugin SDK declarations within the build limit fix(ci): remove unused hook type exports (openclaw#203074) fix(test): exercise the sign-in callback path guard (openclaw#203075) refactor(tts): separate caption eligibility from text helpers (openclaw#203068) test: reuse worker preload options (openclaw#203058) refactor(test): share Bun native-policy test launcher (openclaw#203064) fix(cron): a chat-created automation's failure notice reaches that chat (openclaw#203056) refactor(test): remove duplicate claw origin rejection case (openclaw#203067) refactor(channels): move chunk-mode lookup to streaming readers (openclaw#203047) refactor: separate skill queries from workspace discovery (openclaw#203045) fix: resume new chat turns in retained tasks after a restart refactor: separate usage pricing preparation from formatting (openclaw#203043) fix: avoid repeated filesystem probes before agent turns (openclaw#203057) perf(agents): preserve sealed history during endpoint compaction (openclaw#203037) fix(test): give deferred identity fixtures read scope (openclaw#203053) refactor(test): remove redundant channel catalog facade (openclaw#203052) refactor(cli): isolate daemon port presentation (openclaw#203020) refactor(cron): isolate CLI input parsing (openclaw#203031) * chore(plugin-sdk): record the approved session-discussion surface growth Open original adds two exports to openclaw/plugin-sdk/session-discussion: the stored-session Control UI path resolver and the session path parser. Raise the public export and callable budgets by two for them. Use neutral fixtures for the rejected-origin and rejected-query URL tests so the fixtures do not resemble credentials; the same rejections are covered. Co-authored-by: Vincent Koc <[email protected]> Co-authored-by: vincentkoc <[email protected]>
Adapted from 3eb60f7 (#203056), by Ayaan Zaidi. Preserve the lead270 explicit two-failure threshold expectation; retain the three-file routing repair and regression. Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 5493554d640589c2806671bd96f4626088cd0b7c) (cherry picked from commit 69bdf07114198f77720d82d2df32e8d997b7027d)
…at (#203056) Baseline adaptation: Reuse the baseline conversation writer and persisted notification ID for unrouted current-session alerts; preserve external delivery obligations and transport outcomes. (cherry picked from commit 3eb60f7) Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 71a7e36143c905112a0b5f7433ec5b79b208cedc)
Problem
An automation created in a chat (
sessionTarget: "current",delivery: { mode: "announce" }, no channel) sends its results back to that chat. Its failure notice did not go there.The failure-alert transport called
resolveDeliveryTargetwithout the job'ssessionTarget(src/gateway/server-cron-notifications.ts:488). The resolver's rule "a conversation-bound job with no external route completes in its conversation" (src/cron/isolated-agent/delivery-target.ts:281) did not apply. The resolver then took whatever channel was configured. On a Gateway that has Telegram configured, it chose Telegram with no recipient and failed withDelivering to Telegram requires target <chatId>. The job recordedlastFailureNotificationDeliveryStatus: not-delivered. The in-app fallback did put a notice in the chat, but as a new user turn.The result path does the right thing: it passes
sessionTarget, gets "Channel is required when delivery.channel=last has no previous channel.", and commits the result to the creating conversation (fallbackUsed: true,delivered: true).Solution
The failure-alert transport now:
sessionTargetto the same resolver, so the resolver does not pick an unrelated channel.currentjob has no external route, commits the notice to its conversation throughcommitCronConversationResult, the same writer that results use. The notice uses its own idempotency key, so it cannot collide with that run's result row.requiresExternalCronDelivery(the existing obligation check) blocks the conversation fallback in that case, so an explicit target never becomes a local write recorded as delivered.Evidence
Regression test in
src/cron/service/failure-alerts.owner-conversation.test.ts. It runs the realCronServiceand the real Gateway transport: an ownedcurrentjob, announce with no channel, a trigger that throws, and a run that comes due. It fails onmainwithChannel is required (no configured channels detected). With the fix, it passes and showsdeliveredplus the notice in the owner transcript.Control test: an explicit
towith channellastand no channel that can be selected staysnot-deliveredand writes nothing to the conversation. It fails on the first revision of this fix and passes now.Isolated Gateway E2E (
ocx, Telegram configured, a trigger that throws, a schedule that comes due by itself, job created by the owner chat with the automations tool):lastFailureNotificationDeliveryStatus: not-deliveredwithDelivering to Telegram requires target <chatId>. The log showscron: failure alert delivery failed. The notice appears in the chat only as a fallback user turn.lastFailureNotificationDelivered: truewith statusdelivered. The owner'schat.historyhasAutomation "Thrower fix" failed / Cause: trigger script failed internally / Run started: 2026-11-21 16:09 GMT+5:30with keycron-failure-alert:…. No Telegram send was tried.pnpm tsgoand oxlint are clean. The notifications, completion, failure-repair and failure-alert suites pass (103 tests).The local ClawSweeper review is clean at
e00b1e658363. The first round's P2 about explicit recipients is fixed and has its own test.src/cron/cron-delivery-outcomes.e2e.test.tsstill expected the old two-failure threshold; 9a12f4d made the first failure alert by default. CI's changed-test shard ran it here and failed; the expectation now matches main's default and the file passes locally.Follow-ups (not in this PR)
operatorSourceis turned off after one permanent trigger error (timer-outcomes.ts:341). Its failure therefore skips the owner repair turn and takes the plain alert path. That is what happened here.sourceConversationhave the same gap for failure notices, because the notification job does not carrysourceConversation.