New Tool Radar

AI Concepts

How to Place a Cache Breakpoint on the Stable Part of a Prompt

Place a cache breakpoint on the last block that stays the same from one request to the next.

Schematic illustration of place a cache breakpoint on the stable part of a prompt: step one sort the prompt by change, step two mark the last stable block, step three keep the tail dynamic.

Prompt caching reuses a prefix: the system checks whether the prompt up to a cache breakpoint was cached by a recent request, and only an identical prefix can hit. The breakpoint therefore belongs on the last block that stays the same from one request to the next. Put it too early and you cache too little; put it after a changing block and the cache never hits.

Prerequisites

  • A prompt with stable parts, such as tools, system instructions and a reference document, and a changing part, such as the user’s question.
  • Access to explicit cache breakpoints, with cache_control on content blocks.
  • A way to read the usage fields to confirm the hit.

Steps

Step 1: Sort the prompt by change

List the prompt’s blocks in order: tools, system, messages. Mark each one stable or changing. The cache covers the full prefix in that order, up to and including the block with the breakpoint.

Step 2: Mark the last stable block

Place cache_control on the last stable block. Everything before it is cached; everything after it stays dynamic and is processed fresh each time.

Step 3: Keep the tail dynamic

Put the changing question after the breakpoint, and never put a changing block before it. If two parts change at different rates, use more than one breakpoint, up to four per request.

Worked example: Bluebell Bakery order assistant

The fictional Bluebell Bakery’s prompt has 4 blocks: tools, system instructions, a product list, and the customer’s question.

Block Changes Breakpoint Cached
Tools Never No Yes, as prefix
System instructions Never No Yes, as prefix
Product list Weekly Yes Yes, up to here
Customer question Every request No No: processed fresh

The breakpoint sits on the product list, the last stable block, so the tools, system and product list are cached and only the question is processed fresh.

Expected result. The breakpoint is on the last stable block, and the usage fields show the stable prefix being read from cache. UNTESTED: this guide was not run against a live model or API. The worked example below is fictional practice material, and its result is the expected result, not a measured one.

Limits

  • A breakpoint does nothing if the prefix before it is too short; each model has a minimum cacheable length.
  • Up to four breakpoints are allowed per request; more than that is rejected.
  • This guide does not cover automatic caching, which places the breakpoint for you.

Sources

See all