Gemini 4 Argon over AI Studio's Chat API marks the chunk that opens
<thought> as a thought (extra_content.google.thought) but not the one
that closes it and goes on into the answer. The decoder took a marked
chunk whole as reasoning, past the tag parser, so the reasoning began
"<thought>" and the next, unmarked chunk reached Codex's answer as
"</thought>接下来我将调用 probe…", streamed and in response.completed.
A marked chunk now goes through the same in-band tag parser as text
when it carries a tag, or could be the start of one, with its text kept
as thought: the open tag is dropped, the close in the unmarked chunk
after it ends the thought, and the answer starts clean. A marked chunk
with no tag in sight is thought as before; an answer that only quotes a
tag later keeps it.
Run:
- TestGeminiMarkedThoughtTagLeftOut: the reporter's /v1/responses body
and the stream deltas as #2098 captured them; output_text is the
answer with no tag, reasoning is "[REASONING CONTENT REDACTED]", the
completed output has the probe call with {"number":42}. FAILs on the
old chat.go ("</thought>接下来…" in the stream, "<thought>[REASONING…"
as reasoning).
- TestChatMarkedThoughtTags: tags split across chunks, marked and not,
no tags, quoted tags. Also TestChatThoughtTags and TestGeminiThoughts*.
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows on
internal/gateway; go test -tags nogui ./internal/gateway/.
Not tried: a real Gemini 4 Argon stream (no AI Studio key here).