Detect repetition loops in thinking token streams - #511
Merged
TheGreatAxios merged 2 commits intoAug 22, 2026
Merged
Conversation
Sample inference.thinking.delta on the same interval as text and abort as repetition on a hit. The cycle recorder now buffers thinking text separately and flushes it into partial.jsonl so a thinking-only abort stays diagnosable. Thinking detection folds digit runs to one placeholder with a shorter window/higher repeat threshold, catching a monotonic counter loop (observed live: ~64k thinking tokens of 0/1 1/2 2/3 ...) without touching the text path, which stays digit-preserving to avoid flagging numbered lists and tables.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Mid-stream repetition detection only watched inference.text.delta, so a model looping inside inference.thinking.delta (observed live: ~64k thinking tokens of a monotonic 0/1 1/2 2/3 ... counter) never tripped it and streamed until operator cancel. Thinking deltas are now sampled on the same interval and abort through the existing repetition salvage path, buffered separately in the cycle recorder and flushed into partial.jsonl so a thinking-only abort stays diagnosable.
Thinking detection folds digit runs to one placeholder with a shorter window/higher repeat threshold, which catches the monotonic-counter shape without risk since thinking is never rendered to the user. The visible-text path is untouched and stays digit-preserving, so numbered lists and tables keep not tripping.
Fixes CL-6634
https://linear.app/abklabs/issue/CL-6634