Skip to content

[Bug]: retryOnReset replacements never spent for key-auth openai-responses providers — every pre-header reset answers synthetic 429 (v2.99.0) #8453

Closed

Description

@jingyihu818

Client or integration

Codex App (desktop) on Windows 11, sending POST /v1/responses to OpenCodex over loopback HTTP/SSE.

Area

Proxy / routing — upstream HTTP transport, connection-reset handling, providers.<name>.retryOnReset.

Summary

On v2.99.0 I have three providers configured with an identical, explicit opt-in:

"retryOnReset": { "enabled": true, "replacements": 2 }

One is the canonical openai provider (adapter: "openai-responses", authMode: "forward"). The other two are key-auth openai-responses providers with a custom baseUrl (no authMode).

For the same kind of failure — the upstream closing the connection before any response byte, recorded as failureStage: "headers-only", failureCause: "transport-ambiguous" — the canonical provider spends the allowance and the key-auth providers never do:

provider 429 records today sendCount recoveryKinds
canonical openai (forward auth) 41 3 (all 41) ["connection-reset"]
key-auth openai-responses A 49 1 (48), 2 (1, ["transient-5xx"]) []
key-auth openai-responses B 30 1 (all 30) []

Canonical: 41/41 got both replacements. Key-auth: 78/78 got none. The terminal response is the same synthetic 429 upstream_reset_replay_refused in every case, so the client shows exceeded retry limit, last status: 429 Too Many Requests after ~16 s on a key-auth turn and after ~48 s on the canonical one.

This is not a complaint that the proxy refused an ambiguous resend — that fail-closed default is right. It is that an operator who opted in cannot tell why the opt-in did not apply on a non-canonical provider row.

Reproduction

Intermittent in production, deterministic in shape: any pre-header connection reset from a key-auth openai-responses provider reproduces it (0 of 78 such resets today spent a replacement).

The cleanest observation is a single conversationId that was retried alternately between the two provider kinds within 90 seconds, same client, same turn content:

18:24:27  key-auth A            429  sendCount=1  durationMs=15790   recoveryKinds=[]
18:24:43  canonical openai      429  sendCount=3  durationMs=47752   recoveryKinds=["connection-reset"]
18:25:16  key-auth A            429  sendCount=1  durationMs=15782   recoveryKinds=[]

Same conversation, same tool catalog, same body shape; only the provider row differs. Every one of the 120 429 records today has exactly one entry in attempts, so no other leg of the logical request could have spent the request's allowance.

What I verified in the code (so this is not "the config was not loaded")

Reading the installed 2.99.0 sources at D:\DevTools\npm-global\node_modules\@bitkyc08\opencodex and calling the shipped functions under the same bun runtime the service uses:

  1. loadConfig() keeps retryOnReset on all three rows; routedProviderConfig() spreads the row (src/providers/routed-config.ts:113-144, :210+), so the field survives request-time resolution.
  2. resetReplayPolicyFor() (src/providers/key-failover.ts:672-682) returns {"enabled":true,"replacements":2} for all three providers — printed by calling it on routedProviderConfig(name, config.providers[name]). It has no auth-mode gate.
  3. The native Responses passthrough lane passes claimAmbiguousResend: claimPreHeaderResend on the first send (src/server/responses/passthrough-dispatch.ts:1045-1055), and claimPreHeaderResend routes through authorizeResendForRecovery("pre-header", "connection-reset", ambiguousResend()) (:787-798).
  4. fetchWithTransientRetry's innerResetOptions() is {...opts, attempts: remaining(), onSendsConsumed: undefined} (src/lib/upstream-retry.ts:846-851), so the callback does reach fetchWithResetRetry.
  5. The send cap is the same for both kinds: neither row sets transientRetryOn5xx, so transientSendCapFor(undefined, …) returns the default and initialSendAllowance() gives the same total; attempt + 1 >= attempts therefore cannot be what ends the key-auth leg at the first attempt.

That leaves, inside authorizeResend (src/lib/request-resend-gate.ts:102-122), only ambiguous-request-not-replayable (selfContainedResponsesBody(parsed._rawBody) returning false, src/server/responses/reset-replay.ts:62-79) or a call site that ran without the callback installed. Both produce byte-identical telemetry, and src/lib/upstream-retry.ts:703 collapses an absent callback and a gate refusal into the same replayRefusalResponse():

if (attempt + 1 >= attempts || opts.claimAmbiguousResend?.() !== true) {
  return replayRefusalResponse();
}

Why this is not an existing issue

The 503/502 evidence from the same window, for context

Today (2026-11-09, Asia/Shanghai): 1126 requests, 919 × 200, 120 × 429, 62 × 503, 20 × 502, 5 × 499.

  • All 120 × 429 are synthetic upstream_reset_replay_refused (no upstream 429 was received).
  • All 62 × 503 are genuine upstream server_is_overloaded from the canonical provider (terminalSource: "upstream"), a separate and real upstream problem.
  • 20 × 502: 4 genuine upstream protocol-prelude, 16 synthesized after a mid-stream break (failureStage: "semantic-output").
  • Duration histogram of the 429s: 71 records in 12–20 s (single send), 37 in 44–52 s (three sends), each physical send ending at ~15.7–15.9 s.

Asks

  1. Record the refusal reason per attempt (and whether a callback was supplied), e.g. resendRefusal: "ambiguous-request-not-replayable" / "ambiguous-no-policy" / "ambiguous-allowance-spent" on the attempt, or at minimum a service.log line. Right now grep over service.log and usage.jsonl cannot distinguish "wired but judged not replayable" from "not wired", which is the whole question an operator has when their opt-in produces nothing.
  2. Confirm the intended scope of retryOnReset: should it apply to key-auth openai-responses rows? If the body judgment is what refuses these turns, say which predicate failed (store !== false, previous_response_id, stream_id, hosted tool) so operators can shape their client accordingly.
  3. Consider judging selfContainedResponsesBody on the outbound body rather than parsed._rawBody, since this lane rebuilds the body anyway and the inbound one may carry client-only hints that never reach the origin.

Version

OpenCodex 2.99.0 (installed via npm, running src/cli/index.ts under bun 1.4.4). Codex App desktop client.

Operating system

Windows 11 x64

Provider and model

Canonical openai (authMode: "forward") versus two key-auth openai-responses providers with custom baseUrl (names and hosts redacted). Models: gpt-6.1-sol / gpt-6-sol / gpt-6-luna, inboundProtocol: "responses", protocolTrace.mode: "native", streamMode: legacy-tee.

Logs or error output

exceeded retry limit, last status: 429 Too Many Requests
[opencodex] upstream failure code=upstream_reset_replay_refused

Redacted usage.jsonl attempts, canonical versus key-auth, same day:

{"provider":"openai","status":429,"terminalSource":"synthetic","errorCode":"upstream_reset_replay_refused",
 "failureStage":"headers-only","failureCause":"transport-ambiguous","durationMs":48950,
 "attempts":[{"ordinal":1,"adapter":"openai-responses","sendCount":3,"recoveryKinds":["connection-reset"],
              "errorCode":"upstream_reset_replay_refused","failureStage":"headers-only"}]}

{"provider":"<key-auth>","status":429,"terminalSource":"synthetic","errorCode":"upstream_reset_replay_refused",
 "failureStage":"headers-only","failureCause":"transport-ambiguous","durationMs":15798,
 "attempts":[{"ordinal":1,"adapter":"openai-responses","sendCount":1,"recoveryKinds":[],
              "errorCode":"upstream_reset_replay_refused","failureStage":"headers-only"}]}

Redacted configuration

{
  "providers": {
    "openai": {
      "adapter": "openai-responses",
      "authMode": "forward",
      "retryOnReset": { "enabled": true, "replacements": 2 }
    },
    "<key-auth-provider-a>": {
      "adapter": "openai-responses",
      "baseUrl": "https://<redacted>",
      "retryOnReset": { "enabled": true, "replacements": 2 }
    },
    "<key-auth-provider-b>": {
      "adapter": "openai-responses",
      "baseUrl": "https://<redacted>",
      "retryOnReset": { "enabled": true, "replacements": 2 }
    }
  }
}

Checks

  • I searched existing issues and documentation.
  • I removed secrets, tokens, account details, request credentials, and personal data.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions