A Chat reply may open its reasoning with <thinking>…</thinking> in the
text. thoughtTags held only <thought> and <think>, so neither tag matched:
chatDecoder.text took the block for the answer's own text and no thinking
block went out (#5106). In a recorded day on one OpenAI-compatible host,
47 of 2832 turns carried a literal <thinking in the answer's text, 44 of
them at offset 0 (neighbads).
<thinking> is added beside the two, closed by </thinking>. It shares no
whole prefix with <think> (they part at the seventh byte, 'i' against
'>'), so the wait in text covers the shared lead and no lead can name two
opening tags. markedThought reads the same map, so a Gemini-marked chunk
opening with <thinking> is thought's text too.
afterThought, which strips a leading block from the titles,
descriptions and predictions Codex asks for (codex_titles.go), now reads
the same map instead of its own <think>, so a <thinking>- or
<thought>-led reply no longer leaves the block in a title (added in the
port; the patch left it as a sibling).
Run (mote): go test -tags nogui -count=5 -run 'TestChatThoughtTags|
TestMarkedThought|ThoughtTag|TestAfterThought|Title|Description'
./internal/gateway/ ok; gofmt -l clean; go vet -tags nogui
./internal/gateway/ clean.
Broken by hand: chat.go put back to origin/main, the four <thinking>
cases of TestChatThoughtTags FAIL and TestAfterThoughtCloseInCode FAILs
on the <thinking> and <thought> leads.
Not tried: a live model that sends the tag (the reporter's model sends
it in about 1.7% of turns, not on demand). The plugins repo's think-tags
middleware keeps its own list and is not changed here.
The tag and the whole/split cases are neighbads' patch on their fork;
ggbdpq added the open-tag-alone and never-closed cases.
Fixes#5106
Generated-by: GLM-5.3-Flash (ZCode)
Co-authored-by: neighbads <16126598+neighbads@users.noreply.github.com>
Co-authored-by: ggbdpq <ggbdpq@gmail.com>