---
slug: "pi-cache-ttl-config"
source_type: "readme"
source_url: "https://cdn.jsdelivr.net/gh/mackenney/pi-cache-ttl-config@main/README.md"
repo: "https://github.com/mackenney/pi-cache-ttl-config"
source_file: "README.md"
branch: "main"
---
# pi-cache-ttl-config

A [pi coding agent](https://shittycodingagent.ai) 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

```bash
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.
