How Claude Code, OpenCode and Pi place prompt-caching breakpoints differently

arpit_bhayani · x · 2026-10-17

Arpit Bhayani breaks down how different coding harnesses exploit prefix-based prompt caching: as long as the prefix is unchanged, inference for that portion is skipped, but any early change invalidates everything after it, so prompts must be ordered from most stable to most volatile.

Some harnesses cache beyond system messages — up to the last couple of turns — reusing cached computation across use cases sharing a system prompt and across turns in a conversation. The pattern: static first, volatile last, stable key per session. Break the order once (e.g. editing the system prompt mid-session) and you pay for the entire prefix again in both cost and energy.

Original post →

More from coding & agent

coding & agent channel →