What changed: every translated request is asked of its upstream as a
stream, and a client that asked for no stream gets its reply assembled
from it. translate read that stream and rendered whatever came as the
whole reply, so an Anthropic upstream that stopped with no stop_reason
and no message_stop, or a Responses one with no response.completed,
handed the client a truncated answer presented as finished — the same
cut a streaming client is told of in its stream (errEndedShort). The
read now watches for the upstream's last event the same way
(upstreamEnds), and ends with the 502 "the reply ended before it was
complete" instead: nothing has been sent, so the next candidate is
asked, and the last one's error reaches the agent. An error the upstream
said still reports itself; a stream that said its last event
(stop_reason, message_stop, response.completed) is served as it came.
Review (yetone's session): with the cut check disabled by hand
TestNonStreamEndedShort fails (both subtests 200 with "Let me look at
the"); restored, green. The 502 takes the same path as the read-error
502 beside it (cutMidReply): nothing written yet, retryable() lets the
next candidate answer, and no account is rested for it as content.
The full suite, gofmt and the cross-OS vets were run on the series.
Author's run: TestNonStreamEndedShort (new; Anthropic and Responses
cases) fails on the old code — both cuts came back 200 with
finish_reason "stop"; with the change both come back 502 naming the
cut, and a reply whose last event came is served 200 whole. gofmt -l
clean; go vet and go build on darwin, linux, windows; go test -tags
nogui -race -count=20 on the relay-stop tests; the full go test -tags
nogui ./... (TestOffline and TestSearchFollowsTheSearchersProxy red on
the clean baseline too).
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>