prxy.monster API-key BYOK is live. Start free

prompt-optimizer

Category: optimization · Cloud + Local · Status: v1.0 — production

Anthropic’s prefix cache rewards stable prefixes: identical leading bytes get cached for ~5 minutes. The cheapest input tokens are the ones never re-billed. This module makes sure you’re getting that win automatically.

What it does

For non-Anthropic providers this is a no-op — the markers ride on the canonical SystemBlock and providers that don’t recognize them just ignore them.

When to use it

Configuration

prompt-optimizer:
  cacheControl: 'auto'         # 'auto' | 'manual' | 'off'
  separateStatic: true         # sort tools alphabetically — default true
  minCacheableChars: 1024      # don't bother below this — default 1024
  markAssistantHistory: false  # also mark last assistant turn — default false

Metrics emitted

Compatibility

Place prompt-optimizer AFTER ipcipc may reshape the prompt, then prompt-optimizer lays cache markers on the resulting stable prefix.

Source

src/modules/prompt-optimizer.ts