pi-cache-ttl-config
v0.1.1
Published
Dynamically switch the Anthropic prompt-cache TTL between 5m and 1h mid-conversation in the pi coding agent
Downloads
286
Maintainers
Readme
pi-cache-ttl-config
A pi coding agent extension that lets you dynamically switch the Anthropic prompt-cache TTL between 5 minutes (default) and 1 hour mid-conversation.
Useful when a conversation turns out to be slower than expected and you want cache entries to survive the default 5-minute window — without having to restart the session.
Install
pi install npm:pi-cache-ttl-configUsage
| Action | Effect |
|--------|--------|
| /cache-ttl | Toggle between 5m and 1h |
| /cache-ttl 1h | Switch to 1-hour TTL |
| /cache-ttl 5m | Switch back to 5-minute TTL (default) |
When 1h is active, a cache:1h indicator appears in the status bar.
How it works
Pi writes cache_control: { type: "ephemeral" } on message blocks (5m, Anthropic's default). This extension hooks into before_provider_request and injects ttl: "1h" into every cache_control block in the outgoing payload when 1h mode is active.
Switching back to 5m removes the ttl field, reverting to default behaviour.
