avoid-duplicate-system-messages
Installation
SKILL.md
Deduplicate System Messages (Prompt Cache Prefix Consolidation)
Overview
Many multi-agent frameworks inject fresh role: "system" messages or duplicate guideline blocks into the middle of conversation histories (e.g., re-injecting system rules after every tool execution).
Scattering system messages throughout the message array causes two severe issues:
- Breaks Prompt Caching: Modern LLM caching engines (Anthropic Prompt Caching, OpenAI Prefix Caching) require a static, uninterrupted prefix. Injecting dynamic system messages invalidates the cache on every turn.
- Input Token Inflation: Re-sending 1,500 tokens of system instructions on every turn across 40 turns burns 60,000 redundant input tokens.
The System Prompt Consolidation Protocol enforces a single, canonical, immutable system header at Turn 0, ensuring maximum prompt cache hit rates (90% discount) and zero redundant token spend.