4 / 10
Как мониторить cache hit rate и retry rate для LLM в production: prompt cache stats, retry observability?
Anthropic возвращает в usage: cache_creation_input_tokens (новый cache write) + cache_read_input_tokens (cache hit). OpenAI prompt caching (Oct 2024) — automatic для prompts ≥1024 токенов, в usage.prompt_tokens_details.cached_tokens. Считаем cache hit rate = cached / (cached + non_cached_input) и шлём в Prometheus / Langfuse. Retry rate = retry_count / total_requests; alert когда > 5% (провайдер деградировал, rate limit, transient errors). Helicone имеет native cache + retry metrics; Langfuse — через metadata.cache_status + metadata.retry_count. Низкий cache hit rate (< 50%) = неоптимальная prompt structure (cached prefix меняется).