mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #5218] [Engine] serve: a reasoning loop written as one long hyphen run-on #5349
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#5349
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/5218
Author: @e041l4su3qu4u03
Created: 11/4/2026
Status: 🔄 Open
Base:
main← Head:serve-hyphen-runon-guard📝 Commits (2)
b7afb86serve: a reasoning loop written as one long hyphen run-ond986339serve: mark the transcript when the degeneracy guard wraps📊 Changes
3 files changed (+111 additions, -5 deletions)
View changed files
📝
serve/responses.py(+2 -0)📝
serve/server.py(+86 -4)📝
serve/test_reasoning_loop_recovery.py(+23 -1)📄 Description
Problem and result
Before. On long agentic requests,
Qwen3.8-Flash-Nextdegenerates into reasoning whereevery word is new but the whole passage circles one sentence pattern. None of the four
existing guards fires:
repeat_stop_tokens(#606)reasoning_loop_recoverycoverage (#728)LOOP_TAIL_PERIOD(#1753)repeat_stop_period(#1803)Measured on 42 runs of one 100,420-token request: 33 degenerate (79%), on all three
local quantizations (IQ3_S 3.4 bpw 5/5, UD-IQ4_XS 4.0 bpw 4/5, NVFP4 4.5 bpw 10/12), so it
is not a quantization artifact. The reply burns
max_tokensand returns no answer.The degeneration has a shape, even though it has no repetition: one run-on of hyphen-joined
words, and almost no sentence ends.
After. With
"reasoning_degeneracy": "wrap", the thinking is closed through theexisting
reasoning_budget_tokenswrap-up path and the reply answers:At 134k / 180k / 252k prompt tokens: 0 / 9 degenerate answers.
Related discussion
#728 (the opt-in recovery this hooks into), #1753 (the periodic-tail check, same class of
blind spot: a run the word split cannot see), #1803, #606. No separate issue: this is a
focused, opt-in fix.
Approach
Two independent signals, then reuse the wrap path — no new state in the happy path, no new
decoding behaviour:
a-b-c-...chain >=hyphen_chain_chars(default 200).degeneracy_punct_per_1ksentence ends(
。!?!?.+ newline) per 1000 characters, once the reasoning is >= 1000 characters.The second signal is what makes this work for Chinese, which has no spaces: a
whitespace-word metric (mean word length, TTR) cannot be used there at all. Measured:
At 6.0: 25/26 degenerate caught, 1/13 normal flagged. Longest hyphen chain: normal 0–56,
degenerate 203–1569.
reportlogs the measurement and leaves the reply alone, so an operator can decide from thenumbers;
offchanges nothing at all. The check is independent ofreasoning_loop_recovery, so either can be used without the other.Validation
Passed:
python -m py_compile serve/server.py— clean, on the patched tree.python -m unittest serve.test_server -v— the repository's own suite, unmodified:Ran 359 tests in 149.467s / OK (skipped=3).quiet; a hyphen run-on fires; a punctuation-only run-on (
"abc def ghi " * 200, no hyphenat all) fires; both signals disabled stays quiet; text under 1000 chars is not judged.
RAM,
qwen3.8-flash-next-iq3s(ISTA-DASLab GSQ-RCO IQ3_S),--kv int8, 262144 context,temperature 1.0 / top_p 0.95 / top_k 20, 242 tools, prompt 100,420 tokens:
5 runs with the guard, 0 degenerate; the same request without it was degenerate in 10 of
12 runs. Server log line when it fires:
[strata] reasoning looks degenerate (hyphen run-on: longest chain 731 chars) at 2048 output tokens; reasoning_degeneracy=wrapFailed:
Not run:
serve/test_server.pyin thisPR (I can add them here if you prefer them in the suite).
Qwen3.8-Flash-Next; no other architecture exercised.Limits
A stop-gap, not a cure: the thinking is cut, so a few reasoning steps are lost. Tuned on one
model's degeneration; a language whose run-on does not use hyphens and punctuates normally
would need another signal. A legitimate hyphenated listing longer than 200 characters inside
the reasoning would be cut — the threshold is configurable and
reportexists for that case.Nickname: 老哥的小守衛 ("the old fellow's little guard").
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.