Skip to content

fix(sdk): Retry hunks when the runtime reports a provider error - #601

Merged
dcramer merged 2 commits into
mainfrom
fix/retry-provider-error-results
Dec 2, 2026
Merged

dcramer merged 2 commits into
mainfrom
fix/retry-provider-error-results

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

When a runtime result comes back with status provider_error, the hunk failed right away. Only thrown errors went through the retry loop, so a transient upstream failure, such as "Internal error during token generation", lost the whole hunk.

Those results now go through the same retry and backoff as thrown provider errors. The last attempt still reports the failure and counts toward the circuit breaker, so a sustained outage still stops the run.

The "All N chunks failed to analyze" error now also lists each failure's code and message. Before, it showed only auth guidance, even when the real cause was something else.

via @dcramer.

--

View Session [Sentry]

A runtime result with status provider_error failed the hunk at once.
Only thrown errors went through the retry loop. Transient provider
failures now retry with the same backoff, and the last attempt still
reports the failure and counts toward the circuit breaker.

The all-chunks-failed error now also lists each failure's code and
message, so it no longer hides the cause behind auth guidance.

Co-Authored-By: David Cramer <23610+dcramer@users.noreply.github.com>
@vercel

vercel Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
warden-prod Ready Ready Preview Dec 2, 2026 3:37am UTC

Request Review

@dcramer
dcramer enabled auto-merge (squash) December 2, 2026 03:37
@dcramer
dcramer merged commit 4b2034f into main Dec 2, 2026
19 checks passed
@dcramer
dcramer deleted the fix/retry-provider-error-results branch December 2, 2026 03:39
import { getHunkLineRange, type HunkWithContext } from '../diff/index.js';
import { Sentry, emitExtractionMetrics, emitRetryMetric, emitSkillMetrics, ensureLocalTracing } from '../sentry.js';
import { SkillRunnerError, WardenAuthenticationError, isRetryableError, isAuthenticationError, isAuthenticationErrorMessage, isSubprocessError, classifyError, mapExtractionErrorCode, sanitizeErrorMessage, type ProviderErrorContext } from './errors.js';
import { ProviderResultError, SkillRunnerError, WardenAuthenticationError, isRetryableError, isAuthenticationError, isAuthenticationErrorMessage, isSubprocessError, classifyError, mapExtractionErrorCode, sanitizeErrorMessage, type ProviderErrorContext } from './errors.js';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ProviderResultError with IPC substrings skips retry and becomes auth failure

Retryable provider_error results are thrown as ProviderResultError, but the catch path runs isSubprocessError before isRetryableError, so messages containing ECONNRESET/EPIPE/etc. abort as auth instead of retrying. Handle ProviderResultError before the subprocess/auth converters.

Evidence
  • On non-final attempts, provider_error becomes throw new ProviderResultError(failureMessage) where failureMessage embeds resultMessage.errors (analyze.ts ~504).
  • The hunk catch path checks isSubprocessError(error) before isRetryableError(error) (analyze.ts ~662–680).
  • isSubprocessError is true for any Error whose message includes ECONNRESET/EPIPE/ECONNREFUSED/ENOTCONN (errors.ts, covered by errors.test.ts).
  • That branch records auth_failed, opens the circuit, and throws WardenAuthenticationError, so the intended ProviderResultError retry never runs.
  • Before this change, the same provider_error result returned failureCode: 'provider_unavailable' without entering that catch path.

Identified by Warden · code-review · 4FJ-4QF

This branch was successfully deployed

2 active deployments
Preview – warden-prod — 19e6faf3 Deployed Dec 2, 2026 by vercel[bot]
Preview – warden — 19e6faf3 Deployed Dec 2, 2026 by vercel[bot]
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.

1 participant