Skip to content

[Bug] retryOnReset does not replace a native prelude-only clean EOF #8231

Closed

Description

@LynchLiu-Lingqing

Client or integration

Codex App; isolated native Responses HTTP/SSE fixture.

Area

Streaming

Summary

With providers.<name>.retryOnReset = {"enabled":true,"replacements":1}, a native Responses stream that sends only keepalive comments / an empty lifecycle prelude and then closes cleanly without any terminal does not reach the explicit replacement owner. It becomes adapter_eof even though the request is self-contained and no output was committed.

A thrown reader error reaches the owner; reader.read().done === true takes the accepted branch instead. This is distinct from #8216, which concerns preserving an untyped provider error envelope. An explicit provider error should continue to be delivered, not reinterpreted as EOF recovery.

Reproduction

No external model or credentials required. In a source checkout, save as .tmp/prelude-eof-repro.ts and run bun .tmp/prelude-eof-repro.ts:

process.env.OPENCODEX_HOME = import.meta.dir + "/fixture-home";
process.env.CODEX_HOME = import.meta.dir + "/fixture-codex";
const { deferProtocolSafeResetRecovery } = await import("../src/server/responses/combo-stream-preflight");
const { relaySseWithFailedTail } = await import("../src/server/relay");
const headers = { "content-type": "text/event-stream" };
const first = new Response(': PING\n\ndata: {"type":"response.created","response":{"id":"resp_fixture","output":[],"status":"in_progress"}}\n\n', { headers });
let replacements = 0;
const held = deferProtocolSafeResetRecovery(first, { provider: "fixture", model: "probe" }, async () => {
  replacements++;
  return new Response('data: {"type":"response.completed","response":{"id":"resp_replacement","status":"completed","output":[{"type":"message","id":"msg_fixture","role":"assistant","status":"completed","content":[{"type":"output_text","text":"RECOVERY_OK","annotations":[]}]}]}}\n\ndata: [DONE]\n\n', { headers });
});
const text = await new Response(relaySseWithFailedTail(held.body!, new AbortController())).text();
console.log(JSON.stringify({ replacements, text }));

This low-level reproduction supplies the recovery owner directly. An additional full loopback gateway fixture used the redacted configuration below and a store:false, complete-input request declaring only a client function. Before the fix, the upstream fixture received one POST and the client got adapter_eof. After the fix it received two POSTs and the replacement completed.

Version

OpenCodex 2.97.0 / Bun 1.4.4. Also inspected current dev source: preflight still accepts the clean EOF branch without offering it to reset recovery. Other local compatibility changes are unrelated to the synthetic, client-function-only fixture.

Operating system

macOS 27.0.1, Apple Silicon

Provider and model

Synthetic native openai-responses provider. Investigated after repeated Gemini HTTP/SSE prelude-only missing-terminal failures; this report does not claim to fix a provider's upstream execution deadline.

Logs or error output

Baseline: replacements:0, synthetic response.incomplete, reason adapter_eof.

Narrow local fix:

  • represent a protocol-observed pre-output EOF with a distinct error type;
  • offer that EOF only through the existing explicit post-header recovery owner;
  • retain the existing self-contained-body check, per-request grant and physical-send ceiling;
  • preserve default behavior without the grant, explicit errors, real terminals, opaque payloads and committed output;
  • suppress replacement initiation after downstream cancellation.

Companion liveness coverage: the owner holds pre-output bytes while inspecting/replacing. A slow upstream can otherwise leave the client without keepalive traffic. The local patch emits bounded 15-second SSE comment heartbeats during this hold only. They are not model progress and do not renew an upstream deadline.

Screenshots and supporting files

Five isolated HTTP cases on port 10101:

  • prelude EOF then completion: 2 POSTs, success;
  • persistent prelude EOF: 2 POSTs, incomplete, no third send;
  • text emitted then EOF: 1 POST, partial output preserved;
  • explicit untyped provider error: 1 POST, response.failed with original diagnostic;
  • delayed prelude EOF: client receives keepalive before EOF, then the one replacement succeeds.

269 focused/import-connected tests across five files passed, including grant/cancellation and negative boundaries. Typecheck, privacy scan, structure checks and documentation build passed. Full repository suite was not run.

A real synthetic tool-call/result round trip through the local gateway also completed; that validates ordinary operation, not recovery from an actual remote outage. No private histories, project material, credentials or model-generated executable code are attached.

Redacted configuration

{
  "providers": {
    "fixture": {
      "adapter": "openai-responses",
      "baseUrl": "http://127.0.0.1:<mock-port>/v1",
      "apiKey": "fixture-key",
      "allowPrivateNetwork": true,
      "proxy": "direct",
      "models": ["probe"],
      "retryOnReset": {"enabled":true,"replacements":1}
    }
  },
  "emptyCompletionRetry": false,
  "clientIntegrations": {"codex":false,"grok":false,"claude-desktop":false}
}

Checks

  • I searched existing issues and documentation.
  • I removed secrets, tokens, account details, request credentials, and personal data.

Activity

  1. github-actions commented on Nov 6, 2026

    @github-actions
    Contributor

    Automated translation bookkeeping — detected language: English.

  2. added
    bug
    streaming
    on Nov 6, 2026
  3. Ingwannu commented on Nov 7, 2026

    @Ingwannu
    Owner

    Confirmed on dev (aaa3c20f3f). In preflightComboStreamResponse, a clean reader.read().done with no terminal and no committed output returns kind: "accepted" (src/server/responses/combo-stream-preflight.ts:377-378, then 406-408). deferProtocolSafeResetRecovery offers only kind: "read-error" to the recovery owner (combo-stream-preflight.ts:456). A prelude-only clean EOF therefore never reaches retryOnReset, and the relay closes it as the synthetic adapter_eof incomplete. A thrown read error does reach the owner, which matches your observation.

    The owner's draft #8292 (Closes #8231) covers this. It sends that EOF through the existing replay-safety grant and send budget, keeps the original stream when recovery is refused, and emits bounded comments while the prelude is held. This issue stays open until the fix lands on dev.

  4. added a commit that references this issue on Nov 12, 2026
    aa30ea9
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

    bugstreaming

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions