Skip to content

centralize Responses retry policy#24131

Open
rhan-oai wants to merge 1 commit into
mainfrom
rhan/retry-fallback-refactor
Open

centralize Responses retry policy#24131
rhan-oai wants to merge 1 commit into
mainfrom
rhan/retry-fallback-refactor

Conversation

@rhan-oai
Copy link
Copy Markdown
Collaborator

@rhan-oai rhan-oai commented May 22, 2026

Why

#23951 added remote compaction v2 retries, but it left the retry and WS -> HTTPS fallback behavior duplicated between normal Responses turns and compaction. This follow-up centralizes the common retry handling so future changes to fallback, retry delay, retry notifications, and retry sleep do not have to be kept in sync across both callsites.

What changed

  • Added core/src/responses_retry.rs with a shared handler for retryable Responses stream errors.
  • Reused that handler from normal turn sampling and remote compaction v2.
  • Kept each callsite responsible for its retry budget: normal turns still use stream_max_retries, while compaction v2 still uses min(stream_max_retries, 2).
  • Preserved caller-specific behavior around non-retryable errors, context-window errors, usage-limit errors, and compact-specific final failure logging.

The shared handler now owns:

  • WS -> HTTPS fallback warning emission
  • retry delay selection, including server-requested stream retry delay
  • retry logging
  • first-WebSocket-retry notification suppression
  • Reconnecting... n/max stream-error notification
  • sleeping before the next retry attempt

Verification

  • cargo test -p codex-core remote_compact_v2
  • cargo test -p codex-core websocket_fallback
  • just fix -p codex-core

Did not run the full workspace test suite.

@rhan-oai rhan-oai requested a review from a team as a code owner May 22, 2026 19:09
@rhan-oai rhan-oai marked this pull request as draft May 22, 2026 19:30
@rhan-oai rhan-oai force-pushed the rhan/retry-fallback-refactor branch 2 times, most recently from eecab42 to c1cfb21 Compare May 22, 2026 20:48
@rhan-oai rhan-oai force-pushed the rhan/retry-fallback-refactor branch from c1cfb21 to 96d3b7d Compare May 22, 2026 21:24
@rhan-oai rhan-oai marked this pull request as ready for review May 22, 2026 21:42
@rhan-oai rhan-oai requested a review from jif-oai May 22, 2026 21:42
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