Files
magpie/docs
yetone c0cf352a8d gateway: a group member's reply that ends with nothing in it goes to the next member (#6712)
shawn8888's ai-studio (magpie-gemini-web 0.14.0, aistudio2api 0.3.8)
answered a streamed request with 200, a role chunk with "" content, then
finish_reason "stop" and 0 output tokens when Google's every
regeneration came back malformed_response. streamEvent read that Chat
finish chunk as content, so the hold let the stream through as an answer
and group/auto-gemini-4-hydrogen (routing order) never asked agy-cli or
google; the agent got no reply.

A reply's end in an event that says nothing itself is now eventEmptyEnd:
a Chat finish_reason other than length, error or a filter; Messages'
end_turn, stop_sequence or tool_use; a completed Responses reply; Gemini's
STOP. The hold fails the try with a 502 "empty reply: it ended with
nothing in it" only when nothing was said before it, reasoning included,
and only for a group member with another member after it and errors not
passed through (holdWriter.emptyFails). The group's existing empty-reply
branch then asks the next member and rests nobody. A reply held whole is
judged in the one parse settle already made (refusedReply is now
readWhole, which also says empty), so a passing reply is read no more
than before. The last member's empty reply, or a model asked alone, goes
to the agent as it came, so an empty answer can't loop.

Changed on purpose: a Claude member's empty end_turn inside a group with
members left now asks the next member; TestStreamEventRefusals' three
rows for an empty end now say eventEmptyEnd.

Not handled: a stream the hold already let through on its timer (a Gemini
client after 15s) before the empty end came. The plugin side is
BUKOWSKIREAL/magpie-gemini-web#61 (a 502 or error event, not 200 + stop).

Run, on mica:
- new tests red on 369ec0418's fallback.go/gateway.go (checked out over the
  new ones, the unit tables left out): TestEmptyStopFailsOverToTheNextMember
  (chat, messages, responses, gemini), TestEmptyWholeReplyFailsOverToTheNextMember,
  TestEmptyStopEndsAtTheLastMember, TestEmptyEndFromEachUpstreamFailsOver
  (Messages and Responses upstreams) all FAIL; TestReasonedThenStoppedStaysTheAnswer
  passes on both (a guard against reaching too far). All green on the new code.
- go test ./internal/gateway -count=1 (whole package): one red,
  TestStreamEventRefusals' three empty-end rows, updated here; then
  -run 'StreamEvent|Refusal|Empty|FinishReason|Overload|Overflow|ReadWhole|Reasoned|Responses' ok.
- go vet ./internal/gateway, GOOS=linux (nogui) and GOOS=windows vet ok; gofmt -l clean.
- The full go test ./... -timeout 45m runs after the push (ship-at-once);
  its result goes on #6712.
2026-11-15 06:09:25 +08:00
..