avtc-pi-prune-images
Payload-level rolling image eviction for pi: sends only the N most recent images per LLM call so providers with per-prompt image caps (e.g. GLM's 2) never reject the request. Session history stays intact.
Package details
Install avtc-pi-prune-images from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:avtc-pi-prune-images- Package
avtc-pi-prune-images- Version
1.0.0- Published
- Nov 1, 2026
- Downloads
- 348/mo · 348/wk
- Author
- avtc
- License
- MIT
- Types
- extension
- Size
- 8.7 KB
- Dependencies
- 0 dependencies · 0 peers
Pi manifest JSON
{
"extensions": [
"./index.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
avtc-pi-prune-images
Payload-level rolling image eviction for pi.
Providers may cap images per prompt (for example vLLM's --limit-mm-per-prompt '{"audio": 0, "image": 8, "video": 0}').
pi keeps every image in session history — pasted images and images returned by read — and re-sends the full history on every LLM call, so one image over the cap bricks the session with 400: At most X image(s) may be provided in one prompt.
This extension listens to the context event (fires before each LLM call) and replaces every image part older than the N most recent with a text placeholder.
Only the outgoing payload is pruned: the session file keeps every image for /tree, /export, and compaction.
Settings
~/.pi/agent/settings.json (project .pi/settings.json overrides):
{
"avtc-pi-prune-images": {
"keep-last-images": 8
}
}
keep-last-images: non-negative integer, ornullfor unlimited. Defaultnull— the extension is inert until you opt into eviction.0strips all images from the payload (payload-only equivalent of pi'simages.blockImages).
Invalid values warn once and leave messages unmodified.
Notes
- The setting is re-read before every LLM call, so edits apply live.
/treeto a point before an image-heavyreadremains the surgical fix when you want the images gone from history entirely.