pi-cache-ttl-config

内容来源:README.md(说明文档) · 原始地址 · 查看安装指南

原始内容

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.