Repository navigation
feat(pi): autodetect and break behavioral-rut loops in loop-guard - #52
Merged
Merged
Conversation
The loop-guard only blocked exact re-issues of calls from truncated responses (stopReason length). The 2026-08-30 second incident was a behavioral rut: the same successful tool call (sed -n on the same file ranges) re-issued 8+ times because each truncated response made the model re-run the same diagnostic instead of producing the deliverable. Add a per-call repeat detector (same tool + same args, N>=3) that blocks the repeat with a delegate/change-approach directive, and document the three loop signals + mandatory break response in APPEND_SYSTEM.md.
Contributor
Review — PASSHead SHA: Security screen: PASS — no scope mismatch (diff matches description exactly), no secrets/exfiltration (extension only counts tool calls in memory), no weakened guardrails (pi extension, not security machinery), no supply-chain changes. Checklist: All applicable rules PASS or NA.
Verdict: PASS ollama/deepseek-v4-flash — pi-review-action. |
github-actions Bot
pushed a commit
that referenced
this pull request
Oct 24, 2026
…sdk and distro-cachyos producer work (#684) (#685) The currency report named four pins that were not current, and every one of them is a fast-forward against its own remote: charly 6f62efbf3a -> 2386643d4 charly#1055, #1062, #1067, #1068, #1069 distro-cachyos 1893455d3a -> 6abe89522 distro-cachyos#157 -- the EDGE: charly's own box/cachyos gitlink, advanced by charly#1055 plugin-task 69223053ff -> 30c57809b plugin-task#47, #49, #52 sdk 306d3d15c2 -> d71b9abb4 sdk#475 The advance is the sanctioned verb's, never a hand-pin: `charly task sync` rolled the submodules to their default-branch HEAD and advanced the pins in the index, `charly task init` materialized the checkouts AT those pins, the worktree-local binary was rebuilt from the new charly pin (R9, stamp 2026.297.2323), and `charly task verify` judged the tree on the committed commit: 33 step(s), 0 failed, 0 skipped, zero warnings. The currency question, asked again on the same tree: 0 of 411 pin(s) NOT current -- every pin is at the ref its intent names. That closes the nine rows filed as #669: eight moved in #671, and distro-cachyos moved here once charly#1055 advanced the edge's source. The bump's own report counts index WRITES (406) where this commit carries the four gitlinks that MOVED; the difference is a defect in the verb that owns the count and is filed as opencharly/plugin-task#53. Refs #684, #669 Assisted-by: Claude Code minimax/minimax-m3.1-flash:cloud (fully tested and validated)
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.
Summary
The pi loop-guard extension (
.pi/extensions/loop-guard.ts) only blocked exact re-issues of calls from truncated responses (assistantstopReason: "length"). The 2026-08-30 second loop incident was a different class: a behavioral rut — the same successful tool call (sed -n "752,788p"/sed -n "1044,1091p"on the same file) re-issued 8+ times because each truncated response made the model re-run the same diagnostic to "recover" context instead of producing the deliverable. Those calls succeeded, so the truncation detector never fired.This change:
loop-guard.ts: a per-call (tool, serialized-args) repeat counter; the Nth identical call (N>=3) is blocked with a directive to change approach and delegate to a subagent. The block is not reset, so the model must change approach to proceed..pi/APPEND_SYSTEM.md: the three loop signals (repeated output-token-limit rejections, repeated identical tool calls, re-reading the same data) and the mandatory break response (never re-issue; delegate to a subagent; produce the deliverable).How tested
git commitran the umbrella pre-commit gate:check-policy-b: OK — 6 distro pins equal charly's gitlinks,umbrella-gates.ts parses (node type-strip pass),check-harness-parity: OK — 5 shared harness files identical to charly/,pre-commit: OK.Detector 1truncation-retry,Detector 2behavioral-rut),REPEAT_THRESHOLD = 3.sed -ncalls on the same file ranges before the fix.Rulebook compliance
scripts/check-harness-parity.sh"NOT in this list are umbrella-specific forks (extensions, prompts, tomls)"), so no charly mirror is required; the parity gate passed.Change classification
analysed on a live system— the loop it fixes was reproduced live this session; the fulltask verifypinning gate is unchanged by this docs/config-only change.Assisted-by: pi openrouter/deepseek/deepseek-v4-flash-0731 (analysed on a live system)