[PR #1777] [CLOSED] serve: reasoning loop recovery also catches a loop written as one long word (#1753) #3665

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

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/1777
Author: @BaaRai
Created: 10/10/2026
Status: ❌ Closed

Base: main ← Head: serve-1753-one-word-loop


📝 Commits (1)

  • 831e9b8 serve: the reasoning loop check also sees a loop written as one long word (#1753)

📊 Changes

3 files changed (+32 additions, -2 deletions)

View changed files

📝 docs/DETAILS.md (+4 -1)
📝 serve/server.py (+10 -1)
📝 serve/test_reasoning_loop_recovery.py (+18 -0)

📄 Description

Fixes #1753.

What it changes: reasoning loop recovery (opt-in, #728) now also checks the last 2,048 chars of the reasoning for a period of at most 64 chars, before the word count. A periodic tail reads as coverage 1.0, so both stop and recover act on it. This is the shape #1753 replayed: a greedy run that writes its loop as one long word (a 24k-digit string cycling the 11-digit pattern 58747693387) is a single word to the 2,000-word window, and it never repeats one token because the tokenizer has no multi-digit tokens, so both guards passed it and the run burned the whole reasoning budget (24,599 and 32,791 tokens in the captured runs, both answering 1).

What it leaves alone: the word count, its thresholds, the check cadence and the recovery splice are unchanged, and the check runs only when reasoning_loop_recovery is on, so the default path is byte-identical. No engine change. The issue's engine-level variant (extending #606 to short periods) would also protect users who have not opted in; this PR is the server-side half and uses the exact 2,048-char / 64-period window the issue author replayed across 70 captured reasonings (both digit-string runs caught, zero false fires).

How I checked: python -m unittest serve.test_reasoning_loop_recovery, 18 tests, all pass. New tests cover the issue's cases directly: the digit cycle scores 1.0, a non-periodic 2,893-char digit string scores 0, a 1,100-char tail too short to judge scores 0, and a stop-mode run with MockEngine whose script is the digit string now ends at 2,560 tokens instead of running to the budget. Also ran the full serve suite (595 tests): the 8 errors there also error on an unmodified clone (they need the real tokenizer files and Windows job objects), nothing else changed. CPU only, no GPU involved.


🔄 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/1777 **Author:** [@BaaRai](https://github.com/BaaRai) **Created:** 10/10/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `serve-1753-one-word-loop` --- ### 📝 Commits (1) - [`831e9b8`](https://github.com/Niko1221/Strata/commit/831e9b8b72be987cd537acaa0c45e156f12373f5) serve: the reasoning loop check also sees a loop written as one long word (#1753) ### 📊 Changes **3 files changed** (+32 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `docs/DETAILS.md` (+4 -1) 📝 `serve/server.py` (+10 -1) 📝 `serve/test_reasoning_loop_recovery.py` (+18 -0) </details> ### 📄 Description Fixes #1753. **What it changes:** reasoning loop recovery (opt-in, #728) now also checks the last 2,048 chars of the reasoning for a period of at most 64 chars, before the word count. A periodic tail reads as coverage 1.0, so both `stop` and `recover` act on it. This is the shape #1753 replayed: a greedy run that writes its loop as one long word (a 24k-digit string cycling the 11-digit pattern 58747693387) is a single word to the 2,000-word window, and it never repeats one token because the tokenizer has no multi-digit tokens, so both guards passed it and the run burned the whole reasoning budget (24,599 and 32,791 tokens in the captured runs, both answering 1). **What it leaves alone:** the word count, its thresholds, the check cadence and the recovery splice are unchanged, and the check runs only when `reasoning_loop_recovery` is on, so the default path is byte-identical. No engine change. The issue's engine-level variant (extending #606 to short periods) would also protect users who have not opted in; this PR is the server-side half and uses the exact 2,048-char / 64-period window the issue author replayed across 70 captured reasonings (both digit-string runs caught, zero false fires). **How I checked:** `python -m unittest serve.test_reasoning_loop_recovery`, 18 tests, all pass. New tests cover the issue's cases directly: the digit cycle scores 1.0, a non-periodic 2,893-char digit string scores 0, a 1,100-char tail too short to judge scores 0, and a stop-mode run with MockEngine whose script is the digit string now ends at 2,560 tokens instead of running to the budget. Also ran the full serve suite (595 tests): the 8 errors there also error on an unmodified clone (they need the real tokenizer files and Windows job objects), nothing else changed. CPU only, no GPU involved. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 15:29:55 +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#3665
No description provided.