Prompt order determines caching savings for AI agents
Prompt caching reduces AI agent costs by reusing the computed state of an identical request prefix. Any change breaks reuse from that point onward, making prompt structure critical for agents that repeatedly send tools, instructions and conversation history. Manus cited Claude Sonnet input rates of $0.30 per million for cached tokens against $3 for uncached ones.
Requests should run from the most stable content to the most dynamic: fixed tool definitions, system instructions, reference material, session details and an append-only conversation. Timestamps near the beginning, reordered tools, inconsistent JSON formatting, personalized system prompts and edits to earlier messages can invalidate reusable content. Anthropic builds its prefix from tools, then the system prompt, then messages, so changing a tool definition disrupts every subsequent layer.
Anthropic exposes cache reads, writes and uncached input through its usage fields, allowing teams to track hit rates and catch regressions. OpenAI caches automatically for prompts of 1,024 tokens or more and reports cached usage. Shared worker prefixes and completing an initial cache write before parallel requests can improve reuse.
An illustrative Sonnet calculation puts a 30,000-token prefix across 40 steps at $3.60 without caching versus roughly $0.46 with caching, a reduction of about 87 percent. Added conversation tokens reduce the overall savings. Short prompts, mostly unique requests and infrequent traffic offer less benefit, making measurement essential.