GLM 5.3 Flash: long agentic thinking turn degenerates into one repeated token at temperature 1.0; no server-side repetition control
Summary
A long agentic thinking turn degenerated into one repeated token, even with the model card's sampling.
Setup:
- GLM-5.3-Flash Q2, resident:
--ctx 393216 --warm-weights, disk KV. - M5 Max 128 GB, ds4 at 5379c1c.
- Client: Hermes Agent through
/v1/chat/completions, withtemperature 1.0,top_p 0.95,top_k 0,min_p 0andreasoning_effort: high.
After 29 consecutive tool calls in one user turn, the 30th reasoning block degenerated:
| generated tokens | context position | content |
|---|---|---|
| 0 – 5,779 | 128,794 – 134,573 | ordinary (increasingly terse) reasoning |
| 5,780 – 7,559 | 134,574 – 136,353 | hmm — repeated 890 times |
| 7,561 – ~20,600 | 136,355 – ~149,400 | token 68926 aaaaaaaa, repeated ~13,000 times |
Decode held ~21.9 tok/s throughout, and the client cut the stream after about 16 minutes. The token ids come from the continued checkpoint the server wrote at 143,360 tokens.
This is not greedy decoding, so it is a different case from #1196 and #1045 (DeepSeek at temperature 0 / 0.2).
What led into it
This model keeps all previous reasoning by default (clear_thinking is false). So the turn's earlier reasoning blocks made up 51% of the 128,794-token prompt. Their style drifted, measured per 1K characters of reasoning:
| reasoning blocks | hmm |
= |
|---|---|---|
| first 30 turns of the session | 0.8 | 0.2 |
| this turn, 1–10 | 2.0 | 8.7 |
| this turn, 11–20 | 3.4 | 12.4 |
| this turn, 21–29 | 10.4 | 18.2 |
| this turn, 30 | the loop above |
Engine side, as far as I can tell
- Not the checkpoints. Two
continuedcheckpoints were written during this decode, at 133,120 and 143,360 tokens. The first came 1,454 tokens before the stutter began, and the GLM payload save only reads state. - No repetition control. The request parsers silently skip
presence_penalty,frequency_penaltyandrepetition_penalty(json_skip_value); the sampler reads onlytemperature,top_p,top_k,min_pandseed. An OpenAI-compatible client has no way to push back on a loop, and nothing on the server stops a run of one repeated token beforemax_tokens.
Possible fixes
- Honour
presence_penalty/frequency_penaltyover the generated tokens, skipping speculative decoding while they are set. - Add a cheap guard in the decode loop: inside thinking, when the last few hundred generated tokens are an exact cycle with a short period, emit the think-close sequence so the model moves on to its answer. This is the trailing-block detection #1196 suggests, and it would also end the greedy loops there.
I can send a PR for either if you have a preference.