Skip to content

Detect repetition loops in thinking token streams - #511

Merged
TheGreatAxios merged 2 commits into
mainfrom
cl-6634-repetition-detector-ignores-thinking-token-loops
Aug 22, 2026
Merged

Detect repetition loops in thinking token streams#511
TheGreatAxios merged 2 commits into
mainfrom
cl-6634-repetition-detector-ignores-thinking-token-loops

Conversation

@TheGreatAxios

Copy link
Copy Markdown
Collaborator

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

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.
@linear-code

linear-code Bot commented Aug 22, 2026

Copy link
Copy Markdown

CL-6634

@TheGreatAxios
TheGreatAxios merged commit d2ec915 into main Aug 22, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant