Skip to content

Pause automations after 3 consecutive failures (#160) - #1580

Merged
currentbits merged 1 commit into
mainfrom
coder/automation-failure-circuit-breaker-pause-7b0ed1
Oct 10, 2026
Merged

currentbits merged 1 commit into
mainfrom
coder/automation-failure-circuit-breaker-pause-7b0ed1

Conversation

@currentbits

Copy link
Copy Markdown
Owner

Closes #160.

What

  • Failures counted per automation and persisted (consecutiveFailures): a launch throw counts immediately; a run that launches and later ends with thread status failed is settled on the next scheduler tick via pendingRunThreadId (startRun resolves at launch, not at run end).
  • At 3 in a row the automation is set enabled=false, lastError reads "Paused after 3 consecutive failures. Last: …", and a desktop notification fires once.
  • Re-enabling with the existing toggle is the explicit re-enable: it resets the count and clears the error.
  • Any other finished status resets the streak; settling happens before due automations are picked, so a pause stops the next fire.
  • The Automations view refetches on open (it was boot-only), so a background pause shows as Off.

Not built

  • Optional cooldown and max-runs fields from the issue's fix direction. Schedules already fire at most hourly; say if either is wanted.
  • Threshold is a fixed 3, not per automation.
  • If an hourly run is still working when the next fires, the older run's outcome is not counted.

Tests

  • electron/test/automations.test.js: pause after 3 (launch throw + two runtime failures), pause blocks the next fire, single notify, re-enable resets; finished run resets streak.
  • npm run test:electron with CI-comparable env: 4519 pass / 0 fail / 0 cancelled.

🤖 Generated with Claude Code

Count launch throws immediately and runs that end with thread status
"failed" on the next scheduler tick. At 3 in a row the automation is
set enabled=false with a "Paused after N consecutive failures" error and
a desktop notification. Re-enabling resets the streak. The Automations
view refetches on open so a background pause is visible.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-10T08:39:26.522611Z e2fcf17 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@currentbits
currentbits merged commit 34c0d88 into main Oct 10, 2026
6 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e2fcf17ad4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/App.tsx
Comment on lines +463 to +465
useEffect(() => {
if (view === "automations") void refreshAutomations().catch(() => {});
}, [view, refreshAutomations]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep an open Automations view synchronized

Refresh while the Automations view remains open, not only when view changes. If the user is already on this view when the scheduler auto-pauses an automation, this effect never runs again because refreshAutomations is stable, and there is no automation-change subscription or polling elsewhere. The row therefore continues to show On and omits the pause reason until the user navigates away and back or performs another action.

Useful? React with 👍 / 👎.

Comment thread electron/automations.js
Comment on lines +120 to +122
if (pause && typeof ctx.notify === "function") {
try {
ctx.notify({ id, name: auto.name, message: lastError });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Pass the pause notifier through Run Now

Ensure the automations:runNow path supplies the same notifier as the scheduler. A launch failure from Run Now reaches this branch with the IPC context, but makeCtx does not expose notify; therefore, when a manual launch is the third consecutive failure, the automation is disabled without the promised desktop notification. Only scheduled failures receive the notifier passed directly to startScheduler in main.js.

Useful? React with 👍 / 👎.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Automation failure circuit breaker: pause after N consecutive failures

1 participant