Study FAQ
What should I do when a Claude stream breaks after showing partial output?
Also asked as 2
- Can I retry a disconnected Claude SSE stream without mixing two answers?
- How can I resume an interrupted Claude Messages response safely?
Answer
Mark the attempt incomplete if the response disconnects or emits an error before message_stop. Keep previously shown text provisional, and withhold it from actions or final records. Depending on the application, discard it, show it as incomplete, offer a fresh request, or explicitly continue from the last usable text.
Track the application operation ID, attempt ID, request ID if present, and last event or closed block. A fresh attempt can generate different content, so replace the provisional answer or display the attempts separately.
Anthropic documents continuation as a new Messages request. For Claude 4.5 or earlier models that support assistant prefill, the documented form supplies the partial text as the start of an assistant response. For Claude 4.6 and newer models, put the partial text and a request to continue into a user message. Save only text appropriate to reuse and keep its origin clear. Partially received tool calls or thinking blocks cannot be recovered this way. Revalidate the assembled application result and apply the normal side-effect controls.
If using an SDK, handle the exception raised by the stream consumer. SDK HTTP retry behavior does not automatically resume a stream that has started.
Official references
Full explanation
Reliable Claude API Streaming, Asynchronous Work, and Error Handling
Study guide · CCDV-F
Read the full explanation