Registry / ai-ml / pi-cache-optimizer

pi-cache-optimizer

JSON →
library2.5.6jsnpmunverified

A Pi extension that improves KV cache and prompt cache hit rates for AI providers like DeepSeek, OpenAI, Claude, and Gemini. v2.5.6 (stable) maintained by jiangge. Key features: reorders prompts to put stable content first, compresses Pi skill lists, injects prompt_cache_key fallback for OpenAI-compatible requests, warns about proxy cache/compat issues, and displays session-scoped cache stats in the footer. Renamed from pi-deepseek-cache-optimizer for broader provider support. Uses peer dependency on @earendil-works/pi-coding-agent. Does not modify models.json. Opt-out via environment variables for prompt rewriting, skill compression, or OpenAI cache key fallback.

npm install pi-cache-optimizer
INSTALL
IMPORT
SIG · PI-CACHE-OPTIMIZER
P
pi-cache-optimizer
ai-mljavascriptv2.5.6
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

pi-cache-optimizer
pi install npm:pi-cache-optimizer
npm install pi-cache-optimizer
This is a Pi extension, not an npm package. Install via pi command.
/cache-optimizer
/cache-optimizer
/cache-optimizer help
The command is space-sensitive. Use slash commands in Pi chat.
PI_CACHE_OPTIMIZER_NO_PROMPT_REWRITE
export PI_CACHE_OPTIMIZER_NO_PROMPT_REWRITE=1
set PI_CACHE_OPTIMIZER_NO_PROMPT_REWRITE=true
Environment variable; unset to enable prompt rewriting. Use numeric 1, not boolean.

Shows basic installation, enable/disable commands, and persistent opt-out via environment variable.

# Install the extension in Pi pi install npm:pi-cache-optimizer # After install, run /reload in Pi # Enable cache optimization /cache-optimizer enable # Check status and compatibility /cache-optimizer doctor # To disable temporarily /cache-optimizer disable # Persistent opt-out for prompt rewriting (in Pi config/env) export PI_CACHE_OPTIMIZER_NO_PROMPT_REWRITE=1 # To uninstall pi remove npm:pi-cache-optimizer
Debug
Known issues
breakingRenamed from pi-deepseek-cache-optimizer. Uninstall old package first.
fix
pi remove npm:pi-deepseek-cache-optimizer && pi install npm:pi-cache-optimizer
affects: <2.0
breakingRequires @earendil-works/pi-coding-agent peer dependency to be installed.
fix
Ensure Pi is up-to-date and the peer dep is satisfied.
affects: all
deprecatedPI_CACHE_OPTIMIZER_OPENAI_CACHE_KEY=0 is deprecated; use PI_CACHE_OPTIMIZER_NO_OPENAI_CACHE_KEY=1
fix
Use PI_CACHE_OPTIMIZER_NO_OPENAI_CACHE_KEY=1 instead
affects: >=1.0
gotchaenable/disable are per-process; restart Pi or run /reload resets to startup behavior.
fix
Use environment variables for persistent opt-out.
affects: all
gotchaCache statistics are local and session-scoped; do not reflect provider-side cache behavior.
fix
Interpret stats as indicators only, not ground truth.
affects: all
gotchaThird-party proxies may ignore compatibility headers, causing 400 errors.
fix
Check /cache-optimizer compat output and remove unsupported settings.
affects: all
Errors
Common errors & fixes
pi: error: package not found: pi-deepseek-cache-optimizer
Package renamed; old name no longer exists.
fix
pi install npm:pi-cache-optimizer
Error: Unsupported parameter: prompt_cache_retention
Proxy does not support long cache retention.
fix
Remove compatible.longCacheRetention from models.json, or don't set supportsLongCacheRetention.
TypeError: Cannot read properties of undefined (reading 'models')
Missing or corrupted models.json.
fix
Restore ~/.pi/agent/models.json or re-run Pi setup.
Upgrade
Version history
2.5.6latest on npm
Audit
Dependencies
@earendil-works/pi-coding-agentrequiredRuntime code dependency (peer dep) - provides Pi agent hooks and model management
Agent activity
20 hits · last 30 days
node
18
Perplexity
1
Resources
pi-cache-optimizer — npm install pi-cache-optimizer · libregistry