Agent skill

Pi Loop Forensics

by dimetron in dimetron/pi-go

Diagnose pi-go agent loops and degenerate turns — "agent loop aborted", runaway thinking with no tool calls, repeated phrases.

MITAuto-check: notesAgent Workflows

Install Pi Loop Forensics

skills CLI
$ npx skills add dimetron/pi-go --skill pi-loop-forensics -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install dimetron/pi-go pi-loop-forensics --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/dimetron/pi-go.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.pi-go/skills/pi-loop-forensics .claude/skills/pi-loop-forensics && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
pi-loop-forensics
GitHub stars
207
Token cost
~2.1k tokens
SKILL.md length
1,002 words
Files
4
Skills in repo
21
Repo updated
First seen
Licence
MIT

At a glance

Diagnose pi-go agent loops and degenerate turns — "agent loop aborted", runaway thinking with no tool calls, repeated phrases.

  • Works in 4 steps: Sweep the corpus for scale and per-model… → Score individual logs → Discriminate the cause. Run all three… → …
  • Tasks that involve Autonomous loops
  • SKILL.md covers Where the evidence lives, How the guard actually works, Steps and Guidelines, plus 2 more sections
  • Runs Python and Shell scripts from its folder; calls python3 and bash; needs OLLAMA_API_KEY

What it does

Pi Loop Forensics is an agent skill from dimetron/pi-go. Diagnose pi-go agent loops and degenerate turns — "agent loop aborted", runaway thinking with no tool calls, repeated phrases. Discriminates genuine model repetition collapse from a race, a tool-parse failure, or a too-low guard, and A/B replays a seed session across providers.

Its SKILL.md is about 2.1k tokens, which your agent loads only when the skill is triggered. The skill folder holds 3 other files (for example `ab_replay.sh`, `scan_logs.py` and `score_run.py`).

It sits in Agent Workflows, covering Autonomous loops. The repository describes itself as: Go implementation of AI coding agent. The licence is MIT.

When your agent uses it

  • Tasks that involve Autonomous loops

Example prompts

  • “agent loop aborted”
  • “/pi-loop-forensics”

Requirements

  • Python 3
  • A Bash shell
  • A credential in OLLAMA_API_KEY

Workflow steps

4 steps, taken from the first numbered list in SKILL.md.

  1. Sweep the corpus for scale and per-model distribution
  2. Score individual logs
  3. Discriminate the cause. Run all three tests; do not stop at the first
  4. A/B replay across providers. Find a seed session whose **last persisted

What it can do on your machine

Read from SKILL.md and the folder at commit 24d1f2b. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships script files (Python and Shell), which the agent can run.

    Shell commands in SKILL.md call:

    • python3
    • bash

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names these keys or tokens, usually read from environment variables:

    • OLLAMA_API_KEY

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Pi Loop Forensics loads about 2.1k tokens when it runs. Until then it costs about 74 tokens; SKILL.md has 1,002 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~74
When it runs · the whole SKILL.md, loaded when a task matches
~2.1k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check: notes

The automated check noted patterns worth knowing about, such as sudo or a known installer.

  • NoteMentions a .env fileSKILL.md:159
    Keys live in `~/.pi-go/.env` **and** `<repo>/.pi-go/.env`; pi-go merges both

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from dimetron/pi-go at commit 24d1f2b, republished under its MIT licence (© dimetron). 1,002 words, ~2,100 tokens.

Download SKILL.mdSave it as .claude/skills/pi-loop-forensics/SKILL.md (or your agent's skills folder). This skill also uses 3 other files; get the full folder from GitHub.
name
pi-loop-forensics
description
Diagnose pi-go agent loops and degenerate turns — "agent loop aborted", runaway thinking with no tool calls, repeated phrases. Discriminates genuine model repetition collapse from a race, a tool-parse failure, or a too-low guard, and A/B replays a seed session across providers.

Loop Forensics

Use when a run dies with agent loop aborted: ..., or a model burns a long turn thinking without ever calling a tool. This skill decides why before anything is changed: the abort message names a symptom, not a cause.

Sibling skill pi-check-session-logs covers tool call errors. This one covers repetition and runaway turns. They do not overlap.

Where the evidence lives

WhatPath
Session logs (JSONL, one per run)~/.pi-go/log/<yyyy-mm-dd>/session-HH-MM-SS.log
Session state (resumable)~/.pi-go/sessions/<id>/ — events.jsonl, meta.json, trajectory.atif.json
Detector sourceinternal/tui/agent_loop.go

Log rows are {"time","type","content",...} with type in session_start, thinking, llm_text, tool_call, tool_result, user, error. The model name is on the session_start row — always record it, findings are per-model.

How the guard actually works

stuckDetector (internal/tui/agent_loop.go:119) has three independent arms:

  • observe — identical consecutive tool calls, trips at maxRepeatToolCalls=10. Pagination args are stripped first (volatileToolArgs), so paging one file collapses to one fingerprint.
  • observeError — same tool failing maxToolErrorStreak=10 times running.
  • observeOutput (:246) — the model's own text/thinking. Needs a period ≥ minOutputPeriod=16 bytes, ≥ minPeriodVariety=8 distinct bytes, and maxOutputRepeats=12 byte-exact back-to-back copies inside an 8 KB tail.

The third arm is the only one that sees a turn making no tool calls at all. outBuf is never reset across a run, and the thinking branch (:690) skips dedup.SkipText, unlike the text branch (:697).

Timeline caveat — check this before judging any old log. Sessions predating these commits cannot be compared against current behavior:

CommitLandedEffect
e069b342026-08-08 06:56:44 +0200added observeOutput (the phrase-repetition arm)
5a4cb8b2026-08-08 18:52:42 +0200stopped aborting productive polling (bash_output)

Steps

  1. Sweep the corpus for scale and per-model distribution:

    bash
    python3 .pi-go/skills/pi-loop-forensics/scan_logs.py

    Reports per model: session count, aborts, longest tool-free thinking run (max/p95), worst periodic repetition. Also lists aborted sessions and the top offenders. Loops are almost always concentrated in one model.

  2. Score individual logs:

    bash
    python3 .pi-go/skills/pi-loop-forensics/score_run.py ~/.pi-go/log/*/session-*.log

    Three metrics per log: think_run (longest tool-free thinking run), reps/period (longest byte-exact periodic tail), intent/calls ("let me write/run/test" phrases vs actual tool calls). A high intent:calls ratio is the signature of announce-but-never-act.

    reps>=12 is the reliable discriminator. The think_run>=20 arm is heuristic and does produce false positives on models that legitimately think in long bursts — confirm with reps before calling it a loop.

  3. Discriminate the cause. Run all three tests; do not stop at the first plausible one.

    • Race / double-emission? Hash every thinking payload in the session and count exact duplicates, and check timestamps. Genuine model output has zero duplicate payloads, varied lengths, and monotonic timestamps spaced by stream latency. Duplicated payloads or identical timestamps would mean pi-go re-emitted chunks — a real bug in the stream path.
    • Tool-parse failure? Grep thinking and text for tool-call syntax that leaked in as prose: <tool_call, <function, tool_calls, "name":...,"arguments", ```json, <think>, <|tool. If the model emitted a call the provider layer failed to parse, the raw syntax shows up in a text channel and the model never receives a result — which looks exactly like a loop. Zero matches rules this out.
    • Guard too low? Compare the tripping value against the corpus. Healthy sessions peak around 1 periodic repeat; the threshold is 12 byte-exact copies. If healthy runs sit far below the threshold, the guard is not the problem.

    If all three are ruled out, it is inference-level repetition collapse, and the fix is a provider/sampling question, not a pi-go parsing question.

  4. A/B replay across providers. Find a seed session whose last persisted event is the tool result immediately before the spiral — the degenerate thinking usually never gets committed to events.jsonl, so resuming restores the exact pre-failure state and the next turn is the one that broke.

    bash
    # From an isolated worktree — a resumed agent can write files.
    PI=/path/to/pi TRIALS=3 OUT=/tmp/ab-replay \
      bash .pi-go/skills/pi-loop-forensics/ab_replay.sh

    Arms are ollama-cloud, ollama-local, opencode (override with ARMS="ollama-cloud opencode"). Each arm runs a preflight one-shot first and is skipped with its error if credentials are dead, so a bad key costs one call instead of every trial. Override the seed with SEED=<session-id>.

    Per trial the script copies the seed to a throwaway session ID (the original is never mutated), rewrites meta.json (id/model/provider/workDir), resumes with --trace-http --mode print, scores the log, and deletes the copy.

    • Nothing pins temperature or seed, so reproduction is probabilistic — run several trials per arm and compare rates, not single outcomes.
    • --trace-http writes full request/response bodies to the session log. Credentials are masked (internal/provider/provider.go:440); prompts and source context are not.
    • Run from a git worktree, never the primary checkout: a resumed agent can write files.
Show full SKILL.md (286 more words)Show less

Guidelines

  • Always name the model and check it against the commit timeline before concluding anything about an old log.
  • An abort message describes the symptom the guard caught, not the cause. A correct abort on genuine degeneration and a false positive on healthy polling look identical in the log.
  • Ollama requests set only num_predict (internal/provider/ollama.go:104-110) — no repeat_penalty, repeat_last_n, temperature. A looping Ollama model currently has no tunable knob, which makes provider A/B the informative test.
  • When reporting, separate the guard behaved correctly from the model degenerated. Both can be true at once, and they imply different fixes.

Probing providers: pi ping is not trustworthy

Verified 2026-08-09. pi ping resolves URLs and credentials differently from the real agent path, so a ping failure is not evidence a provider is down. Confirm with a one-shot real run instead:

bash
./pi --model <model> --mode print "reply with exactly: OK"

Observed ping-only failures, all of which the real path handled fine:

SymptomCause
DNS resolution failed: lookup : no such host (empty host) on opencode/*ping never applies opencodeDefaultBaseURL (internal/provider/opencode.go:62)
<model>:cloud dials localhost:11434 despite OLLAMA_API_KEY being setping does not pass the key, so the cloud-URL switch (internal/provider/ollama.go:38) never fires
dial tcp [::1]:11434: connection refused while the daemon is upping's dialer picks the IPv6 literal; the Ollama daemon binds IPv4. Pass --url http://127.0.0.1:11434

Keys live in ~/.pi-go/.env and <repo>/.pi-go/.env; pi-go merges both (internal/config/config.go:387-389). Neither is in a shell profile, so an agent's own shell will not have them exported — but pi-go reads the files itself, so that only matters for scripts that gate on env vars.

Examples

  • /pi-loop-forensics — sweep all logs, report per-model loop distribution
  • "why did my run abort with 'repeated a 89-character phrase'" — steps 2 and 3
  • "does this loop happen on the other provider too" — step 4

© dimetron, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 3 other files in .pi-go/skills/pi-loop-forensics of dimetron/pi-go.

  • SKILL.md
  • ab_replay.sh
  • scan_logs.py
  • score_run.py

Open the folder on GitHubat commit 24d1f2b

Compare with similar skills

Pi Loop Forensics next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Pi Loop Forensics compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Pi Loop Forensics this skilldimetron/pi-go207—~2.1kAutomated safety check: NotesMIT
Show Me Your Work Decision Logcursor/plugins10k9 repos~1.6kAutomated safety check: PassNone
Autoresearch Iteration Loopuditgoenka/autoresearch6.5k1 repos~2kAutomated safety check: PassMIT
PUA Looptanweai/pua20k1 repos~1.1kAutomated safety check: PassMIT
AutopilotYeachan-Heo/oh-my-claudecode40k1 repos~4.4kAutomated safety check: PassMIT
Install Loop Engineeringcobusgreyling/loop-engineering11k1 repos~648Automated safety check: PassMIT

Similar skills

  • Official

    Keeps a TSV decision log for long or unattended agent runs, one row per decision with what, why, evidence and result, so a reviewer can check the work later.

    10k GitHub starsUsed in 9 repos~1.6k tokens
    Agent WorkflowsAuto-check passed
  • Autoresearch Iteration Loop

    uditgoenka/autoresearch

    Runs an autonomous modify, verify, keep-or-discard loop against any metric, with subcommands for planning, debugging, fixing, security audits, shipping and more.

    6.5k GitHub starsUsed in 1 repo~2k tokens
    Agent WorkflowsAuto-check passed
  • PUA Loop

    tanweai/pua

    Runs an unattended iterate-until-verified loop in which a user-set verify command, not the agent's own claim, decides when the task is finished.

    20k GitHub starsUsed in 1 repo~1.1k tokens
    Agent WorkflowsAuto-check passed
  • Autopilot

    Yeachan-Heo/oh-my-claudecode

    Takes a short product idea through requirements, design, planning, parallel implementation, QA cycles and multi-reviewer validation to produce working code.

    40k GitHub starsUsed in 1 repo~4.4k tokens
    Agent WorkflowsAuto-check passed
  • Install Loop Engineering

    cobusgreyling/loop-engineering

    Installs Loop Engineering into a project through the single @cobusgreyling/loop CLI, scaffolding a report-only loop and a readiness score.

    11k GitHub starsUsed in 1 repo~648 tokens
    Agent WorkflowsAuto-check passed
  • Loopy

    Forward-Future/loopy

    Discover, find, compare, audit, repair, adapt, craft, run, debrief, save, and prepare repeatable AI-agent loops for publication.

    3.2k GitHub stars~3.9k tokensUpdated 27 days ago
    Agent WorkflowsAuto-check passed

More from dimetron/pi-go

All 21 skills in this repo
  • Vhs E2E Gif

    dimetron/pi-go

    Record a test run, a TUI session, or any terminal command as a GIF with VHS and attach it to a GitHub PR as a release-hosted asset, never a repo commit.

    207 GitHub stars~1.7k tokensUpdated 7 days ago
    Auto-check passed
  • Agents Md

    dimetron/pi-go

    Generate AGENTS.md files for Go, Rust, TypeScript, and Java projects.

    207 GitHub stars~1.7k tokensUpdated 7 days ago
    Auto-check passed
  • Bubbletea Testing

    dimetron/pi-go

    A skill your agent uses whenever writing tests for Bubble Tea (charmbracelet/bubbletea) TUI applications in Go.

    207 GitHub stars~3.6k tokensUpdated 7 days ago
    Auto-check passed
  • Memory Index

    dimetron/pi-go

    Index a folder's contents into the MemPalace semantic memory for search and retrieval.

    207 GitHub stars~1.5k tokensUpdated 7 days ago
    Auto-check passed
  • Nightly Session Watch

    dimetron/pi-go

    Nightly sweep of the last 24h of pi-go sessions — anomalous runs, loop aborts, tool error rates, token waste, real prompt-token spend, and whether the observation and palace pipelines are still…

    207 GitHub stars~1.5k tokensUpdated 7 days ago
    Auto-check passed
  • Osx Tuning

    dimetron/pi-go

    Tune macOS resource limits and sysctls for best performance with Go development, Docker/OrbStack, and Linux VMs.

    207 GitHub stars~1.6k tokensUpdated 7 days ago
    Auto-check: notes

Categories

Questions about Pi Loop Forensics

What does Pi Loop Forensics do?

Diagnose pi-go agent loops and degenerate turns — "agent loop aborted", runaway thinking with no tool calls, repeated phrases. Pi Loop Forensics is an agent skill from dimetron/pi-go. Diagnose pi-go agent loops and degenerate turns — "agent loop aborted", runaway thinking with no tool calls, repeated phrases.

When should I use Pi Loop Forensics?

Pi Loop Forensics fits situations like: tasks that involve Autonomous loops.

How do I install Pi Loop Forensics in Claude Code?

Run `npx skills add dimetron/pi-go --skill pi-loop-forensics -a claude-code`. Or copy the skill folder (.pi-go/skills/pi-loop-forensics in dimetron/pi-go) into .claude/skills/pi-loop-forensics in your project. Claude Code loads it when a task matches its description.

How do I install Pi Loop Forensics in Codex?

Run `npx skills add dimetron/pi-go --skill pi-loop-forensics -a codex`. Or copy the skill folder (.pi-go/skills/pi-loop-forensics in dimetron/pi-go) into .agents/skills/pi-loop-forensics in your project. Codex loads it when a task matches its description.

Can I use Pi Loop Forensics in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add dimetron/pi-go --skill pi-loop-forensics -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/pi-loop-forensics, .gemini/skills/pi-loop-forensics, .github/skills/pi-loop-forensics and .opencode/skills/pi-loop-forensics in your project.

What does Pi Loop Forensics need to run?

Going by SKILL.md and its folder, Pi Loop Forensics needs Python and a shell for the scripts in its folder, the command-line tools its instructions call (python3 and bash) and credentials named OLLAMA_API_KEY. Our summary lists: Python 3; A Bash shell; A credential in OLLAMA_API_KEY.

Does Pi Loop Forensics access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Pi Loop Forensics safe to install?

Our automated static check of SKILL.md found notes only (mentions a .env file), nothing it rates as a warning. It is not a guarantee. Review the folder before installing.

What licence does Pi Loop Forensics use?

Pi Loop Forensics is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Pi Loop Forensics use?

About 2.1k tokens (SKILL.md is roughly 8.4k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Pi Loop Forensics?

Skills that share tags, products or a category with Pi Loop Forensics: Show Me Your Work Decision Log (cursor/plugins, 10k stars), Autoresearch Iteration Loop (uditgoenka/autoresearch, 6.5k stars), PUA Loop (tanweai/pua, 20k stars) and Autopilot (Yeachan-Heo/oh-my-claudecode, 40k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Pi Loop Forensics?

dimetron (a GitHub user) maintains it in dimetron/pi-go, which has 207 GitHub stars. The repository holds 21 skills in this directory. The repository was last updated on October 1, 2026.

Source: dimetron/pi-go on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.