喜欢一个人 on Discord (v0.1.1299, deepseek-v4.1-flash through a relay,
usage row stop "stop"): the agent loop ended mid-turn. Their first ask:
when a reply calls tools, finish_reason must be tool_calls on every
path.
Checked each path on origin/main 9b0f48612:
- calls read out of text: tool_calls on Chat stream and whole,
tool_use on Anthropic, function_call items on Responses (existing
TestTextWritten*, TestDSMLBlockClosedWithCalls);
- calls the upstream made, ended "stop": the translations' collector
already ends them "tool" (collector.finish, 蓝猫 on Discord), but a
relayed Chat reply went on with "stop", streamed and whole, so a Chat
client reading finish_reason ended its turn with the calls not run.
chatTidy now marks a choice that made a call and turns its "stop" into
"tool_calls"; chatWhole does the same for a whole reply's message with
tool_calls. A reply with no call keeps "stop", and other reasons
(length) stay.
Test: TestChatCallsEndToolCalls (chattidy_finish_test.go): stream with
and without tools offered, whole with text and with null content, a
length end kept, no-call replies kept "stop". Red on the old code (stream:
finish "stop"); broken by hand, each half red alone (the chatTidy line
off: stream red; the chatWhole check off: whole red).
TestGeminiCompatRelayEndedShort pinned the old "stop" after Linka's
Gemini call (gemini_compat_cut_test.go's "whole" cases). Its guarantee
is that a whole reply goes with its one finish_reason and none added;
it now expects that one as "tool_calls". Found by the full suite at
770c5fc48 (the only red).
Docs: gateway-routing.md, beside the call-id entry.
Run at the tree pushed (go test -timeout 45m ./... in a sandbox HOME at
308f693df, tree cfd91bbea, on origin/main c358e7660; only messages
changed since): 68 packages ok, exit 0. The one red at an earlier run
(770c5fc48), TestGeminiCompatRelayEndedShort, is answered in the finish
commit. gofmt -l clean; go vet ./internal/gateway for darwin, linux
-tags nogui and windows clean.
Not tried: a real relay or the reporter's client.
Reported by 喜欢一个人 on Discord.