# Agent with extensive instructions benefits from cachingpraisonai "Answer questions about the codebase" \ --prompt-caching --llm anthropic/claude-sonnet-4-20250514
from praisonaiagents import Agentagent = Agent( instructions="You are an AI assistant..." * 50, # Long system prompt llm="anthropic/claude-sonnet-4-20250514", caching=True)# First call caches the promptresult1 = agent.start("Question 1")# Subsequent calls use cached promptresult2 = agent.start("Question 2") # Reduced costresult3 = agent.start("Question 3") # Reduced cost
The --prompt-caching flag controls whether caching is requested on the wire, but Praison now automatically arranges memory and tools cache-friendly for supported models โ even without the CLI flag.In code, your agentโs system prompt, memory context, and tools are automatically organized to maximize cache hits:
Deterministic tool order: Tools sorted by function name
Stable memory prefix: Memory sections emitted in fixed order
Reserved boundary constant: A CACHE_BOUNDARY marker is defined for future structured-cache metadata; today the caching benefit comes entirely from stable ordering above