[PR #1854] [CLOSED] Loop guard: catch a young sentence loop, splice medium effort on recovery #3722

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

📋 Pull Request Information

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

Base: main ← Head: loop-guard-early-detection-and-medium-splice


📝 Commits (1)

  • 7c9b3a7 loop guard: catch a young sentence loop and splice medium effort on recovery

📊 Changes

3 files changed (+167 additions, -19 deletions)

View changed files

📝 docs/DETAILS.md (+9 -6)
📝 serve/server.py (+49 -13)
➕ tools/loop_guard_test.py (+109 -0)

📄 Description

A production agent session this week looped inside its reasoning: one ~20-word sentence, 15 times in a row, carrying a stale premise from the previous turn. Two small additions to the #728 guard, both behind the existing opt-in "reasoning_loop_recovery" key.

Early detection. The coverage look measures the last 2,000 words, so a young loop stays under the 25% line while it burns budget (this one measured ~15% at 15 repetitions, ~1,000 tokens spent before the guard could see it). A parallel trigger now fires when the same sentence runs 5 times in a row at the end of the reasoning. Pieces shorter than 8 words and 40 characters are out of the count, so repeated code, short lines and numbered enumerations stay safe; interleaved repetition remains the coverage look's job.

Medium effort recovery. focused_recovery_prompt now matches the medium sentence as well as the xhigh one and splices it to low, so a medium-effort request gets the same rescue. The coding-agent report in #728 looped at effort medium, the shape this opens up. The xhigh splice is byte-identical; a test pins that.

Checked: tools/loop_guard_test.py, 17 assertions (splice parity, medium, the None cases, the production shape, the length gate, CJK, interleaving, a coverage regression), plain python, no GPU or model needed. Not tested: a live looped session end to end.


🔄 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/1854 **Author:** [@Yunado](https://github.com/Yunado) **Created:** 10/10/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `loop-guard-early-detection-and-medium-splice` --- ### 📝 Commits (1) - [`7c9b3a7`](https://github.com/Niko1221/Strata/commit/7c9b3a7a6185fc229e2c3f9b40a7d37ac956e7f5) loop guard: catch a young sentence loop and splice medium effort on recovery ### 📊 Changes **3 files changed** (+167 additions, -19 deletions) <details> <summary>View changed files</summary> 📝 `docs/DETAILS.md` (+9 -6) 📝 `serve/server.py` (+49 -13) ➕ `tools/loop_guard_test.py` (+109 -0) </details> ### 📄 Description A production agent session this week looped inside its reasoning: one ~20-word sentence, 15 times in a row, carrying a stale premise from the previous turn. Two small additions to the #728 guard, both behind the existing opt-in `"reasoning_loop_recovery"` key. **Early detection.** The coverage look measures the last 2,000 words, so a young loop stays under the 25% line while it burns budget (this one measured ~15% at 15 repetitions, ~1,000 tokens spent before the guard could see it). A parallel trigger now fires when the same sentence runs 5 times in a row at the end of the reasoning. Pieces shorter than 8 words and 40 characters are out of the count, so repeated code, short lines and numbered enumerations stay safe; interleaved repetition remains the coverage look's job. **Medium effort recovery.** `focused_recovery_prompt` now matches the medium sentence as well as the xhigh one and splices it to low, so a medium-effort request gets the same rescue. The coding-agent report in #728 looped at effort medium, the shape this opens up. The xhigh splice is byte-identical; a test pins that. Checked: `tools/loop_guard_test.py`, 17 assertions (splice parity, medium, the None cases, the production shape, the length gate, CJK, interleaving, a coverage regression), plain python, no GPU or model needed. Not tested: a live looped session end to end. --- <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:17 +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#3722
No description provided.