fix: replace interrupted OpenAI responses safely - #10
Merged
Conversation
danielkov
force-pushed
the
docs/openai-post-event-stream-failures
branch
from
August 25, 2026 23:56
a1f33b2 to
28d7d65
Compare
danielkov
force-pushed
the
docs/openai-post-event-stream-failures
branch
from
August 26, 2026 00:05
28d7d65 to
458e39f
Compare
danielkov
marked this pull request as draft
August 26, 2026 00:17
danielkov
force-pushed
the
docs/openai-post-event-stream-failures
branch
from
August 26, 2026 14:01
458e39f to
1eb8ead
Compare
danielkov
marked this pull request as ready for review
August 26, 2026 14:01
danielkov
force-pushed
the
docs/openai-post-event-stream-failures
branch
2 times, most recently
from
August 26, 2026 15:29
6383c3c to
a85618c
Compare
danielkov
enabled auto-merge (squash)
August 26, 2026 15:32
danielkov
force-pushed
the
docs/openai-post-event-stream-failures
branch
from
August 26, 2026 15:40
a85618c to
11e08d5
Compare
auto-merge was automatically disabled
August 26, 2026 15:41
Pull request was closed
danielkov
force-pushed
the
docs/openai-post-event-stream-failures
branch
from
August 26, 2026 15:43
11e08d5 to
90460ac
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Recovers interrupted OpenAI subscription response streams without relying on deterministic SSE-prefix replay. ACP v2 replaces partial output in place, while ACP v1 emits a non-terminal interruption warning before streaming a fresh response; only the successful response attempt enters the final transcript.
Motivation
OpenAI subscription streams can fail after visible text or reasoning has reached the client. Retrying by matching a regenerated response against the failed attempt assumes deterministic frames and model output, while failing the turn prevents recovery from transient interruptions.
Fixes #19.
Impact
ACP v2 clients receive a clean replacement response instead of stale or duplicated partial output. ACP v1 is append-only, so its partial output remains visible and is followed by
Response interrupted; replacement followsbefore the replacement stream. Non-ACP recovery surfaces retain fatal post-output behavior.This bumps Kit from 0.1.92 to 0.1.93.
Technical details
Retry contract
Each retry reuses the request context, idempotency key, credentials, retry budget, and turn state, but parses the fresh response from byte zero and discards parser, output, usage, and tool state from the failed attempt. Learned
x-codex-turn-staterouting metadata is propagated and contradictory routing state is rejected.Tool calls remain withheld until
response.completed. Response ingress is limited to 16 MiB per attempt and 64 MiB across all attempts.ACP rendering
A reserved internal marker is emitted before retry backoff, authentication, or the next POST can fail. ACP v2 translates it into empty whole-message upserts for stale answer and reasoning content, then assigns fresh stable message IDs to replacement chunks; cancellation also clears tracked partial content if the marker is suppressed. ACP v1 translates the marker into a warning notice. The marker and notice do not enter output items or transcripts, and ACP v2 does not emit the notice.