Skip to content

Fix unbounded auto-retry loop when retry_max_attempts=0#48

Draft
Copilot wants to merge 2 commits intoadd-historyfrom
copilot/sub-pr-46-again
Draft

Fix unbounded auto-retry loop when retry_max_attempts=0#48
Copilot wants to merge 2 commits intoadd-historyfrom
copilot/sub-pr-46-again

Conversation

Copy link
Contributor

Copilot AI commented Mar 3, 2026

shouldRetry treated RetryMaxAttempts <= 0 as "unlimited retries," but retry_max_attempts=0 is a valid config value explicitly meaning "disabled." With auto_check_on_error=true, a repeatedly failing command would recurse infinitely through runSession → retrySession until stack/memory exhaustion.

Changes

  • internal/runner/runner.go: Fix shouldRetry condition — replace RetryMaxAttempts <= 0 || RetryCount < RetryMaxAttempts with RetryMaxAttempts > 0 && RetryCount < RetryMaxAttempts so 0 disables auto-retry rather than enabling unbounded retries
// Before — 0 treated as "always retry"
if r.cfg.History.RetryMaxAttempts <= 0 || session.RetryCount < r.cfg.History.RetryMaxAttempts {
    return true
}

// After — 0 means disabled
if r.cfg.History.RetryMaxAttempts > 0 && session.RetryCount < r.cfg.History.RetryMaxAttempts {
    return true
}
  • internal/runner/runner_test.go: Add test case asserting shouldRetry returns false when AutoCheckOnError=true but RetryMaxAttempts=0

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: kriserickson <325934+kriserickson@users.noreply.github.com>
Copilot AI changed the title [WIP] Add history and retry functionality to AI CLI Fix unbounded auto-retry loop when retry_max_attempts=0 Mar 3, 2026
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.

2 participants