Skip to content

fix(retry): extend transient-5xx replay budget to openai-responses passthrough - #4800

Open
Yum-wu wants to merge 4 commits into
lidge-jun:devfrom
Yum-wu:fix/transient-5xx-responses
Open

Yum-wu wants to merge 4 commits into
lidge-jun:devfrom
Yum-wu:fix/transient-5xx-responses

Conversation

@Yum-wu

@Yum-wu Yum-wu commented Sep 16, 2026

Copy link
Copy Markdown

Summary

Extends the transient-5xx replay budget (transientRetryOn5xx) to key-auth openai-responses passthrough providers in addition to openai-chat.

Without this gate allowance, transientRetryPolicyFor returns null for openai-responses providers, causing fast transient 502/503 responses on the native /responses passthrough lane (e.g. opencode-zen/go) to terminate the request on the very first send with an "interrupted with no error" experience on client side instead of using the configured send budget.

Changes

  • src/providers/key-failover.ts: allow openai-responses in transientRetryPolicyFor alongside openai-chat. Non-key auth modes (oauth, forward, local) and other generic adapters remain rejected fail-closed.
  • tests/providers/upstream-transient-retry.test.ts: update qualification tests to assert that openai-responses with key auth qualifies for transient 5xx retry while non-key auth and other adapters remain excluded.

Verification

  • Ran bun test tests/providers/upstream-transient-retry.test.ts: 18 pass / 0 fail (66 assertions passed).

Review readiness checklist

This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:

  • All CI tests are green on my local testing.

  • I pushed my PR to the latest dev commit.

  • I resolved all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

Summary by CodeRabbit

  • Bug Fixes
    • Transient retries for temporary server errors now apply to providers using both supported OpenAI adapters.
    • Existing restrictions for unsupported providers and authentication modes remain unchanged.

@coderabbitai

coderabbitai Bot commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: c54a0ee8-90d0-4b5c-af6a-0528caff9ffe

📥 Commits

Reviewing files that changed from the base of the PR and between 533cc43 and af985d3.

📒 Files selected for processing (2)
  • src/providers/key-failover.ts
  • tests/providers/upstream-transient-retry.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

The transient retry policy now supports key-authenticated openai-responses passthrough providers in addition to openai-chat. Tests cover supported adapters, default authentication, and existing exclusions.

Changes

Transient retry policy

Layer / File(s) Summary
Expand the adapter eligibility gate
src/providers/key-failover.ts
The documentation at line 309 and adapter gate at line 319 now include openai-responses.
Validate provider eligibility
tests/providers/upstream-transient-retry.test.ts
Lines 42–60 verify openai-chat and openai-responses eligibility, omitted authMode defaults, and continued rejection of anthropic, google, OAuth, forward, and local authentication.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to af985

The change narrowly expands transient retry eligibility for key-authenticated OpenAI Responses providers while retaining existing exclusions, with no identified merge-blocking risk.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: extending transient 5xx retry behavior to openai-responses passthrough providers.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the bug Something isn't working label Sep 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Deterministic PR hygiene checks passed.

@github-actions

github-actions Bot commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

✅ READY

  • all PR quality gates passed; the review readiness checklist is complete.

Review readiness checklist

  • ✅ All CI tests are green on my local testing.
  • ✅ I pushed my PR to the latest dev commit.
  • ✅ I resolved all correct Codex and CodeRabbit findings.
  • ✅ My PR is ready for review.

4/4 boxes ticked.

This pull request is already Ready for Review.
The review-ready label marks this PR as ready; review automation runs independently.
Maintainers: @lidge-jun @Ingwannu

@github-actions
github-actions Bot marked this pull request as draft September 16, 2026 10:20
@Yum-wu
Yum-wu marked this pull request as ready for review September 16, 2026 10:53
@lidge-jun

Copy link
Copy Markdown
Owner

리뷰 · 우선순위 72 / 80

이 PR(#4800)은 Yum-wu가 올린 아주 좁은 retry 게이트 확장이다. 바꾸는 파일은 src/providers/key-failover.tstests/providers/upstream-transient-retry.test.ts 두 개뿐이고(+10/−4), 베이스는 지금 dev tip dc9d1fabc(package 2.57.0, #4796)에 맞춰져 있다. types.ts/config.ts 분할과 무관하고 close-don't-rebase 대상도 아니다.

지금 dev에서 transientRetryPolicyFor는 정책이 켜져 있어도 adapter === "openai-chat"이고 key-auth일 때만 정책을 돌려준다. 그런데 Responses 쪽은 이미 이 함수를 쓰고 있다. src/server/responses/adapter-dispatch.tsadapter-continuation.tstransientRetryPolicyFor(route.provider) 결과가 있으면 fetchWithTransientRetry로 가고, 없으면 reset-only로 간다. 그래서 key-auth openai-responses 제공자(예: opencode-zen/go 같은 네이티브 /responses 패스스루)에 transientRetryOn5xx를 켜도 게이트가 null을 반환해, 빠른 502/503이 첫 전송에서 끊기고 클라이언트는 “interrupted with no error”에 가까운 경험을 본다. chat 레인(chat-native.ts)만 정책이 살아 있는 상태다.

고치는 한 줄이 핵심이다. 어댑터 조건을 openai-chat || openai-responses로 넓히고, 주석도 “chat only”에서 두 패스스루로 고친다. authMode fail-closed(key 또는 생략 기본값만 허용, oauth/forward/local 거절)는 그대로다. 테스트는 제외 목록에서 openai-responses를 빼고, key-auth responses가 기본 attempts 3으로 qualify하는지와 omitted authMode 기본값 케이스까지 잠근다. anthropic/google과 non-key는 계속 null이다.

현재 dev 방향과 맞춰 보면, 바로 아래 tip 쪽에 #4798(모호한 reset replay 거절)·#4797(요청을 못 받는 계정 선택 중지) 같은 fail-closed retry/계정 가드가 있다. 이 PR은 그 옆줄에서 “이미 배선된 Responses transient 경로의 어댑터 게이트만 열어 주는” 수정이라 맞물린다. #2643이 chat에 넣었던 opt-in을 responses에도 대칭으로 맞추는 셈이다. 체크리스트 4/4·review-ready·로컬 upstream-transient-retry 18 pass를 본문에 적었다. 범위가 한 함수라 회귀면이 작고, 점수에서 조금 깎는 지점은 dispatch 쪽 옛 주석 미갱신과 “responses 재전송이 chat과 같은 안전 가정인지” 확인이다.

라인 src/providers/key-failover.ts transientRetryPolicyFor 어댑터 게이트 - chat과 responses만 열고 나머지는 fail-closed로 두는 선택은 #2643 범위 확장으로 타당하다. 다만 generic key-auth 어댑터가 실수로 들어가지 않게 테스트 제외 목록(anthropic/google)이 계속 있는지가 중요하고, 이번 PR은 그걸 유지했다.
라인 src/server/responses/adapter-dispatch.ts #2643 주석 - “opted-in key-auth openai-chat”이라고만 적혀 있다. 게이트가 바뀌면 이 주석도 responses를 포함하도록 같이 고치지 않으면 다음 기여자가 chat-only로 오해할 수 있다. 이 PR diff에는 그 주석 변경이 없다.
경로/심볼 Responses 본문 재전송 - initial dispatch는 builtInitialRequest를 다시 보내므로 chat과 비슷한 replayable fetch 가정이다. 이미 bytes를 읽기 시작한 스트림 mid-body 5xx까지 같은 예산으로 삼키는지는 기존 fetchWithTransientRetry 계약에 맡긴다. 이번 PR은 게이트만 열므로 그 계약을 바꾸지는 않는다.
경로/심볼 #4798과의 경계 - 최근 tip 근처 #4798은 모호한 reset replay를 거절한다. 이 PR의 transient-5xx는 다른 레이어(정책 opt-in 5xx)라 직접 충돌하진 않지만, responses 패스스루에서 “언제 재시도하고 언제 거절할지” 문서/주석이 한곳에 모여 있으면 유지가 쉽다.
경로/심볼 설정 기본값 - transientRetryOn5xx는 여전히 opt-in이다. 게이트만 넓혀도 기본 제공자 동작은 안 바뀌고, 켠 사람만 responses에서 예산이 살아난다. 그 점이 회귀를 작게 만든다.
경로/심볼 CI - 로컬 단위 테스트 통과만으로 머지하지 말고 exact-head 호스티드 CI 초록을 기다린다.

메인테이너의 판단이 필요한 지점

  • [Feature]: opt-in transient-5xx retry for key-auth providers on openai-chat adapter #2643 당시 chat-only가 “responses replay가 더 위험해서”였는지, 단순히 1차 범위였는지. 후자라면 이번 확장이 맞고, 전자라면 responses는 별도 가드가 더 필요할 수 있다.
  • adapter-dispatch.ts / adapter-continuation.ts의 chat-only 주석을 이 PR에 포함해 고칠지, 후속 한 줄 PR로 둘지.
  • key-auth openai-responses + transientRetryOn5xx를 쓰는 실제 제공자(예: zen/go)에서 502/503 재시도가 체감되는지 머지 전 스모크할지.
  • 프리뷰 배포는 계획에 없다.

너의 추천
머지 후보로 둔다. 게이트 한 줄 + 테스트 대칭이 핵심이고, 이미 Responses 경로가 이 정책을 기다리고 있어서 “죽은 설정”을 살리는 수정이다. 가능하면 같은 PR에 dispatch/continuation의 #2643 주석만 responses 포함으로 고치고, exact-head CI 초록 후 랜딩한다. types/config 분할·중복 close 대상 아님.

이 댓글은 grok-bot이 작성했습니다

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working review-ready

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants