Skip to content

Commit d6f17d2

Browse files
byapparovclaude
andcommitted
fix(session): keep the max-retry guard as the exhausted branch (#121)
Restores the `attempt > SessionRetry.MAX_RETRY_ATTEMPTS` guard that the existing session.retry.max_attempts test asserts; behaviour unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent ad52624 commit d6f17d2

1 file changed

Lines changed: 15 additions & 14 deletions

File tree

‎packages/cli/src/session/processor.ts‎

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,21 @@ export namespace SessionProcessor {
400400
const retry = SessionRetry.retryable(error)
401401
if (retry !== undefined) {
402402
attempt++
403-
if (attempt <= SessionRetry.MAX_RETRY_ATTEMPTS) {
403+
if (attempt > SessionRetry.MAX_RETRY_ATTEMPTS) {
404+
log.error("max retry attempts reached", { attempt, retry })
405+
input.assistantMessage.error = MessageV2.APIError.isInstance(error)
406+
? new MessageV2.APIError({
407+
...error.data,
408+
message: `Max retry attempts (${SessionRetry.MAX_RETRY_ATTEMPTS}) reached: ${retry}`,
409+
}).toObject()
410+
: new NamedError.Unknown({
411+
message: `Max retry attempts (${SessionRetry.MAX_RETRY_ATTEMPTS}) reached: ${retry}`,
412+
}).toObject()
413+
await Bus.publish(Session.Event.Error, {
414+
sessionID: input.assistantMessage.sessionID,
415+
error: input.assistantMessage.error,
416+
})
417+
} else {
404418
const delay = SessionRetry.delay(attempt, error.name === "APIError" ? error : undefined)
405419
SessionStatus.set(input.sessionID, {
406420
type: "retry",
@@ -411,19 +425,6 @@ export namespace SessionProcessor {
411425
await SessionRetry.sleep(delay, input.abort).catch(() => {})
412426
continue
413427
}
414-
log.error("max retry attempts reached", { attempt, retry })
415-
input.assistantMessage.error = MessageV2.APIError.isInstance(error)
416-
? new MessageV2.APIError({
417-
...error.data,
418-
message: `Max retry attempts (${SessionRetry.MAX_RETRY_ATTEMPTS}) reached: ${retry}`,
419-
}).toObject()
420-
: new NamedError.Unknown({
421-
message: `Max retry attempts (${SessionRetry.MAX_RETRY_ATTEMPTS}) reached: ${retry}`,
422-
}).toObject()
423-
await Bus.publish(Session.Event.Error, {
424-
sessionID: input.assistantMessage.sessionID,
425-
error: input.assistantMessage.error,
426-
})
427428
}
428429
if (retry === undefined) {
429430
input.assistantMessage.error = error

0 commit comments

Comments
 (0)