{"record":{"id":"6dd26ab92038e849","repo":"siyuan-note/siyuan","slug":"response-stream-failed","errorCode":null,"errorMessage":"response stream failed","messagePattern":"response stream failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/util/openai_completion.go","lineNumber":649,"sourceCode":"\t\titem, ok := responseOutputItem(raw)\n\t\tif ok && item.Type == \"function_call\" {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\nfunc responseEventError(event openai.ResponseStreamEvent, fallback string) error {\n\tif event.Error != nil && event.Error.Message != \"\" {\n\t\treturn &openai.APIError{Code: event.Error.Code, Message: event.Error.Message}\n\t}\n\tif event.Response != nil && event.Response.Error != nil && event.Response.Error.Message != \"\" {\n\t\treturn &openai.APIError{Code: event.Response.Error.Code, Message: event.Response.Error.Message}\n\t}\n\tif event.Message != \"\" {\n\t\treturn &openai.APIError{Code: event.Code, Message: event.Message}\n\t}\n\treturn errors.New(fallback)\n}\n\nfunc (stream *OpenAICompletionStream) ResponseOutput() []json.RawMessage {\n\treturn CloneOpenAIResponseOutput(stream.responseOutput)\n}\n\nfunc (stream *OpenAICompletionStream) Close() {\n\tif stream.chat != nil {\n\t\tstream.chat.Close()\n\t}\n\tif stream.responses != nil {\n\t\tstream.responses.Close()\n\t}\n}\n","sourceCodeStart":631,"sourceCodeEnd":664,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/afa823b6b4e4f183511e0bc0a3be93caa94c7c97/kernel/util/openai_completion.go#L631-L664","documentation":"responseEventError builds the most specific error available from a stream error event: event.Error, then event.Response.Error, then event.Message. The fallback string \"response stream failed\" is used when an error-class event (ResponseStreamEventError) carried none of these — the stream died mid-flight at the transport or protocol level and the provider attached no detail.","triggerScenarios":"A provider or proxy injects a bare error event mid-stream (connection reset, protocol violation, watchdog abort) without an error payload; gateways under load dropping streams and emitting empty error events.","commonSituations":"Proxies converting socket errors into detail-less error events; gateway resource exhaustion during long streams; non-compliant Responses API reimplementations.","solutions":["Retry the request — mid-stream transport errors are usually transient.","Inspect the network path: proxy timeouts, connection limits, and gateway load at failure time.","Check the gateway's own logs for the underlying socket or upstream error.","Upgrade the gateway so error events carry code and message payloads."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"Close the stream and retry with exponential backoff; persistent occurrences point at the network path — inspect proxies and gateway logs instead of retrying indefinitely.","preventionTips":["Keep proxies and gateways from dropping idle SSE connections","Set client read timeouts longer than the longest expected generation","Monitor mid-stream error-event rates per provider"],"tags":["streaming","openai","responses-api","sse","network"],"backgroundTag":"llm-stream-failed-event","analyzedSha":"afa823b6b4e4f183511e0bc0a3be93caa94c7c97","analyzedAt":"2026-08-18T17:04:10.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}