pi-cache-ttl-config

Dynamically switch the Anthropic prompt-cache TTL between 5m and 1h mid-conversation in the pi coding agent

Package details

extension

Install pi-cache-ttl-config from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:pi-cache-ttl-config
Package
pi-cache-ttl-config
Version
0.1.1
Published
Apr 23, 2026
Downloads
263/mo · 161/wk
Author
mackenney
License
MIT
Types
extension
Size
13.1 KB
Dependencies
0 dependencies · 3 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

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-config

Usage

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.