Skip to content

Commit 2336288

Browse files
edyedy
authored andcommitted
fix(retry): limit max retry attempts to 10 and reduce max delay to 5 minutes
- Add RETRY_MAX_ATTEMPTS = 10 to prevent infinite retry loops - Reduce RETRY_MAX_DELAY from 24.8 days to 5 minutes (300_000ms) - Check attempt count in schedule step to stop after max attempts Previously, a session could retry 113 times over 56 minutes. Now it will stop after 10 attempts (max ~4.5 minutes total retry time).
1 parent e11f0ae commit 2336288

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

packages/opencode/src/session/retry.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ export type Retryable = {
2626
export const RETRY_INITIAL_DELAY = 2000
2727
export const RETRY_BACKOFF_FACTOR = 2
2828
export const RETRY_MAX_DELAY_NO_HEADERS = 30_000 // 30 seconds
29-
export const RETRY_MAX_DELAY = 2_147_483_647 // max 32-bit signed integer for setTimeout
29+
export const RETRY_MAX_DELAY = 300_000 // 5 minutes (was 24.8 days)
30+
export const RETRY_MAX_ATTEMPTS = 10 // Maximum retry attempts
3031

3132
function cap(ms: number) {
3233
return Math.min(ms, RETRY_MAX_DELAY)
@@ -180,6 +181,9 @@ export function policy(opts: {
180181
}) {
181182
return Schedule.fromStepWithMetadata(
182183
Effect.succeed((meta: Schedule.InputMetadata<unknown>) => {
184+
// Stop retrying after RETRY_MAX_ATTEMPTS
185+
if (meta.attempt >= RETRY_MAX_ATTEMPTS) return Cause.done(meta.attempt)
186+
183187
const error = opts.parse(meta.input)
184188
const retry = retryable(error, opts.provider)
185189
if (!retry) return Cause.done(meta.attempt)

0 commit comments

Comments
 (0)