Pull requests / #1886

#1886 serve: preserve literal </think> across reasoning parsing

open · @CC-David-CC · 0 comentários · No GitHub

Server & API

Descrição

## Summary

Builds on the end-of-thinking recovery and captured real-world specimens from #1840, then makes parser transitions depend on the actual special-token identity. This keeps an ordinary `</think>` string in reasoning when it is quoted or appears mid-line, including when the model continues reasoning afterward.

## Reproduction and fix

With #1840's end-of-turn recovery alone, a deterministic token-stream test puts a literal `</think>` in ordinary prose and then continues reasoning. The parser switches to answer mode at the string; the remaining reasoning and quoted tag are routed to the answer. A second test emits the special close token inside an unclosed inline-code span and stops. The recovery continuation preserves the backtick boundary, but the close token is exposed as a structural close instead of quoted reasoning text.

This branch adds token-aware parser signaling and bounded continuation handling. In the same streams, the full prose and quoted tag stay in reasoning, and the answer remains `42`. The original #1840 empty-reasoning / no-answer recovery and its real-turn specimens remain included.

## Validation

- Focused literal-thinking, parser, and #1840 recovery suites: 45 tests passed.
- Full serving suite on latest `main`: 735 tests passed, 12 skipped.
- `git diff --check upstream/main...HEAD`: clean.

These are deterministic service/parser tests; no live Qwen3.8 / dual-3090 rerun is claimed. The recovery/continuation guard remains opt-in, while token-identity parsing is always used.

Supersedes the standalone draft in #1839 and combines its parser-ambiguity fix with #1840's reproduction and recovery.

No site

Links install, modelos, releases.