Skip to content

fix(cron): show job notices when the owner conversation's model cannot run - #207186

Merged
obviyus merged 1 commit into
mainfrom
fix/cron-notice-direct
Nov 28, 2026
Merged

obviyus merged 1 commit into
mainfrom
fix/cron-notice-direct

Conversation

@obviyus

@obviyus obviyus commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

Problem

Cron's fixed notices reach the owner conversation only as a session-event model turn. These are the auto-disabled notice (including account-unavailable from #207097) and the failure alert when no direct transport delivers it, which also covers repair fallbacks and the #207091 reset alert. The notice text becomes the turn's input row. When the conversation's own model cannot run, for example on the same signed-out account, the turn fails before it starts and writes no row. The user never sees why their automation stopped.

Fix

The Gateway cron adapter (src/gateway/server-cron-targets.ts) keeps the notice turn, because it is also the agent's repair turn (#188105). When a job notice's turn settles failed without starting and is not retained for retry, the adapter posts the same text through the existing session notice writer (postSessionNotice). This writes one transcript row, sends it to the conversation's channel unless the event is private, and adds the text to the next turn's context. No model turn is involved.

  • It uses the captured target's store path and deliver policy.
  • When the model works, nothing changes: the user sees the same row and the agent's reply.

Review

Fable reviewed this adversarially. Applied: drop the extra flag (jobId already identifies job notices); skip retryable outcomes, because the retained event still owns its text; honor the captured target's deliver and store path.

Not applied:

  • A re-check of requester authority before the post. Authority is decided once, when the turn target is captured. Repo rules forbid assertCurrent()-style re-checks.
  • Always posting notices directly and hiding the repair input. That would change what users see when the model works, and would send a second channel message.

Accepted edge cases:

  • A notice whose turn is cancelled by restart or supersession is not reposted.
  • A session that does not exist yet (createIfMissing) and fails before creation has nowhere to post. The warning is logged.

Evidence

  • src/gateway/server-cron-notice-delivery.test.ts uses a real Gateway target resolver, a real session-event handoff and an owner model with no usable account. On the merge base, 0 visible notices. On this branch, exactly 1.
  • Cron failure-alert, delivery-outcome, startup-notification, Gateway notification and failure-repair final-effect suites pass.

…t run

A job notice whose session-event turn fails before it starts, and is not retained, is posted through the session notice writer instead of being lost. Uses the captured target's store path and delivery policy; the turn stays the repair turn when the model works.
@clawsweeper

clawsweeper Bot commented Nov 28, 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.

@obviyus
obviyus marked this pull request as ready for review November 28, 2026 03:28
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: S labels Nov 28, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. impact:ux-friction User-facing flow adds avoidable confusion or support burden without fully blocking progress. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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 Nov 28, 2026
@clawsweeper

clawsweeper Bot commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Codex review: passed.

What this changes

The PR posts a fixed automation notice directly when its owner-conversation turn permanently fails before execution starts.

Example: The Health check automation is disabled after its account is signed out, and the owner conversation also has no usable model account.

  • Before: The notice turn fails before starting, leaving the conversation without the repair instructions.
  • After: The existing session-notice writer records the notice without running a model and optionally delivers it to the conversation’s channel.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused implementation has no identified correctness defect, but required shipped-entry-point proof is absent; existing transcript and delivery formats are reused without migration.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An automation can stop without showing its owner the notice or repair instructions because the owner conversation’s model also cannot run.
Reason: This is a focused repair of an evidenced silent failure, and the maintainer-authored direction preserves existing successful-turn behavior.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR addresses a concrete silent-notice failure still present on main, and inspection found no definite introduced bug.

Reviewed head: 31bc57f1e768eb4fc8228a0942c56fffc50bf625

Before merge

None.

Findings

None.

Agent review details

How this fits together

The Gateway cron adapter translates scheduler notices into owner-conversation turns; the fallback uses the existing session-notice owner for transcript, next-turn context, and channel delivery.

flowchart TD
  A[Cron scheduler notice] --> B[Gateway cron adapter]
  B --> C[Owner conversation turn]
  C --> D[Normal repair and reply]
  C --> E[Permanent failure before start]
  E --> F[Session notice writer]
  F --> G[Transcript and next turn context]
  F --> H[Conversation channel]
Loading

Technical review

Best possible solution:

Keep the normal repair turn and use the existing session-notice writer only for terminal pre-start notice failures.

Do we have a high-confidence way to reproduce the issue?

Source establishes the failure path, the preceding merged repair documents it, and the PR reports a matching regression; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The fallback is appropriately placed in the cron adapter, preserves the established repair behavior, and delegates notice effects to their existing owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 0edb7c507f91.

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +59, Tests +84, Docs 0. Total +143 across 3 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 1 62 3 +59
Tests 1 84 0 +84
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 147 4 +143

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab 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:

  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Capture the unavailable-owner-model scenario through an isolated shipped Gateway and show the resulting notice.

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 November 27, 2026, 10:45 PM ET / November 28, 2026, 03:45 UTC.

@obviyus
obviyus merged commit 22a3aec into main Nov 28, 2026
207 checks passed
@obviyus
obviyus deleted the fix/cron-notice-direct branch November 28, 2026 03:55
@obviyus

obviyus commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator Author

Landed as 22a3aec. Before: the cron job notice was lost when the owner conversation's model could not run (0 rows on base). After: exactly 1 visible notice, posted without a model turn. CI green on 31bc57f; local ClawSweeper on the exact head: correct, no findings.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 28, 2026
…t run (openclaw#207186)

## Problem

Cron's fixed notices reach the owner conversation only as a session-event model turn. These are the auto-disabled notice (including `account-unavailable` from openclaw#207097) and the failure alert when no direct transport delivers it, which also covers repair fallbacks and the openclaw#207091 reset alert. The notice text becomes the turn's input row. When the conversation's own model cannot run, for example on the same signed-out account, the turn fails before it starts and writes no row. The user never sees why their automation stopped.

## Fix

The Gateway cron adapter (`src/gateway/server-cron-targets.ts`) keeps the notice turn, because it is also the agent's repair turn (openclaw#188105). When a job notice's turn settles `failed` without starting and is not retained for retry, the adapter posts the same text through the existing session notice writer (`postSessionNotice`). This writes one transcript row, sends it to the conversation's channel unless the event is private, and adds the text to the next turn's context. No model turn is involved.

- It uses the captured target's store path and `deliver` policy.
- When the model works, nothing changes: the user sees the same row and the agent's reply.

## Review

Fable reviewed this adversarially. Applied: drop the extra flag (`jobId` already identifies job notices); skip retryable outcomes, because the retained event still owns its text; honor the captured target's `deliver` and store path.

Not applied:
- A re-check of requester authority before the post. Authority is decided once, when the turn target is captured. Repo rules forbid `assertCurrent()`-style re-checks.
- Always posting notices directly and hiding the repair input. That would change what users see when the model works, and would send a second channel message.

Accepted edge cases:
- A notice whose turn is `cancelled` by restart or supersession is not reposted.
- A session that does not exist yet (`createIfMissing`) and fails before creation has nowhere to post. The warning is logged.

## Evidence

- `src/gateway/server-cron-notice-delivery.test.ts` uses a real Gateway target resolver, a real session-event handoff and an owner model with no usable account. On the merge base, 0 visible notices. On this branch, exactly 1.
- Cron failure-alert, delivery-outcome, startup-notification, Gateway notification and failure-repair final-effect suites pass.

Co-authored-by: Ayaan Zaidi <[email protected]>
obviyus added a commit that referenced this pull request Nov 28, 2026
…input (#207226)

## Problem

#207186 fixed the case where a cron job notice (auto-disabled, or a fallback failure alert) was lost because the owner conversation's model could not run. The notice still reached chat only as a model turn's input, and was posted directly only after that turn failed before start. A turn cancelled before start (supersession, restart) still lost it. The notice also never reached the conversation's channel as written; there the user saw only the agent's reply about it.

## Fix

`src/gateway/server-cron-targets.ts` posts every job notice directly through the session notice writer (`postSessionNotice`), without a model turn. The post needs no requester: it is fixed runtime text sent to the job owner conversation. It writes one chat row and a durable send to the conversation's channel, unless the notice is private or the conversation denies automatic sends (`session.sendPolicy`).

The notice's turn stays as the agent's repair turn (#188105), with its input hidden from chat (`cron_failure_repair` provenance, the same authority path as `cron`). Its error payloads are suppressed, as for repair turns, because the user already has the notice. When there is no session to post into yet, the turn keeps its visible input, so the notice still shows exactly once. The posted row is not replayed to the model, so when the repair turn fails for good before it starts (the owner conversation's model cannot run), the text is queued as context for the next turn, as #207186 did. The #207186 settle-time fallback is removed.

## What users see

- Chat: the fixed notice as a system notice row, then the agent's reply when the model works. Before, it was shown as a user-role row.
- Channels: the fixed notice, then the agent's reply. Before, only the reply.
- A dead model: the notice still shows once.
- Session notices (plugin notices too) now honor `session.sendPolicy`: a conversation that denies automatic sends keeps the notice in its transcript only. Before, `postSessionNotice` sent to the channel regardless.

## Accepted edge cases

- Owner guidance typed into a notice's repair turn does not join it as owner continuation. Repair turns already work this way.

## Evidence

- `server-cron-notice-delivery.test.ts`: owner model with no usable account. Chat shows the notice exactly once, as the posted assistant row. The next turn gets the notice as context.
- `server-cron-failure-repair.final-effect.test.ts`, auto-disabled case with a working model: the repair still applies and chat shows the notice exactly once, as the posted row, not the turn input.
- `runtime-session-notice.e2e.test.ts`: a conversation with `sendPolicy: deny` gets the transcript row and no channel send.
- `pnpm check:madge-import-cycles`: 0 cycles. The send policy is loaded lazily on the delivery path, because its owner reaches the channel plugin registry, which loads the notice writer.
- Not covered by a test: the private branch (`deliver: false`, one expression) and the channel send itself.
- Cron failure-alert, delivery-outcome, startup-notification and Gateway notification suites pass.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 29, 2026
…input (openclaw#207226)

## Problem

openclaw#207186 fixed the case where a cron job notice (auto-disabled, or a fallback failure alert) was lost because the owner conversation's model could not run. The notice still reached chat only as a model turn's input, and was posted directly only after that turn failed before start. A turn cancelled before start (supersession, restart) still lost it. The notice also never reached the conversation's channel as written; there the user saw only the agent's reply about it.

## Fix

`src/gateway/server-cron-targets.ts` posts every job notice directly through the session notice writer (`postSessionNotice`), without a model turn. The post needs no requester: it is fixed runtime text sent to the job owner conversation. It writes one chat row and a durable send to the conversation's channel, unless the notice is private or the conversation denies automatic sends (`session.sendPolicy`).

The notice's turn stays as the agent's repair turn (openclaw#188105), with its input hidden from chat (`cron_failure_repair` provenance, the same authority path as `cron`). Its error payloads are suppressed, as for repair turns, because the user already has the notice. When there is no session to post into yet, the turn keeps its visible input, so the notice still shows exactly once. The posted row is not replayed to the model, so when the repair turn fails for good before it starts (the owner conversation's model cannot run), the text is queued as context for the next turn, as openclaw#207186 did. The openclaw#207186 settle-time fallback is removed.

## What users see

- Chat: the fixed notice as a system notice row, then the agent's reply when the model works. Before, it was shown as a user-role row.
- Channels: the fixed notice, then the agent's reply. Before, only the reply.
- A dead model: the notice still shows once.
- Session notices (plugin notices too) now honor `session.sendPolicy`: a conversation that denies automatic sends keeps the notice in its transcript only. Before, `postSessionNotice` sent to the channel regardless.

## Accepted edge cases

- Owner guidance typed into a notice's repair turn does not join it as owner continuation. Repair turns already work this way.

## Evidence

- `server-cron-notice-delivery.test.ts`: owner model with no usable account. Chat shows the notice exactly once, as the posted assistant row. The next turn gets the notice as context.
- `server-cron-failure-repair.final-effect.test.ts`, auto-disabled case with a working model: the repair still applies and chat shows the notice exactly once, as the posted row, not the turn input.
- `runtime-session-notice.e2e.test.ts`: a conversation with `sendPolicy: deny` gets the transcript row and no channel send.
- `pnpm check:madge-import-cycles`: 0 cycles. The send policy is loaded lazily on the delivery path, because its owner reaches the channel plugin registry, which loads the notice writer.
- Not covered by a test: the private branch (`deliver: false`, one expression) and the channel send itself.
- Cron failure-alert, delivery-outcome, startup-notification and Gateway notification suites pass.

Co-authored-by: Ayaan Zaidi <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 29, 2026
…t run (#207186)

## Problem

Cron's fixed notices reach the owner conversation only as a session-event model turn. These are the auto-disabled notice (including `account-unavailable` from #207097) and the failure alert when no direct transport delivers it, which also covers repair fallbacks and the #207091 reset alert. The notice text becomes the turn's input row. When the conversation's own model cannot run, for example on the same signed-out account, the turn fails before it starts and writes no row. The user never sees why their automation stopped.

## Fix

The Gateway cron adapter (`src/gateway/server-cron-targets.ts`) keeps the notice turn, because it is also the agent's repair turn (#188105). When a job notice's turn settles `failed` without starting and is not retained for retry, the adapter posts the same text through the existing session notice writer (`postSessionNotice`). This writes one transcript row, sends it to the conversation's channel unless the event is private, and adds the text to the next turn's context. No model turn is involved.

- It uses the captured target's store path and `deliver` policy.
- When the model works, nothing changes: the user sees the same row and the agent's reply.

## Review

Fable reviewed this adversarially. Applied: drop the extra flag (`jobId` already identifies job notices); skip retryable outcomes, because the retained event still owns its text; honor the captured target's `deliver` and store path.

Not applied:
- A re-check of requester authority before the post. Authority is decided once, when the turn target is captured. Repo rules forbid `assertCurrent()`-style re-checks.
- Always posting notices directly and hiding the repair input. That would change what users see when the model works, and would send a second channel message.

Accepted edge cases:
- A notice whose turn is `cancelled` by restart or supersession is not reposted.
- A session that does not exist yet (`createIfMissing`) and fails before creation has nowhere to post. The warning is logged.

## Evidence

- `src/gateway/server-cron-notice-delivery.test.ts` uses a real Gateway target resolver, a real session-event handoff and an owner model with no usable account. On the merge base, 0 visible notices. On this branch, exactly 1.
- Cron failure-alert, delivery-outcome, startup-notification, Gateway notification and failure-repair final-effect suites pass.

Co-authored-by: Ayaan Zaidi <[email protected]>

(cherry picked from commit 22a3aec)

Release adaptation: Keep the beta.2 cron troubleshooting document; its release-specific surrounding guidance conflicts. The runtime/test patch applies unchanged.

Companions: #207226 changes notice display to direct posting with hidden repair input; not needed for the failed-before-start fallback, and not in this lane.

Co-authored-by: RomneyDa <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 29, 2026
…input (#207226)

## Problem

#207186 fixed the case where a cron job notice (auto-disabled, or a fallback failure alert) was lost because the owner conversation's model could not run. The notice still reached chat only as a model turn's input, and was posted directly only after that turn failed before start. A turn cancelled before start (supersession, restart) still lost it. The notice also never reached the conversation's channel as written; there the user saw only the agent's reply about it.

## Fix

`src/gateway/server-cron-targets.ts` posts every job notice directly through the session notice writer (`postSessionNotice`), without a model turn. The post needs no requester: it is fixed runtime text sent to the job owner conversation. It writes one chat row and a durable send to the conversation's channel, unless the notice is private or the conversation denies automatic sends (`session.sendPolicy`).

The notice's turn stays as the agent's repair turn (#188105), with its input hidden from chat (`cron_failure_repair` provenance, the same authority path as `cron`). Its error payloads are suppressed, as for repair turns, because the user already has the notice. When there is no session to post into yet, the turn keeps its visible input, so the notice still shows exactly once. The posted row is not replayed to the model, so when the repair turn fails for good before it starts (the owner conversation's model cannot run), the text is queued as context for the next turn, as #207186 did. The #207186 settle-time fallback is removed.

## What users see

- Chat: the fixed notice as a system notice row, then the agent's reply when the model works. Before, it was shown as a user-role row.
- Channels: the fixed notice, then the agent's reply. Before, only the reply.
- A dead model: the notice still shows once.
- Session notices (plugin notices too) now honor `session.sendPolicy`: a conversation that denies automatic sends keeps the notice in its transcript only. Before, `postSessionNotice` sent to the channel regardless.

## Accepted edge cases

- Owner guidance typed into a notice's repair turn does not join it as owner continuation. Repair turns already work this way.

## Evidence

- `server-cron-notice-delivery.test.ts`: owner model with no usable account. Chat shows the notice exactly once, as the posted assistant row. The next turn gets the notice as context.
- `server-cron-failure-repair.final-effect.test.ts`, auto-disabled case with a working model: the repair still applies and chat shows the notice exactly once, as the posted row, not the turn input.
- `runtime-session-notice.e2e.test.ts`: a conversation with `sendPolicy: deny` gets the transcript row and no channel send.
- `pnpm check:madge-import-cycles`: 0 cycles. The send policy is loaded lazily on the delivery path, because its owner reaches the channel plugin registry, which loads the notice writer.
- Not covered by a test: the private branch (`deliver: false`, one expression) and the channel send itself.
- Cron failure-alert, delivery-outcome, startup-notification and Gateway notification suites pass.

Co-authored-by: Ayaan Zaidi <[email protected]>

Follow-up scan: 494561c test: fix the participation admission test after cron notices became repair turns (#207414); 2a3bf24 fix(cron): let the agent stay silent after a posted automation notice (#207315). Other hits are not required by this focused beta.2 fix.

(cherry picked from commit fff3e0e)

Release adaptation: Backport direct posting onto the beta.2 cron target, preserving the admitted session generation and no-delivery policy.

Release adaptation: Resolve the lane-5 #207186 overlap in upstream order: replace the settle-time visible fallback with a direct post and hidden repair input, preserve next-turn context on permanent pre-start failure, and keep the release target-generation and delivery checks. The notice regression now checks chat projection and queued context; the separate removal, quota-alert and script-delivery fixes remain intact.

Co-authored-by: RomneyDa <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
…input (#207226)

`src/gateway/server-cron-targets.ts` posts every job notice directly through the session notice writer (`postSessionNotice`), without a model turn. The post needs no requester: it is fixed runtime text sent to the job owner conversation. It writes one chat row and a durable send to the conversation's channel, unless the notice is private or the conversation denies automatic sends (`session.sendPolicy`).

The notice's turn stays as the agent's repair turn (#188105), with its input hidden from chat (`cron_failure_repair` provenance, the same authority path as `cron`). Its error payloads are suppressed, as for repair turns, because the user already has the notice. When there is no session to post into yet, the turn keeps its visible input, so the notice still shows exactly once. The posted row is not replayed to the model, so when the repair turn fails for good before it starts (the owner conversation's model cannot run), the text is queued as context for the next turn, as #207186 did. The #207186 settle-time fallback is removed.

- Chat: the fixed notice as a system notice row, then the agent's reply when the model works. Before, it was shown as a user-role row.
- Channels: the fixed notice, then the agent's reply. Before, only the reply.
- A dead model: the notice still shows once.
- Session notices (plugin notices too) now honor `session.sendPolicy`: a conversation that denies automatic sends keeps the notice in its transcript only. Before, `postSessionNotice` sent to the channel regardless.

- Owner guidance typed into a notice's repair turn does not join it as owner continuation. Repair turns already work this way.

- `server-cron-notice-delivery.test.ts`: owner model with no usable account. Chat shows the notice exactly once, as the posted assistant row. The next turn gets the notice as context.
- `server-cron-failure-repair.final-effect.test.ts`, auto-disabled case with a working model: the repair still applies and chat shows the notice exactly once, as the posted row, not the turn input.
- `runtime-session-notice.e2e.test.ts`: a conversation with `sendPolicy: deny` gets the transcript row and no channel send.
- `pnpm check:madge-import-cycles`: 0 cycles. The send policy is loaded lazily on the delivery path, because its owner reaches the channel plugin registry, which loads the notice writer.
- Not covered by a test: the private branch (`deliver: false`, one expression) and the channel send itself.
- Cron failure-alert, delivery-outcome, startup-notification and Gateway notification suites pass.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit fff3e0e)

Release adaptation: Keep only session notice automatic-send policy resolution and transcript-only proof. Leave stable cron posting and repair behavior untouched.

Companion audit: 2a3bf24 and 494561c cover excluded cron redesign; b3f2fcc covers Goal scheduling; d62c462 changes an independent transcript write fence. None is required for the selected send-policy slice.

Co-authored-by: RomneyDa <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
…ext run (#207091)

## Problem

On a production deployment, 126 scheduled-automation runs in 7 days failed with "<model> is rate-limited. The provider says to retry in 5-6 days". Recurring jobs ran again on every slot, or hourly once the error backoff reached its 60-minute maximum, and every run hit the same limit. Two jobs were still looping with 25 consecutive errors. Nothing in the cron scheduler read the provider's reset time; a rate limit counted as a transient error.

## Fix

- The run result now carries the provider's reset time as a transient fact (`rateLimitResetAt`, never stored). It is set only when every failed model attempt was rate-limited with a known reset (candidates skipped for a local cooldown are ignored), and the earliest reset wins. It reuses the existing reset facts on the failover error.
  - Session-target jobs: the settled failure cause already reaches the automation settlement in-process.
  - Isolated jobs: the run's catch, forwarded by the isolated execution adapter.
- `applyJobResult` uses it when scheduling the next run after an error:
  - The next normal slot is the first scheduled slot at or after the reset, so cron expressions stay on their schedule.
  - A reset before the schedule's own next slot moves the quick retry to the reset. A later reset skips quick retries for the first slot after it (an off-slot time there would be moved earlier by schedule maintenance), and the failure alert is not held for a retry that is days away.
- One-shot jobs are unchanged.
- Jobs are not paused; the failure notice already names the reset time (#206945).

## User impact

A recurring automation on a model with a multi-day limit stops hitting the provider, or the local limit gate, every hour. It runs again on its first slot after the stated reset, and the user gets the failure alert once instead of after every slot.

## Evidence

- `src/cron/rate-limit-reset.integration.test.ts`: a loopback provider returns 429 with `retry-after: 518400`. On both the session-target and the isolated path, the run makes one provider request and reports the reset (~6 days). Fails on main (no reset reported), passes here.
- `src/cron/service/timer-outcomes.regression.test.ts`: an hourly `every` job and a weekday cron job land exactly on their first slot after the reset, schedule maintenance keeps that slot, and the failure alert is emitted. A 45-second reset moves the quick retry instead of skipping to the next day. Fails on main, passes here.
- The same file runs both execution adapters through the timer, schedule maintenance and the persisted store, including a 5-minute cron with a 20-minute reset: the stored next run is the first slot after the reset.
- Cron run, outcome, failure-alert and cross-provider fallback suites on both paths pass.

Accepted edge: a provider that states an absurd reset (for example years away) parks the job until then; the failure notice shows that date, and a reset the scheduler cannot represent is ignored.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit 1ed6fd2)

Follow-ups: c27edf0 is required for restart catch-up and is its own later lane row. #207186 (22a3aec) concerns alternate notice delivery when the owner model cannot run; not needed to carry the reset timestamp.

Co-authored-by: RomneyDa <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
…t run (#207186)

Cron's fixed notices reach the owner conversation only as a session-event model turn. These are the auto-disabled notice (including `account-unavailable` from #207097) and the failure alert when no direct transport delivers it, which also covers repair fallbacks and the #207091 reset alert. The notice text becomes the turn's input row. When the conversation's own model cannot run, for example on the same signed-out account, the turn fails before it starts and writes no row. The user never sees why their automation stopped.

The Gateway cron adapter (`src/gateway/server-cron-targets.ts`) keeps the notice turn, because it is also the agent's repair turn (#188105). When a job notice's turn settles `failed` without starting and is not retained for retry, the adapter posts the same text through the existing session notice writer (`postSessionNotice`). This writes one transcript row, sends it to the conversation's channel unless the event is private, and adds the text to the next turn's context. No model turn is involved.

- It uses the captured target's store path and `deliver` policy.
- When the model works, nothing changes: the user sees the same row and the agent's reply.

Fable reviewed this adversarially. Applied: drop the extra flag (`jobId` already identifies job notices); skip retryable outcomes, because the retained event still owns its text; honor the captured target's `deliver` and store path.

Not applied:
- A re-check of requester authority before the post. Authority is decided once, when the turn target is captured. Repo rules forbid `assertCurrent()`-style re-checks.
- Always posting notices directly and hiding the repair input. That would change what users see when the model works, and would send a second channel message.

Accepted edge cases:
- A notice whose turn is `cancelled` by restart or supersession is not reposted.
- A session that does not exist yet (`createIfMissing`) and fails before creation has nowhere to post. The warning is logged.

- `src/gateway/server-cron-notice-delivery.test.ts` uses a real Gateway target resolver, a real session-event handoff and an owner model with no usable account. On the merge base, 0 visible notices. On this branch, exactly 1.
- Cron failure-alert, delivery-outcome, startup-notification, Gateway notification and failure-repair final-effect suites pass.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit 22a3aec)

Release adaptation: use the already-captured original target and lifecycle revision for fallback; retain stable repair turns and exception handling. Follow-ups: do not import direct-post redesign; the stable fallback neither posts twice nor follows a replacement session.

Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime impact:ux-friction User-facing flow adds avoidable confusion or support burden without fully blocking progress. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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