[PR #1886] [CLOSED] serve: preserve literal </think> across reasoning parsing #3735

Closed
opened 2026-11-07 15:30:24 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/1886
Author: @CC-David-CC
Created: 10/10/2026
Status: ❌ Closed

Base: main ← Head: fix/literal-think-output-combined


📝 Commits (9)

  • 85ced52 serve: a reply that ends inside its thinking with no answer is continued (#1814)
  • 68c2d07 serve: report a reply that ended inside its thinking, guard or no guard (#1814)
  • 549efc6 serve: put the tag back into the reasoning before the close, and test it (#1814)
  • d41047c fix(serve): distinguish reasoning marker identity from literal text
  • e603e90 fix(serve): route literal thinking tags by token identity
  • fc98b38 test(serve): cover literal repair cancellation and budget
  • 3d66ab0 test(serve): verify literal thinking tags across HTTP APIs
  • 471bcd5 fix(serve): continue after EOS inside reasoning code
  • b83016b fix(serve): compose literal guard with end detection

📊 Changes

8 files changed (+818 additions, -13 deletions)

View changed files

📝 docs/DETAILS.md (+10 -0)
➕ serve/fixtures/literal_think_specimens.json (+30 -0)
📝 serve/frontend.py (+32 -6)
📝 serve/prometheus.py (+5 -0)
📝 serve/server.py (+173 -7)
➕ serve/test_literal_think.py (+226 -0)
➕ serve/test_literal_think_guard.py (+236 -0)
➕ serve/test_literal_think_parser.py (+106 -0)

📄 Description

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.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/1886 **Author:** [@CC-David-CC](https://github.com/CC-David-CC) **Created:** 10/10/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/literal-think-output-combined` --- ### 📝 Commits (9) - [`85ced52`](https://github.com/Niko1221/Strata/commit/85ced52a9550e328c1b7672a3faa69a4810c8a95) serve: a reply that ends inside its thinking with no answer is continued (#1814) - [`68c2d07`](https://github.com/Niko1221/Strata/commit/68c2d076ccf05c0b1841f4792c942f1e57df85c8) serve: report a reply that ended inside its thinking, guard or no guard (#1814) - [`549efc6`](https://github.com/Niko1221/Strata/commit/549efc6cef5b33583596442e828f47903d1d503f) serve: put the tag back into the reasoning before the close, and test it (#1814) - [`d41047c`](https://github.com/Niko1221/Strata/commit/d41047c6404310a4811773ae518d9a532943cd88) fix(serve): distinguish reasoning marker identity from literal text - [`e603e90`](https://github.com/Niko1221/Strata/commit/e603e9060d49836988afdb9208dc36988b836cfb) fix(serve): route literal thinking tags by token identity - [`fc98b38`](https://github.com/Niko1221/Strata/commit/fc98b38d40e4bdf03994673d22ca1bb3a00e6aa4) test(serve): cover literal repair cancellation and budget - [`3d66ab0`](https://github.com/Niko1221/Strata/commit/3d66ab0edf4a719ec7cbb9446116745d9f46e70d) test(serve): verify literal thinking tags across HTTP APIs - [`471bcd5`](https://github.com/Niko1221/Strata/commit/471bcd5e17130f89cb30e04bed8ecc983dd9fe3c) fix(serve): continue after EOS inside reasoning code - [`b83016b`](https://github.com/Niko1221/Strata/commit/b83016b21b54f7f2dc192f7efaa1efaea754cfa7) fix(serve): compose literal guard with end detection ### 📊 Changes **8 files changed** (+818 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `docs/DETAILS.md` (+10 -0) ➕ `serve/fixtures/literal_think_specimens.json` (+30 -0) 📝 `serve/frontend.py` (+32 -6) 📝 `serve/prometheus.py` (+5 -0) 📝 `serve/server.py` (+173 -7) ➕ `serve/test_literal_think.py` (+226 -0) ➕ `serve/test_literal_think_guard.py` (+236 -0) ➕ `serve/test_literal_think_parser.py` (+106 -0) </details> ### 📄 Description ## 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 15:30:24 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#3735
No description provided.