{"record":{"id":"fa18b162be76aa02","repo":"siyuan-note/siyuan","slug":"response-failed","errorCode":null,"errorMessage":"response failed","messagePattern":"response 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 failed stream event: event.Error first, then event.Response.Error, then event.Message. The fallback string \"response failed\" appears only for a response.failed event that carried none of these — the response object itself failed (safety system, server error) but the provider sent no detail, so the adapter can only report the event type.","triggerScenarios":"Streaming a Responses completion when the provider emits response.failed with an empty or absent error object; upstream server faults converted by the gateway into payload-less failure events.","commonSituations":"Gateways that collapse upstream 5xx into bare failure events; provider safety terminations without messages; capacity or moderation terminations during long generations.","solutions":["Capture the raw SSE frame to confirm the event truly lacks detail.","Check the provider's server-side logs at that timestamp — the root cause usually lives there.","Retry with backoff — payload-less failures are frequently transient upstream faults.","Upgrade or fix the gateway to populate error.code and error.message on failure events."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"Close the stream, surface a generic 'provider failed the response' message, and retry with backoff; if failures cluster, check provider status and logs before retrying further.","preventionTips":["Prefer providers that attach error payloads to failure events","Keep gateway error-mapping configured for upstream faults","Rate-limit retries on detail-less failures"],"tags":["streaming","openai","responses-api","sse","provider-error"],"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"}