Skip to content

Recover recurring automations after transient provider failures - #4332

Closed
ymichael wants to merge 3 commits into
mainfrom
bb/investigate-and-fix-the-reported-github-issue-thr_vpxkmesdx6
Closed

ymichael wants to merge 3 commits into
mainfrom
bb/investigate-and-fix-the-reported-github-issue-thr_vpxkmesdx6

Conversation

@ymichael

@ymichael ymichael commented Sep 25, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

The automations plugin treated a reused target thread in error as permanently unavailable even though core can start a new turn there. It disabled every automation targeting that thread. The generic three-failure pause also retired recurring automations after transient provider failures. A failed manual run was subsequently found to be mislabeled as a scheduled retry.

What changed

A scheduled retry creates a fresh automation run and can dispatch into the same non-deleted, non-archived error thread. Structured transient provider failures and transport/5xx dispatch errors retain exponential retry with a 30-minute cap; permanent and unclassified failures keep the existing pause rule. Missing, deleted, and archived targets remain terminal with an accurate reason. The plugin stores retryAt separately from nextRunAt, so UI and CLI label the next run as a retry only when one is actually scheduled. Manual run failures retain their error and normal schedule. The automation skill reference documents the policy. The plugin database migration adds retry_at and automation JSON responses include nullable retryAt; no server/daemon wire fields changed.

How you verified

  • pnpm exec turbo run typecheck test lint --filter=bb-plugin-automations: 142 tests, typecheck, and lint pass; lint reports five existing React warnings.
  • pnpm start:worktree --dryrun and persistent pnpm start:worktree at PR head 8a2c8bc285848afdc93b70cb5a75d5b6146326a9: 48 build tasks passed; server and host daemon started.
  • In an isolated source app, a seeded failed scheduled run left a target thread in error. The next real scheduled dispatch created a distinct run arun_hwmxfvxr8ji in the same thr_5m6aqhxs7t and succeeded. UI and CLI/API showed the failure reason and next retry.
  • A real manual script run arun_bp-p05scbcu failed. UI and CLI/API showed Next run and Last run failed, with retryAt: null and the original schedule intact.
  • Separate live fixtures at the previous head verified that archived, deleted, and missing targets disable automations with terminal reasons.
  • Live retry fixture is reset to a synthetic degraded state; live manual failure fixture shows the label fix. All required current-head CI checks passed.

Open review concern

Provider Retry can retry a failed provider turn while Automations schedules a separate fresh run. Its faster overload retry can succeed before the automation retry, which still runs later; a subscription-window retry can remain queued while Automations continues. Retry ownership needs resolution before merge.

Fixes #4166

AGENT GENERATED

@ymichael
ymichael marked this pull request as ready for review September 25, 2026 05:32
@davideiffert

Copy link
Copy Markdown

I tested the duplicate-retry risk you flagged (at 8a2c8bc). It's real, in two cases:

  1. Brief overload (529). Provider Retry recovers the turn in about 10 seconds, but Automations' own retry still fires at 30 seconds. One scheduled run sends twice.
  2. Usage limit with a 2-hour reset. Automations keeps retrying into the limit, and Provider Retry queues a retry for each attempt. 9 sends fire within a minute of the reset.

When Provider Retry skips a failure, Automations recovers it once, as intended.

Suggestion: let Provider Retry own retries, and have Automations skip its own retry when one is already queued or the thread has recovered.

Caveat: I tested with the real plugins and database, not a full live server. Case 2's "never cleaned up" part comes from reading the code, not running it.

AGENT GENERATED

@matthiasvongrundherr

Copy link
Copy Markdown
Contributor

We reproduced #4166 on bb 0.45.0 after an Account Pooler 429. A separate change is proposed to let provider clients wait inside the same turn for up to six hours on Pooler 429/502/503; it is not deployed. PR #4332 still needs to recover an automation after that wait expires or another terminal provider failure occurs. Its current head can duplicate dispatches when Provider Retry also acts, as documented in the existing PR comment. Before merge, please add a finite retry ceiling and regression tests for exhausted client wait, concurrent native retry, an explicit user pause, and a new automation run ID that stays bound through submit-result. We can provide a sanitized isolated reproduction.

@SawyerHood

Copy link
Copy Markdown
Collaborator

This is an automated message. We have closed this pull request because it has been open for more than two weeks.

@SawyerHood SawyerHood closed this Oct 10, 2026
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.

Recover recurring automations after transient provider errors in reused target threads

4 participants