Skip to content

server: a reply that ends inside an unclosed think block answers with its text (fixes #3687) - #3699

Merged
ashhart merged 4 commits into
mainfrom
lead/reasoning-only-reply
Nov 17, 2026
Merged

ashhart merged 4 commits into
mainfrom
lead/reasoning-only-reply

Conversation

@ashhart

@ashhart ashhart commented Nov 17, 2026

Copy link
Copy Markdown
Owner

Fixes #3687. A thinking model that finishes at its own end token while its think block is still open, and makes no tool call, used to return an empty answer on every route. Agent clients saw an empty turn. Now its text is returned as the answer too, on chat completions, /v1/messages and /v1/responses, streamed and whole.

When it applies (in Generation.finish, after the engine has drained), all must hold:

  • a chat route with no structured output: no JSON schema, no required or named tool, no strict optional-tool grammar;
  • the model ended the reply itself: the final reason is stop and the last token is an end token, with no client stop string and no loop-guard stop (a stop string or a length cut never qualifies);
  • the answer is empty and there is reasoning;
  • the block never closed: the shared think split's pending close (Qwen3.x, GLM, DeepSeek, MiniMax, Gemma 4 channels, LFM, Kolibri), or Kimi's new open-think signal;
  • no tool call in the text, by the family's call openers and by the route's own tool parser, so a bare JSON call in the reasoning still isn't executed.

Unchanged: the text stays in the reasoning field as well, so joined stream deltas still equal the final message. Token ids, token_sha256 and token counts are untouched. Requests with structure, stop strings, length cuts and closed blocks reply exactly as before. One line is logged when it happens.

Checks: lean level with main, fmt clean, every changed file at most 600 lines.

  • Synthena

@ashhart

ashhart commented Nov 17, 2026

Copy link
Copy Markdown
Owner Author

/atc exchange 325907932c0e7815bc755fc75465b57def29c14bd25649aa4f59358261231d0e

… its text (#3687)

A thinking reply that ended at the model's own end token while its think
block was still open, with no tool call, returned an empty answer on every
route: content "" on chat, a thinking block only on /v1/messages, a
reasoning item only on /v1/responses.

After the engine finishes, when the block never closed, the model ended
the reply itself (not a stop string, max_tokens or the loop guard), the
text holds no call opener and no call the route's tool parser reads, and
the request forced no tool and no structured output, the text is also the
answer. It stays in the reasoning field, so the stream sends it as one
content delta at the end and the joined deltas equal the finished reply.
The reply says tensorfold.reasoning_recovered: true, the server logs one
line, and logprobs keep those tokens under reasoning_content. Token ids,
token_sha256 and token counts are unchanged. Kimi's native parse reports
whether its think channel is still open.

Server goldens: the fake model's thinking replies end at their end token
in a block they never close, so 42 golden files (46 replies) and one
request-log line now carry the answer; each difference was reviewed to be
only that (content, the runtime flag, one more stream content chunk, and
the next turn's prompt count in a stored Responses chain).
@ashhart
ashhart force-pushed the lead/reasoning-only-reply branch from 8f0d20c to c68a12a Compare November 17, 2026 18:06
@ashhart
ashhart merged commit e7ff97e into main Nov 17, 2026
11 checks passed
@ashhart
ashhart deleted the lead/reasoning-only-reply branch November 17, 2026 18:06
ashhart added a commit that referenced this pull request Nov 17, 2026
Seven duplicate entries go (a PR's own line beside its lines-file line), five outside authors are thanked, #1503 gets the line its close note promised, and eleven lines now match their PRs' code and receipts (#3129, #3194, #3258, #2696, #2921, #3365, #3345, #3384, #3679, #3682, #3699, #3393).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A thinking reply that ends inside an unclosed think block returns an empty answer on every route

1 participant