Repository navigation
Stop provider failures from retiring recurring automations - #6677
Merged
Merged
Conversation
A recurring automation whose target thread was left in `error` paused itself on the next run, and three failures in a row paused any automation. Provider retry and Automations also retried the same failure independently, so one failed turn could run the automation prompt twice. - Core records the plugin that sent each turn on its turn request, and `turn.failed` reports it as `originPluginId`. - Provider retry asks that plugin through `provider-retry.v1.consent` before scheduling a retry. A decline skips the retry and shows in `explain`; a missing, failing, or slow answer keeps the retry. - Automations declines retries of scheduled runs of recurring automations, re-prompts a target thread in `error`, never pauses on failures, and makes at most two quick retries per failure streak, each capped at the next scheduled run. Fixes #4166 Co-Authored-By: Claude Opus 5.5 <[email protected]>
An automation prompt sent into a target thread that is already running joins that turn. Declining its retry would also drop the retry of the work it joined, so Automations now allows those and declines only when the failed request started its own turn. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
added a commit
that referenced
this pull request
Oct 30, 2026
## Human comments ## What was wrong The sidebar PR badge tooltip (`plugins/github-pr-status/ui/PullRequestRowMetadata.tsx`) styled its status line with `text-muted-foreground`. That token is a text tone for the `--canvas` surface, but `TooltipContent` draws an inverted `bg-primary` fill, so the muted tone landed next to the fill: 1.15:1 in the Default dark theme and 1.94:1 in light. It was the only tooltip in the repo putting muted/subtle text on the tooltip fill. ## What changed - `PullRequestRowMetadata.tsx`: the status line uses `text-primary-foreground/75`, a tone derived from the tooltip's own foreground, so it stays a step below the title while following any theme's `--primary-foreground`. - Plugin-local fix (the issue's first option). I did not override `--muted-foreground` in shared `TooltipContent`, since no other tooltip needs it. ## How you verified - `pnpm exec turbo run prepare:bundled typecheck test --filter=bb-plugin-bb--github-pr-status`: pass, 181/181 tests; the bundled CSS contains the scoped `text-primary-foreground/75` rule. - `pnpm start:worktree` with a fresh data dir, built once with the old class and once with the fix. Projects and threads point at shallow clones of two open-PR branches (#6677 checks failing, #6679 checks running), with `threadRowMetadata` and `showRowMetadata` on. In Chromium I hovered the real sidebar badge and read computed styles plus WCAG 2 contrast against the tooltip fill: | Mode | Line | Before | After | |---|---|---|---| | Dark | title | 9.98:1 | 9.98:1 | | Dark | status | **1.15:1** | **5.59:1** | | Light | title | 15.13:1 | 15.13:1 | | Light | status | **1.94:1** | **9.10:1** | - Source CLI against that server: `bb pull-request show` (text and `--json`) for both environments, `bb thread list/show`, `bb settings show`, `bb thread-list prefs get`, `bb host list` all behave as before. The composer's PR segment and the sidebar badge render unchanged. - Not run: desktop (Electron) app and custom themes. Fixes #6674 > AGENT GENERATED 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
ymichael
force-pushed
the
bb/fix-issue-4166-in-bb-thr_ie955qmysd
branch
from
October 30, 2026 18:14
c472764 to
865131b
Compare
ymichael
added a commit
that referenced
this pull request
Nov 18, 2026
## Human comments ## What was wrong Three plugins could each re-run one failed turn: provider retry, Automations, and Workflows. Their handoff was the `provider-retry.v1.consent` RPC. The sending plugin had to answer "decline" within provider retry's 5 s timeout, and any miss counted as consent. - **Automations** misses when the run has no thread ID yet because the spawn response is still pending (the [report](https://get-bb.github.io/reports/issues/7708.html) forces this), or when its answer is slow, as on a Mac waking from DarkWake. 0.48.x has no handler at all (#6677 first shipped in 0.49.0, and the reporter is on 0.48). When it misses, provider retry resumes the thread while the automation's 30 s quick retry spawns a fresh thread. - **Workflows** has the same timeout miss. It then replaces the worker 1 s later in the same environment. ## What changed One rule now covers every retrier: provider retry owns a failed turn, and a plugin that re-runs failed work stands down while a retry is in hand. The sync point is provider retry's recorded decision, not timing. - **provider-retry**: no longer asks senders for consent. It records its decision for each `turn.failed`, after queueing any retry, and `decision.get` is now discoverable. Removed: the consent ask, `declined-by-sender`, the consent field in diagnostics and `explain`, and `retryConsent*` from the contract. - **`retry-handoff.ts`**, an identical copy in `plugins/automations/src` and `plugins/workflows/src` (plugins stay self-contained). `readRetryHandoff` reads the steps below in this order: 1. The thread. Gone or archived → re-run. 2. Provider retry's decision. Read before the queue, because provider retry queues the row and then records the decision. Reading the queue first loses that race: the live check below hit it, and the "lands mid-check" rows guard it. 3. The queue. Any `retry` row → stand down. This covers provider retry and core's restart resume (`bb restarted`), and the reason names whichever it was. 4. The latest turn request. The thread isn't in `error` and the request carries `retryOfRequestId` → stand down (overload retries fire 5–10 s out). 5. Undecided failure → wait. Then re-run once the decision arrives, after 60 s, or right away when provider retry is not installed. - **Automations** (`sweep.ts`): before a quick retry of a failed scheduled run, a wait leaves the slot due (the next sweep is 10 s later). A stand-down records a `skipped` run, `failed run <id> is not re-run: a retry (<reason>) is queued in thread <id>`, and `next_run_at` moves to the next scheduled time. Automations' consent handler is deleted. If the handoff can't be read (for example `decision.get` times out), the sweep treats it as undecided: it waits while the failure is under 60 s old, then re-runs, as Workflows does. Before, the error escaped the sweep and the automation stayed due without ever running. - **Workflows** (`service.ts`, `data.ts`): when a worker's `thread.failed` fails a call, the call polls the handoff every second. - On stand-down, `reopenFailedCallOnWorker` sets the call back to `running` on the same worker. It then waits for that worker's result instead of spawning a replacement. A later failure of that worker goes through the handoff again. - While a handoff is pending, worker cleanup skips the worker. Without that, the call sitting briefly in `failed` makes cleanup archive the worker, which failed the run (found live). - Workflows' consent handler is deleted. - **Docs**: provider-retry `SKILL.md`, automations `script-runtime.md`, workflows `runs.md`, and the `turn.failed` entry in `docs/api_to_audit.md`. No wire, SDK, or `HOST_DAEMON_PROTOCOL_VERSION` changes. **The remaining bound:** a plugin re-runs on its own only if provider retry has not recorded a decision within 60 s of the failure. Provider retry's handler makes at most a few RPCs with 5 s timeouts, so this needs a stuck or crashed handler, or a process suspended across the window. Another gap: if `threads.retry` throws, provider retry records no decision, and the plugin re-runs after 60 s. **Left out:** - If the Workflows plugin restarts during a handed-off wait, `reconcileRunningCalls` fails the call ("worker is in an error state"), and the restarted run's live suffix spawns a new worker while the old worker's queued retry still fires. Plugin restart already replays runs from scratch, and fixing that path means changing replay semantics. - If a turn fails before its spawn response returns, the run stays `running` until restart unless a provider retry finishes it. That's pre-existing and separate. On the #7542 pointer: it doesn't affect this. #7542 changes the daemon `turn.submit` target to `auto`, but the persisted `client/turn/requested` target is still `new-turn`, as the live check below confirmed. ## How you verified Live on main first, with `pnpm start:worktree`, Claude Code pointed at a local 503 stub (`CLAUDE_CODE_MAX_RETRIES=0`), and real automations: - consent declined, and the automation's quick retry spawned a second thread. A double retry needs the consent miss, which the report's harness reproduces; - a target-thread send recorded target `new-turn`. Live with this branch, same setup: - **Automation:** one thread. Provider retry `Scheduled …: Provider unavailable`. The run recorded `skipped — failed run arun_… is not re-run: a retry (Provider unavailable) is queued in thread thr_…`, and `nextRunAt` moved to the next hourly slot. - **Automation, declined:** a 400 stub gave `not-retryable`. The automation read the decision through `decision.get` and re-ran on its quick retry. - **Workflows:** one `agent()` call. The worker failed, provider retry queued a retry, and the call stayed `running` on the same worker ("keeps worker … a retry (Provider unavailable) is queued"). After two more provider-retry failures it was still one thread, still `running`, with attempt 3 queued and the worker not archived. The first two live runs here exposed the read-order race and the cleanup race above, and both fixes are in this branch. Tests: the same handoff table runs in `plugins/automations/src/server-harness.test.ts` (real sweep service) and `plugins/workflows/src/service-policy.test.ts` (real workflow service): - six rows: provider retry queued, restart resume queued, retry already ran, retry lands mid-check, provider retry declined, provider retry not installed; - plus "waits for provider retry to decide" in both, which in Workflows also asserts the worker is not archived during the wait; - plus "re-runs after a minute without a decision" and "waits while provider retry's decision cannot be read, then re-runs after a minute" in Automations; - provider-retry: "publishes a failure's decision only once its retry is queued", plus discoverability. Against main's `sweep.ts` / `service.ts`, the four stand-down cases fail in both plugins and the re-run controls pass. Against the old read order, the mid-check row fails in both. Without the cleanup guard, the Workflows wait test fails (`expected [ 'child-1' ] to not include 'child-1'`). Without the read-error catch in `sweep.ts`, the unreadable-decision test fails (`expected [ [ { …(10) } ] ] to have a length of 2 but got 1`): the automation never re-runs. `pnpm exec turbo run typecheck lint test --filter=bb-plugin-automations --filter=bb-plugin-provider-retry --filter=bb-plugin-workflows`: 16/16 tasks, 165 + 27 + 273 tests. The lint warnings are pre-existing in each plugin's `app.tsx`. Fixes #7708 🤖 Generated with [Claude Code](https://claude.com/claude-code) > AGENT GENERATED --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
Human comments
What was wrong
A recurring automation that reuses a target thread treated a thread in
erroras unusable (unusableThreadReasoninplugins/automations/src/run.ts). When a run's turn failed, the 30-second retry found the thread inerrorand paused every automation targeting it. Separately, three consecutive failures paused any automation, so a provider outage of about 90 seconds retired recurring jobs. Provider retry and Automations also retried the same failure independently: provider retry replayed the failed turn while Automations started a fresh run, so the automation prompt could run twice.What changed
apps/server,@bb/domain)originPluginId), on every dispatcher path: inline sends, released queued messages, a spawned thread's first turn, and reprovision. Core notices and retries record none.PluginTurnFailedEvent.originPluginId: string | null. SDK 0.6.106;docs/api_to_audit.mdand the plugin authoring guide updated.provider-retry.v1.consentRPC. A decline skips the retry andbb provider-retry explainshowsdeclined-by-sender (<plugin>: <reason>). A missing, failing, or slow answer keeps the retry.new-turn/thread-start, matched by request id viathreads.events.list). Allows one-off and manual runs, and prompts that joined a turn already running in the target thread, since that retry resumes the joined work. Re-prompts a target thread inerroras a new run. Failures never pause; at most two quick retries (30 s, 60 s) per failure streak, each capped at the next scheduled run. Missing, deleted, or archived targets and unavailable projects still disable the automation.Behaviour by plugin state:
No daemon wire change: turn requests are stored server-side, so
HOST_DAEMON_PROTOCOL_VERSIONis unchanged.How you verified
apps/server/test/threads/dispatcher-paths.test.ts:originPluginIdis recorded on an inline send, a released queued message, and a plugin-spawned thread's first turn, and reported byturn.failed; null for a user send. Three of these fail when the field is not written.plugins/provider-retry/server.test.ts: sender declines (no retry, explained), allows, throws, discovery fails, sender without the method, user-sent turn, and a failure that is not retried anyway.plugins/automations: consent answers (recurring scheduled run that started its own turn, a prompt that joined a running turn, a mismatched or unreadable request, manual run, one-off, latest run on a shared thread, unknown thread), plus a harness test through the sweep,thread.failed,events.listand the RPC; failing recurring automation stays enabled through five failures with two quick retries then its schedule; quick retry capped at the next scheduled run; target thread inerroris re-prompted (fails without the fix).pnpm exec turbo run typecheck lint --filter='...[origin/main]'(153/153), and tests for@bb/server(3,778),@bb/domain,@get-bb/plugin-sdk, automations, provider-retry and bb-guide.check-plugin-sdk-version.mjspasses.Fixes #4166
🤖 Generated with Claude Code