Compact oversized Pi tool results with transparent previews and spill files.
pi-diet keeps Pi sessions lean by filtering runaway tool outputs before they bloat model context and session JSONL files. Small results pass through unchanged. Large results are saved losslessly under ~/.pi/agent/pi-diet/spills/ and replaced with a compact preview, tail, omitted-size count, and spill path.
From npm:
pi install npm:pi-dietFrom GitHub:
pi install git:github.com/ProbabilityEngineer/pi-dietFor local development without installing:
pi -e ./index.tsEarly MVP, but validated against a real Pi session for oversized bash output.
- pass through small tool results unchanged
- compact oversized tool results automatically via the Pi
tool_resulthook - spill full original output to disk before replacing model-visible content
- preserve transparent access to the full output via a spill-file path
- provide specialized previews for bash, read-image, noisy LSP JSON, and generic search-style output
thresholdChars: 64000headChars: 8000tailChars: 8000
/diettoggles on/off/diet status/diet on/diet off
Ask Pi to run a command with very large output. Instead of storing the whole result in model context, pi-diet will replace it with a compact marker and a spill path like:
[pi-diet: compacted oversized bash result]
Original size: 102955 chars
Full output: ~/.pi/agent/pi-diet/spills/...
Rescue a single session file:
node scripts/rescue-session.mjs ~/.pi/agent/sessions/.../session.jsonl --out /tmp/pi-diet-rescueRescue every session file under a directory:
node scripts/rescue-session.mjs ~/.pi/agent/sessions/some-project --out /tmp/pi-diet-rescuenpm testpi-diet does not silently discard oversized tool results. It writes the full original result to a spill file first, then replaces the model-visible content with a compact preview.