View Source Stream replay-safety guide

An HTTP status code does not prove that a streamed operation completed. A connection can close after output was rendered, after a provider emitted an error event, or before a terminal marker. Replaying blindly can duplicate visible output or incur a second charge.

OpenaiSseGuard records bounded evidence without retaining the response body:

EvidenceSnapshot effectApplication question
[DONE]termination: :doneCan the caller mark the stream complete?
response.completedtermination: :doneWas a Responses terminal event observed?
response.incompletetermination: :incompleteDoes the provider require a follow-up?
error eventtermination: :errorShould the caller surface a provider error?
Named/data event then EOFhas_output: true, :unexpected_eofIs replay unsafe without idempotency?
No event then EOF:unexpected_eofIs there enough evidence to retry?
Frame or event bound exceeded:errorShould the transport be treated as untrusted?

The package deliberately does not answer the final retry question. A caller should combine the snapshot with method semantics, an idempotency key, whether bytes were rendered, provider billing rules, cancellation state, and remaining budgets. A conservative false positive prevents a replay; a false negative can duplicate output or billing.

For wire framing, consult the WHATWG SSE specification. For provider errors, see the OpenAI error-code guide. For retry hints, see MDN Retry-After.