Install
Install with PiG
pig install npm:@sh1so6/pi-cache-ttl-mainInstall with Pi
pi install npm:@sh1so6/pi-cache-ttl-mainReview before installing
Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.
Pi manifest JSON
The pi field of package.json.
{
"extensions": [
"./index.ts"
]
}README
Written by the package's publisher, shown as published in version 0.1.3 (README.md). PiG does not review it.
@sh1so6/pi-cache-ttl-main
English | 日本語
Pi extension. Makes the Anthropic prompt cache last 1 hour (ttl 1h) for the main session only. Subagents are left untouched.
This stops the cache from expiring while you wait 5–60 minutes for background subagents, which would otherwise force a ~150k-token rewrite every time.
pi install npm:@sh1so6/pi-cache-ttl-main
- Command:
/cache-ttl(on/off, write count,cacheWrite/cacheWrite1hof the latest turn) - Config (optional):
~/.pi/agent/cache-ttl-main.json{ "enabled": true } - The before-expiry trigger of
@sh1so6/pi-context-relayrelies on the 1h cache (cacheWrite1h > 0) this extension enables. - Main/subagent detection uses
ctx.mode(tui/rpc= main,print/json= subagent;hasUIonly when no mode is reported) and never the session name: aworker#<8hex>session that a person resumes is main and gets the 1h cache. This relies on pi-subagents binding children without a UI context (Pi then reports modeprint; checked against pi-subagents 0.23.2 / Pi 1.5.1). If a future pi-subagents gives children a UI context ormode: "tui", they would be treated as main (the regression tests inindex.test.mjspin the current rule). RPC reportinghasUI: truewas verified on Pi 1.5.1 only (not 1.5.2); the mode-based rule does not depend on it. - See the header comment of index.ts for details and limitations.