Repository navigation
Report provider errors on thread.failed and stop workflow retries after provider retry gives up - #8149
Merged
ymichael merged 2 commits intoNov 25, 2026
Conversation
A workflow worker that died on a provider 429 reported only "Workflow worker failed": thread.failed read its error from system/error rows alone, while provider failures are stored as provider/error. The empty error also stopped the workflows plugin's transient retry, which classifies the error text. getLastThreadErrorMessage now reads the newest system/error or provider/error since the failed turn's request, and formats a provider/error as its detail (else message) followed by its category, HTTP status and provider code. Errors from earlier turns no longer leak into a later failure. Co-Authored-By: Claude Opus 5.5 <[email protected]>
When provider retry declines a failed worker turn as attempts-exhausted, beyond-maximum-wait, or pool-unavailable, a replacement worker would hit the same limit, and each replacement thread brings a fresh provider retry budget. The retry handoff now reads the decline reason and returns give-up for those, and runAgentCall fails the call instead of using its own retries. Other declines, such as a rate limit with no reset time, still fall back to the workflow's retries. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
deleted the
bb/1914-a-rate-limited-workflow-call-reports-only-w-thr_92kcbujujj
branch
November 25, 2026 04:30
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
When a workflow worker failed on a provider 429,
bb workflows statusandhistoryreported onlyWorkflow worker failed. The server built thethread.failed(andexperimental_thread.settled)errorfromsystem/errorrows alone (getLastThreadErrorMessage→getLatestThreadSystemErrorEventRow). Providers record their failures asprovider/error, so plugins goterror: nulland the workflows plugin fell back to its generic string. The workflows plugin decides whether to retry by classifying that text (isRetryableProviderFailure), so the empty error also turned off its two transient retries. That is the second effect in gaodes' 0.50.1 Pi report: provider-retry declines a Pi 429 that has no reset time (no-rate-limit-state), and the workflow's own retry never matched either. The lookup also covered the whole thread rather than the failed turn, so a failure could report an older turn'ssystem/error.What changed
packages/db/src/data/events.ts:getLatestThreadSystemErrorEventRowbecomesgetLatestThreadErrorEventRow. It returns the newestsystem/errororprovider/errorafter a given sequence and uses the existingevents_thread_type_sequence_idxindex, so there is no new index or migration. The query-cost case inpackages/db/scripts/query-costs/events-cases.tsis updated to match.apps/server/src/services/threads/thread-data.ts:getLastThreadErrorMessageonly looks at errors recorded since the failed turn's request (getLastStoredTurnRequestEvent). Aprovider/erroris formatted as itsdetail(ormessageif there is no detail), followed by itserrorInfocategory, HTTP status and provider code, e.g.429: {"code":"1302","message":"Rate limit reached for requests"} (rate-limit, HTTP 429). Asystem/errorstill returns its message.rate-limit/HTTP 429, which it already treats as retryable.plugins/workflows/src/retry-handoff.ts,service.ts: with its own retry now working, the workflow would also retry failures provider-retry had deliberately given up on. Each replacement worker is a new thread with a fresh provider-retry budget, so retries multiplied (persistent overloads: 3 workers × 5 turns). The handoff now reads provider-retry's decline reason.attempts-exhausted,beyond-maximum-waitandpool-unavailablereturngive-up, and the call fails without a replacement. Other declines, such asno-rate-limit-state(this issue's Pi 429), still fall back to the workflow's own retries. The README and the workflows skill'sruns.mddescribe this.thread.failedpayload is still{ thread, error: string | null }. There is no SDK or plugin API change and noHOST_DAEMON_PROTOCOL_VERSIONbump.Not in this PR:
Workflow worker is in an error state, without the cause. Fixing that needs a way for plugins to read a thread's last error.How you verified
New tests, both of which fail on main:
apps/server/test/services/plugins/plugin-thread-events.test.tsdelivers thread.failed with the failed turn's provider/error and its classification: a Pi-shaped sequence of 429s markedwillRetry, then a final 429, after an older turn'ssystem/error. On main it received"earlier turn".does not report an earlier turn's error for a failure without one: expectsnull. On main it received"earlier turn".plugins/workflows/src/service-policy.test.ts:Provider error (rate-limit, HTTP 429)is classed as retryable.fails the call without a replacement when provider retry declined it as %s, forattempts-exhausted,beyond-maximum-waitandpool-unavailable. All three fail without the handoff change: the workflow started a second worker.no-rate-limit-statedecline, which still starts a replacement.Live end-to-end run on
pnpm start:worktree, built once without and once with this change. Setup: Pi with a sandboxedPI_CODING_AGENT_DIRwhose provider points at a local endpoint that returns429 {"code":"1302","message":"Rate limit reached for requests"}, and a one-call workflowagent(..., { provider: "pi", model: "fakezai/glm-fake" }). The worker's events matched the report: three 429s markedwillRetry, a final 429, thenturn/completed failed.bb provider-retry explainreturneddecline / no-rate-limit-statein both runs.errorWorkflow worker failed429: {"code":"1302","message":"Rate limit reached for requests"} (rate-limit, HTTP 429)providerRetryAttemptsLive check of the give-up path, on the same setup with the endpoint returning
529 {"type":"overloaded_error"}: provider-retry retried the turn 4 times inside the one worker (5 turns, 24 provider requests), then recordeddecline / attempts-exhausted. The call failed after 244 s with529: {"type":"overloaded_error","message":"Overloaded"} (overloaded, HTTP 529),providerRetryAttempts0 and no second worker. The server log showsAgent call 1 is not retried: provider retry declined it (attempts-exhausted). Re-running the Pi 429 case on this build still gaveproviderRetryAttempts2 and the 429 error.Commands:
Fixes #1914
🤖 Generated with Claude Code