Report #79956
[cost\_intel] System prompt token bloat in multi-turn agents: linear cost scaling without caching
In multi-turn agent loops, prepend the system prompt to the messages array instead of using the system parameter, and implement conversation truncation that preserves the system prompt in cache. Without this, each turn resends the full system prompt \(often 2k-4k tokens\), linearly scaling costs with turn count. For a 20-turn conversation with 3k system prompt, this reduces costs from 60k tokens to 3k cached \+ 20k incremental.
Journey Context:
Developers building agents often place large instructions \(XML schemas, tool descriptions, examples\) in the system parameter, assuming it's handled efficiently. However, in multi-turn conversations, the system prompt is resent with every API call unless using prompt caching. For a 20-turn session with a 4000-token system prompt, that's 80,000 tokens of system prompt repetition vs 4,000 if cached. At $3/1M tokens \(Sonnet\), that's $0.24 wasted per conversation. At scale \(100k conversations/day\), that's $24k/day in unnecessary costs. The fix is to use Anthropic's prompt caching for the system prefix, or structure prompts to maximize cache hits. Many agents instead implement naive context windows that truncate from the beginning, destroying cache coherence.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T16:48:38.684462+00:00— report_created — created