Skip to content

fix: log retry count at INFO level (#2404)#3072

Open
kevinmalana wants to merge 1 commit intoopenai:mainfrom
kevinmalana:fix/2404-retry-logging
Open

fix: log retry count at INFO level (#2404)#3072
kevinmalana wants to merge 1 commit intoopenai:mainfrom
kevinmalana:fix/2404-retry-logging

Conversation

@kevinmalana
Copy link
Copy Markdown

Fixes #2404

Replace debug-only X retries left logs with a single INFO-level log that includes retry N of M in the existing Retrying request to ... message. No increase in log verbosity — same INFO call, richer context.

Changes

  • _sleep_for_retry() (sync): upgraded log.info() to include retries_taken and max_retries
  • _sleep_for_retry() (async): same change
  • Removed redundant log.debug("1 retry left") / log.debug("X retries left") calls

Both methods updated, covering both sync and async client paths.

Replace debug-only 'X retries left' logs with a single INFO-level log
that includes the retry count (retries_taken) and max_retries in the
existing 'Retrying request to ...' message. No increase in log verbosity,
just richer context at INFO level.
@kevinmalana kevinmalana requested a review from a team as a code owner April 9, 2026 10:07
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0aa86ad08f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


timeout = self._calculate_retry_timeout(remaining_retries, options, response.headers if response else None)
log.info("Retrying request to %s in %f seconds", options.url, timeout)
log.info("Retrying request to %s in %f seconds (retry %d of %d)", options.url, timeout, retries_taken, max_retries)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Report the next retry attempt, not completed retries

This log message is off by one because _sleep_for_retry() is called before the next attempt starts, but it prints retries_taken (the number of retries already completed). On the first retry path (retries_taken == 0), users will see retry 0 of N, and the final retry is logged as retry N-1 of N, which makes the new INFO-level retry counter misleading for troubleshooting in both sync and async clients. Log retries_taken + 1 (or equivalent) to reflect the retry that is about to happen.

Useful? React with 👍 / 👎.

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.

Log number of retries at INFO level

1 participant