Skip to content

fix: replace interrupted OpenAI responses safely - #10

Merged
danielkov merged 2 commits into
mainfrom
docs/openai-post-event-stream-failures
Aug 26, 2026
Merged

fix: replace interrupted OpenAI responses safely#10
danielkov merged 2 commits into
mainfrom
docs/openai-post-event-stream-failures

Conversation

@danielkov

@danielkov danielkov commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

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 follows before 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-state routing 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.

@danielkov
danielkov force-pushed the docs/openai-post-event-stream-failures branch from a1f33b2 to 28d7d65 Compare August 25, 2026 23:56
@danielkov danielkov changed the title docs: record fatal post-event OpenAI stream failures fix: replay interrupted OpenAI streams safely Aug 25, 2026
@danielkov
danielkov force-pushed the docs/openai-post-event-stream-failures branch from 28d7d65 to 458e39f Compare August 26, 2026 00:05
@danielkov
danielkov marked this pull request as draft August 26, 2026 00:17
@danielkov danielkov changed the title fix: replay interrupted OpenAI streams safely fix: replace interrupted OpenAI responses safely Aug 26, 2026
@danielkov
danielkov force-pushed the docs/openai-post-event-stream-failures branch from 458e39f to 1eb8ead Compare August 26, 2026 14:01
@danielkov
danielkov changed the base branch from main to feat/acp-v2-session-inject August 26, 2026 14:01
@danielkov
danielkov marked this pull request as ready for review August 26, 2026 14:01
@danielkov
danielkov force-pushed the docs/openai-post-event-stream-failures branch 2 times, most recently from 6383c3c to a85618c Compare August 26, 2026 15:29
@danielkov
danielkov changed the base branch from feat/acp-v2-session-inject to main August 26, 2026 15:29
@danielkov
danielkov enabled auto-merge (squash) August 26, 2026 15:32
@danielkov
danielkov force-pushed the docs/openai-post-event-stream-failures branch from a85618c to 11e08d5 Compare August 26, 2026 15:40
@danielkov danielkov closed this Aug 26, 2026
auto-merge was automatically disabled August 26, 2026 15:41

Pull request was closed

@danielkov danielkov reopened this Aug 26, 2026
@danielkov
danielkov force-pushed the docs/openai-post-event-stream-failures branch from 11e08d5 to 90460ac Compare August 26, 2026 15:43
@danielkov danielkov closed this Aug 26, 2026
@danielkov danielkov reopened this Aug 26, 2026
@danielkov
danielkov merged commit 5378147 into main Aug 26, 2026
2 checks passed
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.

OpenAI subscription stream failures are fatal after the first model event

1 participant