Repository navigation
Description
False positive: repeatRatio=0.5 flags normal Chinese long reasoning as "self-repeating reasoning loop" (v0.3.3)
Filed jointly by the user and DS (the DeepSeek Harness assistant).
Background
DeepSeek Harness (DSH) desktop, Windows, Chinese-language session.
Plugin: @argszero/cordis-plugin-thinking-loop-guard v0.3.3 (commit 0836b23).
We hit one false positive that seems worth reporting. This is about the plugin's defaults/algorithm/text, not about a local configuration workaround.
What happened
At a point where the user was waiting for the assistant to stop and let them decide, the plugin injected this steer:
You are repeating the same reasoning without acting (a self-repeating reasoning loop). Stop deliberating and either call a tool or produce a concise answer now.
But the assistant had just produced a normal, substantive answer (a ~748-character table), not an empty loop. The steer pushed it to keep acting instead of stopping.
Trigger path (from source)
- Config defaults:
maxThinkingSteps=3,minReasoningChars=2048,repeatRatio=0.5,similarityThreshold=0.8,escalate='steer',maxFires=4. - Listener:
ctx.on('llm/stream');LoopDetector.observeruns after each model call stream ends. observeorder:- reasoning < 2048 chars ->
return undefined(neither counts stalled nor resets it); - no text-delta/tool-call-delta ->
reasoning-only; - containment with the previous step >= 0.8 ->
repeated-material; - 4-gram repetition ratio >= 0.5 ->
low-entropy; - otherwise ->
stalled = 0.
- reasoning < 2048 chars ->
takeFire:stalled >= 3andfires < 4-> fire and reset.reactwithsteercallsagent.steer(notice); the detail"a self-repeating reasoning loop"is emitted only for thelow-entropyreason.- There is no pending-ask / "waiting for the user" state in the plugin (grep found none).
Two amplifiers we observed
- Short calls do not reset the counter. In the middle of the chain, a normal response had reasoning of 2,026 characters — 22 characters below
minReasoningChars=2048. It was skipped without resetting. The next long reasoning (ratio 0.6099) then made the third stalled count and fired. - CJK + 4-character gram bias. A 4-character window is roughly two Chinese words. Discussing the same decision point naturally reuses terms heavily. In that session, all 42 calls judged stalled were
low-entropy(ratios 0.5003–0.7283); none were genuinelyreasoning-only. The README itself reports normal table/log/CSS/JSON ratios of 0.72–0.84 — all above the 0.5 threshold.
Impact
- A misleading "self-repeating reasoning loop" message at a point where the user is waiting for a decision.
- Normal low-diversity text (tables, logs, JSON) can be systematically flagged as low-entropy.
- The false-positive rate is likely non-trivial in Chinese long-reasoning sessions.
Suggestions (plugin-level, not local config)
- Recalibrate the default
repeatRatio: 0.5 -> around 0.7, or provide a language-aware default; document the separation. In our replay, 0.65/0.75 produced zero fires. - Do not silently skip short calls: either count them in the state or explicitly reset; this removes the "2,026 < 2,048 skipped, next call fills the counter" accumulation.
- Reset
stalledon any substantive output; this is a more root-cause fix than only raising the threshold. - If the core exposes pending-ask / awaiting-user state, skip steer while a question is pending. This would be far more reliable than text heuristics.
- Use a larger gram window or language-aware normalization for CJK; the current 4-char gram makes normal Chinese repetition look pathological.
- Fix the detail wording:
low-entropydoes not necessarily mean "self-repeating reasoning loop"; something like "single-call low lexical diversity" would avoid overclaiming. - If 0.5 remains the default, add CJK calibration data/tests and state in the README that normal text can exceed the threshold.
Notes
- De-identified: no session id, no local paths, no user content; only version, platform/language, aggregate ratios, and source references.
- Happy to provide a synthetic minimal event sequence (three consecutive streams plus one short call) or a sanitized trace for a regression test.
- We are not asking for a local-only workaround; we are suggesting improvements to the defaults/state machine/documentation.
Activity
argszero commentedon Nov 21, 2026
I reproduced your source reading line by line, and it is correct on every point. But one measurement says the cause is not CJK, and that the proposed recalibration cannot work. Numbers below, then what I'll change.
Your reading of the state machine is accurate
Verified against
0836b23: defaults atsrc/index.ts:370-375;observeat:566-596follows exactly the order you list (floor at:570,reasoning-only:579,repeated-material:581,low-entropy:582, reset:588);takeFireat:607; and the detail stringa self-repeating reasoning loopis emitted only forlow-entropy(reactionMessage,:1092-1097). Your observation that the notice was written for a call that had produced a substantive table is the important one, and it follows directly from the order: thelow-entropybranch is reached only by calls that did produce output.It is not CJK — it is length
I ran the shipped metric (copied verbatim from the published build,
lib/index.js:236-299, identical tosrc/index.ts:485-498) over synthetic ~2,400-character samples:好。执行。repeatedEnglish scores higher than Chinese here, so a CJK-specific gram window would not help. What drives the number is text length: the same coherent Chinese material measures 0.5678 at 600 characters, 0.7302 at 1,200, 0.7813 at 1,800, 0.7932 at 2,048 and 0.8081 at 2,400. Because
minReasoningCharsis 2,048, every call the arm is ever allowed to judge sits in the range where ordinary prose already scores 0.79–0.82, and ordinary output-shaped text crosses the 0.5 threshold at roughly 600 characters.So raising the default to 0.7 would not fix it
Your session's 0.5003–0.7283 range is what ordinary long reasoning scores, not evidence of a loop. At 0.85 the split is still wrong in the other direction: natural text stops firing, but a legitimate log or table (0.9787) fires while a real loop (0.9983) is only 0.02 above it — the same unusable margin your suggestion 1 was aiming at. No threshold on this statistic separates the three cases, because they overlap.
Your amplifier 1 is deliberate, not an accident —
observe's own comment says a short burst "must not clear a run built from substantive steps", andtest/detection.spec.mjs:136pins it. But combined with the above it compounds rather than causes: three output-bearing calls all score aslow-entropy, and a brief call between them cannot reset the run.What I'll change
low-entropystops being a default trigger in0.4.0. It stays as an opt-in diagnostic; the guard's real loop detection is the mid-stream breaker, whose cycle and density rules use exactness and sentence units rather than a coverage ratio (README:150-160gives the same argument for the breaker). A statistic that flags natural prose at its own configured floor should not be able to steer a turn.low-entropywill say what was measured, not "a self-repeating reasoning loop".Two notes. My samples are synthetic — if you can share the sanitized trace you offered, I will run the shipped analyzer over it and put the real numbers beside these. And
0.3.3is a git-channel build: npm still serves0.3.1, whose defaults are identical (verified), so the fix will reach npm users later than git users.fix: turn the single-call low-entropy arm off by default
argszero commentedon Nov 21, 2026
0.4.0is out on the git channel — https://github.com/argszero/cordis-plugin-thinking-loop-guard at tagv0.4.0(commit9c74fff) — with the three changes I said I'd make:low-entropyarm is off by default.repeatRatio: 0disables it, the conventionsimilarityThresholdalready used. Opt in withctx.plugin(thinkingLoopGuard, { repeatRatio: 0.9 })if you want the reading anyway.0.3.3and each failure names the behaviour the release adds. The suite is 149/149.On your other suggestions, so the record is even:
observe's own comment, andtest/detection.spec.mjs:136pins it. It was an amplifier, not the cause.stalledon substantive output — that already happens (observeresets whenever a call is judged progress), and with the arm off it now happens on the ordinary path rather than only on a genuinely novel call.llm/stream,agents.get) exposes one. If a line ever does, that is the right instrument and better than any text heuristic.The offline analyzer's defaults now match the plugin's and it gained
--repeat-ratio, which is what your offered trace would be worth running against:node tools/analyze-session.mjs <session.jsonl> --repeat-ratio 0.5will report the arm's verdicts over your actual calls, so the numbers stop being my synthetic samples and become yours.One caveat on delivery:
0.4.0is git-only for now. npm still serves0.3.1, and I could not obtain a publish credential on this machine (both local browser profiles are signed out of npmjs.com), so the npm install line will keep giving you 0.3.1 until that is resolved. The git tag is the version with this fix.argszero commentedon Nov 23, 2026
0.4.1is out on the git channel — https://github.com/argszero/cordis-plugin-thinking-loop-guard at tagv0.4.1(commit39731c1) — and it matters to you for a reason that has nothing to do with the threshold:0.4.0could not be installed beside a current dsh at all.What was wrong
0.4.0's peer range ended at>=0.2.1-alpha.1 <0.3.0-0. Those comparators name no0.2.2tuple, so under npm's reading the range refused0.2.2-rc.5— the builddshpoints its ownnexttag at — and0.2.3-alpha.2, which isalpha. Every default install therefore ended inERESOLVE.The cordis peer had the same defect and had carried it longer:
^4.0.2refuses4.2.0-alpha.1under both readings and4.0.5-alpha.1under npm's, and those are exactly whatdsh-agentasks for on the0.2.3-alpha.2and0.2.1-alpha.1lines. dsh drops a bundle whose peers are unmet rather than warning about it, so on those lines the guard would have stopped loading and said nothing.What changed
One segment per measured line in both ranges, so npm's reading and the reading dsh's compatibility gate uses (
includePrerelease: true) admit the same set.0.2.2-alpha.2and0.2.2-alpha.3stay out, because nothing has been run against them.Measuring the new lines needed the measurement repaired first, and that repair is part of the release. The probe read each line's peer set off that line's
dsh-agentalone; from0.2.2-rc.5on,dsh-llmdeclares a peer of its own,@deepseek-ai/dsh-error, whichdsh-agentnever names. With--legacy-peer-depsthat package was simply absent from the probe's tree, so the suite died withERR_MODULE_NOT_FOUNDbefore a single test ran — which reads as "the line is broken" when it was the probe leaving a package out.npm run test:probe-linesnow re-measures every admitted line — thirty-two, including the twelve published since the record was last frozen — and all pass: 141 tests on the fifteen lines through0.2.0-rc.2, and 140 plus one skipped grammar arm on the seventeen from0.2.1-alpha.1on.Install:
Nothing in the detection behaviour moved.
repeatRatio: 0is still the default for the reason the previous comment gives, and the offline analyzer still takes--repeat-ratio. This release is about the package being able to load where you run it.On npm, unchanged and not promised: npm still serves
0.3.1,0.3.3and0.4.xexist only on the git channel, and I could not obtain a publish credential on this machine. So the git tag stays the version that carries both the threshold decision and this fix.fix: end the stalled run when a short call produced output
argszero commentedon Dec 4, 2026
0.4.2is out on the git channel — tagv0.4.2— and it fixes your amplifier 1, which I had defended as deliberate. That defence was wrong.What changed
observecheckedminReasoningCharsbefore it looked athasOutput:The floor exists so that repetition is not judged from too little material. That reason does not reach the output signal, which needs no material at all: the
reasoning-onlybranch already treatshasOutputalone as decisive (!hasOutput ? 'reasoning-only' : ...). So an output-bearing call below the floor was held to a rule the code applies nowhere else, and the count it produced was not consecutive.Your measurement follows directly. With the floor at 2,048, the 2,026-character answer left two stalls standing, the next stalled call made three, and the guard steered at the point where the user was waiting for a decision. The counter now counts consecutive stalled calls, which is what it has always claimed to count.
What did not change
A short reasoning-only burst still neither counts nor resets. That half is what the floor is for, and it now has its own test rather than sharing one with the case that was wrong.
Evidence
test/detection.spec.mjsstates both halves: the reasoning-only burst that must hold the run, and the answer that must end it.0.4.1build fails on its own assertion —a count that real work interrupted must not fire— not on a missing symbol or a broken fixture.observe, so--thresholdand--min-charsruns follow the same rule.Still open from your list
repeatRatio— unchanged,0stays the default, for the measurement in my previous comment: at the 2,048 floor, prose 0.81, a legitimate table/log 0.98 and a real loop 1.00 overlap, so no threshold on that statistic separates them.llm/streamnoragents.getexposes a pending-ask state. I would rather leave it named than imply progress.0.3.1. I checked again this cycle: the browser on this machine is signed out of npmjs.com and no token exists locally, so every fixed version remains git-only.v0.4.2is the tag that carries both the calibration decision and this fix.If your offer of a sanitized trace still stands,
node tools/analyze-session.mjs <file> --repeat-ratio 0.5 --threshold 3onv0.4.2and thestalledline pasted here would turn the amplifier claim into your numbers rather than my reconstruction of them.jilian-dsh commentedon Dec 5, 2026
Thanks — v0.5.0 is installed here (DSH 0.2.2-rc.5; the peer range from 0.4.2 onward covers it, so it resolves cleanly through the git channel).
Both changes check out on this end, and we verified them against the exported classes rather than by waiting for a live loop:
maxThinkingSteps: 2, two reasoning-only calls drive the detector to two stalled steps. A following call belowminReasoningCharsthat did produce visible output now returns no reason and resets the run (stalled === 0), sotakeFire()does not fire. That is exactly the behaviour we expected from your description, and it matches what we saw in production before the fix — the under-floor answer left two stalls standing.repeating-tool-arguments(trip on the first check stride past the cycle window), while a stream of non-repeating argument deltas passes without a trip.One question so we record the semantics correctly rather than inferring them: the single-call
low-entropyarm ships withrepeatRatio: 0(opt-in). Is the new tool-argument arm meant to be on by default atmaxRepeatedArgumentCycleChars: 64/minRepeatedArgumentCycleChars: 256, or should those be treated as defaults a user may set to 0 to opt out? We would like to note the intended reading for our own docs.Thanks again for turning the report around quickly.
argszero commentedon Dec 5, 2026
Answering both halves of your question, and then one thing
0.5.0got wrong that your question is a good excuse to fix.The reading you asked about
maxRepeatedArgumentCycleCharsis64andminRepeatedArgumentCycleCharsis256; a user turns it off by settingmaxRepeatedArgumentCycleChars: 0, the same conventionmaxRepeatedText: 0andsimilarityThreshold: 0already use. So: a default, and0opts out — not an opt-in.maxToolArgumentCharsdefaults to0(disabled) and exists for a deployment that would rather bound the size than judge the shape.low-entropyarm stays opt-in (repeatRatio: 0), and the reason is the measurement from your report rather than a matter of taste: it saturates with length, so at the 2,048-character floor ordinary prose already reads 0.79–0.82 and a legitimate table 0.98. The argument rule did not inherit that treatment because its statistic is exact periodicity, which measured 0 on every legitimate generated document in the calibration set — a false positive there is not a threshold question, so it does not need an opt-in to be safe.README v0.6.0 now states this directly in the tool-argument section, because "is it on, and how do I turn it off" should not have to be inferred from a
defaultin parentheses.The thing your question surfaced
Checking the shipped surfaces to answer you, I found
0.5.0had shipped the breaker without teaching the offline analyzer about the channel. That tool's entire purpose is "would the installed guard have cut this call?", and its own header states the rule: every breaker the plugin ships is answered there in the same release.It was not. On a fixture built from the five cycling fragments in discussion #14925:
0.5.0analyzer0.6.0analyzerargumentCharswouldBreakfalsetruewouldBreakBynullrepeating-tool-arguments(block 0, tripped at 287 chars)So the tool would have told you, about exactly the session
0.5.0was built for, that nothing would have been cut.0.6.0is out on the git channel — tagv0.6.0:What changed, in the terms you would verify against:
ToolArgumentBreakerover each call's argument deltas in stream order, per block index — the same object the plugin constructs, not a second implementation, so the verdict is the guard's and not an opinion.argumentCharsand, on a trip, the block index, the tool name and the size, so a cut in one of two parallel calls is attributable.--max-repeated-argument-cycle,--min-repeated-argument-cycleand--max-tool-argumentmatch the other rules' flags.tool-call-chunksrecord carries no block index of its own, so deltas read from it fold onto block 0. A file in that format cannot tell two parallel calls apart; rawchunkrecords and v1 events carry the index and are read faithfully.The regression suite gained six arms, and the one worth naming is the drift guard: every numeric key
Config({})resolves must appear in the analyzer's defaults at the same value, so the next release that adds a threshold and forgets the tool fails a test by name instead of shipping quietly. The first two arms fail on0.5.0on their own assertions.Your two verifications are what I would have asked for — both read against the exported classes, and the
stalled === 0reset is the amplifier-1 fix doing its job. If you re-run the analyzer against the session that started this issue, theargCharscolumn is the new one; a session whose stuck call never formed JSON should now show the call as cut rather than as progress.feat: hold the reaction while a session waits on a human
argszero commentedon Dec 6, 2026
Second request from this issue, done:
0.7.0holds the reaction back while the session is waiting on you.The npm package is still
0.3.1— this line ships on the git channel only — so install from the tag above.What changed
While a prompt is open, the guard no longer talks over it:
warn/steernotice is held, and delivered to the agent that produced it as soon as the last answer lands, so the resumed turn is still told;cancelis withheld, not replayed — aborting a paused turn answers nothing, and delivering that abort after you unblocked the turn would be worse;finishchunk is stream grammar rather than a message.deferWhileAwaitingHuman(defaulttrue) is the opt-out.The earlier "this is not observable" answer was wrong, and here is what made it right
I told you a plugin could not see whether a question was pending. That reading came from looking for an interaction service to inject. The wait is in the session log instead, and no extra dependency is needed:
approval/askedapproval/decidedask_user_questiontool/calltool/resultapproval/asked/approval/decidedare a pair the approval service writes inside one open turn (it throws rather than write the pair outside one), and the tool-result's identity is inside the message (createToolResultMessage({ callId })), not on the event. Both arrive onctx.on('session/event', (session, event) => …), which plugins may use — six in-tree packages already do.One boundary worth stating: the question signal is exact in
tool-ask-user's defaultlegacymode, where the call returns only after you answer. Intimedmode that tool acknowledges at once and your answer arrives later, so the guard cannot see the wait and behaves as it did before. A permission prompt is unaffected by that mode and is always observed.How it was verified
test/awaiting-human.spec.mjs, holds eight arms: the control that still steers with no prompt open, both prompt kinds holding and releasing, an ordinary tool call holding nothing, two prompts releasing only on the last answer, the withheld cancel plus its resumption afterwards, theturn/endsweep that stops one abandoned prompt from muting the guard, and the opt-out.0.6.0the four behaviour arms fail on their own assertions — the first one readsa prompt is open: the correction must not preempt it — 1 !== 0. The four that pass there are the "must still work" arms, which is the direction a test like this has to prove too.0.2.0-rc.2, and 149 plus the one grammar skip from0.2.1-alpha.1on. The probe's file list now includes the new spec, so it is measured on every line instead of only where I wrote it.That last point is a correction of my own instrument as well: the compatibility section had been quoting 141/140 since
0.4.1while the probe reported 142 on0.6.0's own tree, so the number was one arm stale before this release touched anything. It now states the measured figures and names the command that produces them.If you re-run your original session with
0.7.0, the thing to look for is not a different verdict — the loop is still detected and still cut — but the absence of a steering message in the pause around a question. If you see a correction land while a prompt is on screen, that is a case my two signals did not catch and I would want the session file.jilian-dsh commentedon Dec 6, 2026
Both replies read — thank you for turning these around, and for correcting the earlier “this is not observable” answer rather than leaving it standing.
We upgraded to
v0.7.0on the git channel (pinned at the tag; the peer range covers our0.2.2-rc.5). Our class-level contract re-ran against0.7.0and passes 7/7: the under-minReasoningCharscall that produced output still resets the run (stalled === 0,takeFire()staysundefined), and the shippedToolArgumentBreakerstill trips on repeating argument deltas while leaving non-repeating deltas alone.We then ran the analyzer three ways:
wouldBreak: 0,fired: 0, no argument break. The file still contains the threeplugin:thinking-loop-guardnotices with the old wording, so it is the same object we complained about.--repeat-ratio 0.5: 15 steps read aslow-entropy, but still zero fires — each reading is followed by an output-bearing call that ends the run. That is the amplifier-1 fix visible from the outside.repeating-reasoning, and fired at step 4 (fired: "repeated-material"), with a 70-chunk identical-text run reported asidentical-chunks. So the rule does cut a real loop; it does not merely report it.The argument channel also reports as you described: a synthetic repeating call gives
argumentChars: 656,wouldBreakBy: "repeating-tool-arguments"(tripped at 287 chars, block 0), and a healthy call givesargumentChars: 177with no trip.Two notes from the run:
tool-call-chunksfolds every delta onto block 0, so two parallel calls are indistinguishable there; rawchunkrecords carry the index.On the awaiting-human change: our environment asks questions constantly, so this is the fix we feel most directly. If we see a correction land while a prompt is on screen after
0.7.0is live, we will send you the session file rather than describe it.