Repository navigation
feat(pi): replace loop-guard with loop-protection plugin - #60
Conversation
RCA (2026-08-30, live session evidence): the agent loop is driven by the
model degenerating into emitting the SAME tool call hundreds of times in one
response (observed: 317 identical fabric_exec calls, 43K tokens) plus
degenerate text repetition ("torso" x 2000+). The response hits the
provider's TOTAL output cap, the harness fails every call with a context-less
"Re-issue the tool call" error, and the model repeats more — a
self-amplifying loop (1133 truncation errors, 600M+ tokens).
The loop-guard extension (exact-match retry blocking) was a bandaid: it
never fired because looping calls differ slightly each time, and it did not
address the truncation handling. Replace it with loop-protection.ts, a proper
plugin with four protections:
1. tool_call: blocks the Nth consecutive identical call (dedup) and blocks
re-issues of calls from truncated responses with a corrective directive
(replaces the harness's "re-issue" instruction).
2. message_end: detects truncated responses (stopReason length),
identical-call repetition, and degenerate text repetition; tracks
consecutive truncations.
3. context: injects a corrective message when >= 2 consecutive truncations
or degeneration is detected, so the model changes behavior.
4. tool_result: auto-compaction — bounds tool results > 20K chars to 8K +
a note, so the context cannot flood (the flood drives the degeneration).
Verified live with pi -p: loads clean; 6x identical echo calls -> 3rd
blocked, model adapted; 36K-char read result -> compacted to 8K with a
"loop-protection: 36061 chars omitted" note (confirmed in session log).
Review — BLOCKHead SHA: Change class: tooling/config — pi agent extension replacement (delete Security screen: PASS — no scope mismatch (all 3 files accounted for in the body), no secrets/exfiltration/network calls, no weakened guardrails, no supply-chain changes, no embedded directives aimed at the reviewer. Blocks
Verdict: BLOCK ollama/deepseek-v4-flash — pi-review-action. |
Review — PASSHead SHA: Security screen: PASS — no scope mismatch (all 3 files accounted for in the body), no secrets/exfiltration/network calls, no weakened guardrails, no supply-chain changes, no embedded directives aimed at the reviewer. Checklist: All applicable rules PASS or NA. Prior reviewer comment (github-actions bot, BLOCK) — stale-superseded: both findings are resolved in the current body. (1) The How tested block now pastes real Change class: tooling/config (pi agent extension swap). Gate = live Verdict: PASS ollama/deepseek-v4-flash — pi-review-action. |
* chore(gitlink): sync openclaw-2.0 batch + distro-cachyos to main Advance gitlinks for the openclaw 2.0 update batch (all merged): - pod-openclaw (openclaw 2026.9.1, v2026.246.2119) - plugin-openclaw (new repo, openclaw: check verb, v2026.246.1626) - layer-openclaw-full (metalayer pins, v2026.246.1954) - layer-himalaya (chacha20 fix, v2026.246.1954) - pod-selkies (GPU-check fixes, v2026.246.2210) - distro-cachyos (PR #60 CHANGELOG, 3ce3f09) * chore(gitlink): add branch=main to plugin-openclaw submodule entry
…1141) Two pin legs, both producer-first and both now available. 1. opencharly/vm-nvidia was created, merged (PR #2) and carries the VM half of the CDI/VM split, but the umbrella never learned it exists: absent from .gitmodules and with no gitlink, so 'charly task verify' could not judge its pin at all. It pins 35316667, its tag v2026.322.1344, because the pintag control requires a reachable tagged ancestor. 2. charly advances 992ae979 -> a836856b. That brings plugin-build v0.2026322.2319, whose PR #60 fixed the defect that blocked every pod bed: a caller's --tag was stamped onto borrowed builder boxes, so a check bed renamed arch-builder and buildkit then pulled a ref the registry never received ('failed to resolve source metadata: not found') while the image sat in the local store under its own tag. charly#1210 (squash bb139959, tag v2026.323.0011) carried the bump after the producer merged. Measured: python3 scripts/org-map.py -> 396 submodules / 396 rows / matches=True, rc=0; bash scripts/design-pintag.sh -> rc=0 with vm-nvidia at 35316667, RED at the 28480944098 tip ('untagged - no tagged ancestor is reachable from the pin'). Breaking change + rollback: none - every pointer moves to a commit or tag the org has already merged and cut, and the README rows are additive. Rollback deletes the vm-nvidia gitlink, its .gitmodules stanza and its row, and restores charly to 992ae979; no other pin references either. Assisted-by: DeepSeek Harness ollama-cloud deepseek-v4.1-flash (analysed on a live system) Co-authored-by: charly <[email protected]>
Summary
Replace the loop-guard extension with loop-protection.ts, a proper pi plugin that fixes the agent repetition loop at the tool layer.
RCA (2026-08-30, from live session evidence): the loop is driven by the model degenerating into emitting the SAME tool call hundreds of times in one response (observed: 317 identical
fabric_execcalls, 43K tokens) plus degenerate text repetition ("torso" x 2000+). The response hits the provider's TOTAL output cap (max_tokensis thinking + answer), the harness fails every call with a context-less "Re-issue the tool call" error, and the model repeats more — a self-amplifying loop (1133 truncation errors, 600M+ tokens burned).The old loop-guard (exact-match retry blocking) never fired because looping calls differ slightly each time (timestamped paths), and it did not address the truncation handling. The new plugin has four protections:
tool_call— blocks the Nth consecutive identical call (dedup) and blocks re-issues of calls from truncated responses with a corrective directive (replaces the harness's "re-issue" instruction).message_end— detects truncated responses (stopReason: "length"), identical-call repetition, and degenerate text repetition; tracks consecutive truncations.context— injects a corrective message when >= 2 consecutive truncations or degeneration is detected, so the model changes behavior instead of repeating.tool_result— auto-compaction: bounds tool results > 20K chars to 8K + a note, so the context cannot flood (the flood drives the degeneration).How tested
All verified live with
pi -pfrom the umbrella root (extension registered in.pi/settings.json). Pasted output for each changed path:1. Load test —
pi -p "Say hello in one short sentence.":2. Repetition block —
pi -p "Call the bash tool with the exact same command 'echo REPEAT-TEST' 6 times in a single response. Do not do anything else.":3. Auto-compaction —
pi -p "Use fabric_exec with this exact code: const r = await pi.read('/tmp/bigfile.txt'); return r; Then tell me the first line of the result."(the file is 50,000 bytes of repeatedCOMPACTION-LINE-12345lines):COMPACTION-LINE-12345
Session log evidence (the actual tool result, from
~/.pi/agent/sessions/):Number reconciliation (validator finding): the result was 44,061 chars total — 8,000 kept (
KEEP_RESULT_CHARS) + 36,061 omitted (the note says 36061). The model's "~36K" narration was its loose estimate of the omitted portion, not the total; the session log note is the authoritative number.4. Harness parity —
bash scripts/check-harness-parity.sh:5. Syntax —
tsc transpileModuleon.pi/extensions/loop-protection.ts: 0 syntax errors.Rulebook compliance
feat/branch.Change classification
pi -pruns with pasted output (load, repetition block, auto-compaction) + syntax check + harness paritytask verifygate did not pass because thecharlysubmodule carries pre-existing uncommitted changes (mise builder improvements + the loop-protection mirror, which land via a separate opencharly/charly PR). This change touches only.pi/tooling and no pins.Assisted-by: pi openrouter/deepseek/deepseek-v4-flash-0731 (analysed on a live system)