siyuan-note/siyuan · error

response stream failed

Error message

response stream failed

What it means

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.

Source

Thrown at kernel/util/openai_completion.go:649

		item, ok := responseOutputItem(raw)
		if ok && item.Type == "function_call" {
			return true
		}
	}
	return false
}

func responseEventError(event openai.ResponseStreamEvent, fallback string) error {
	if event.Error != nil && event.Error.Message != "" {
		return &openai.APIError{Code: event.Error.Code, Message: event.Error.Message}
	}
	if event.Response != nil && event.Response.Error != nil && event.Response.Error.Message != "" {
		return &openai.APIError{Code: event.Response.Error.Code, Message: event.Response.Error.Message}
	}
	if event.Message != "" {
		return &openai.APIError{Code: event.Code, Message: event.Message}
	}
	return errors.New(fallback)
}

func (stream *OpenAICompletionStream) ResponseOutput() []json.RawMessage {
	return CloneOpenAIResponseOutput(stream.responseOutput)
}

func (stream *OpenAICompletionStream) Close() {
	if stream.chat != nil {
		stream.chat.Close()
	}
	if stream.responses != nil {
		stream.responses.Close()
	}
}

View on GitHub (pinned to afa823b6b4)

Solutions

  1. Retry the request — mid-stream transport errors are usually transient.
  2. Inspect the network path: proxy timeouts, connection limits, and gateway load at failure time.
  3. Check the gateway's own logs for the underlying socket or upstream error.
  4. Upgrade the gateway so error events carry code and message payloads.
Defensive patterns

Strategy: retry

Try / catch

Close the stream and retry with exponential backoff; persistent occurrences point at the network path — inspect proxies and gateway logs instead of retrying indefinitely.

Prevention

When it happens

Trigger: 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.

Common situations: Proxies converting socket errors into detail-less error events; gateway resource exhaustion during long streams; non-compliant Responses API reimplementations.

Related errors


AI-assisted analysis of siyuan-note/siyuan@afa823b6b4 (2026-08-18). Data as JSON: /api/errors/6dd26ab92038e849. Report an issue: GitHub.