Tip: Stable Prompt Prefix Strategy Maximizes Coding Agent Cache Hits — Keep System Instructions and Tool Definitions Identical Between Requests
OpenAI·medium signal
The Codex agent loop documentation and arxiv research (2601.06007) converge on the same finding: for agents using providers with input caching (Anthropic, OpenAI), keeping system instructions, tool definitions, sandbox configuration, and environment context identical and consistently ordered between requests preserves long stable prompt prefixes that hit the cache. The challenge is that agentic workloads accumulate dynamic tool results that break the prefix. Solution: split the assembled prompt into a stable part (cache-friendly) and a dynamic part (tool results, conversation), ensuring the stable part always comes first.