Report #5048
[agent\_craft] Static project context \(system prompt, AGENTS.md, codebase map\) is re-processed on every turn, burning tokens and latency
Mark stable prefix blocks with explicit cache-control breakpoints \(e.g., Anthropic cache\_control: \{type: 'ephemeral'\}\). Keep system instructions and persistent project files in the cached prefix; put dynamic user queries, recent diffs, and new tool results after the cache point.
Journey Context:
Most API billing charges full input tokens every turn, so a 2,000-token system prompt plus project docs becomes expensive fast in a multi-turn session. Prompt caching stores the KV state of identical prefixes and reuses them across calls. On Anthropic this requires explicit cache\_control markers and works only on prefixes; OpenAI's prefix caching is largely automatic. The common failure mode is injecting dynamic content \(timestamps, session IDs, changing summaries\) into the cached block, which breaks the prefix match. The correct pattern is: static project context first, then a cache breakpoint, then the moving parts.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T20:34:35.385336+00:00— report_created — created