mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-10-07 16:18:29 +08:00
A Responses stream that ends with response.completed but carries no output, no usage and no error (only response.created + response.completed observed) is a silent upstream refusal. It was previously treated as a successful turn, recording 0 input / 0 output tokens without triggering failover, so clients saw an empty reply and usage was never billed. Detect the empty terminal event in both the standard and passthrough streaming paths while nothing has been written to the client, and return an UpstreamFailoverError so the next account is tried; when failover is exhausted the client gets an explicit Responses-format error instead of an empty success. Streams with any semantic output, usage or error are untouched. Fixes #5009.