mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-30 01:08:33 +00:00
The capture plane (parent commit) records each warming-enabled session's latest payload in Redis. This adds the consume side so every tier model's provider prompt cache stays warm while a session is active and tier switches bill as cache reads: - CacheWarmingRefresher.run_tick: single-pod via the Redis cron lock; when the injected PodLockManager has no Redis attached the refresher elects through a fallback PodLockManager bound to the warming store's own Redis, so multi-pod duplicate replays cannot happen whenever warming itself is active. Enumerates session records, drops idle sessions, skips keys that are deleted, blocked, expired, or at 95% of max_budget (fails open on lookup errors; the config-defined master key has no token row and stays eligible), and replays each due payload against every warm-set model with max_tokens=1, stream=False and response-cache bypass, bounded by a 10-replay semaphore. The warm set is warm_models or the first member of each tier pool, filtered to anthropic/bedrock deployments that support prompt caching; a deployment's declared custom_llm_provider wins over inference. Chat payloads replay via router.acompletion with internal metadata in the metadata slot; anthropic_messages payloads replay via router.aanthropic_messages with system and tool_choice forwarded and internal metadata in litellm_metadata, since metadata is the provider body field on that surface. Replays carry the loop-guard marker, the originating key's attribution, and the litellm_cache_warming tag unless tag filtering is enabled. Warmth stamps land even for failed attempts so a dead deployment is retried once per interval, not every tick. - proxy_server._complexity_cache_warming_loop: 30s tick modeled on the adaptive flusher (sleep-first, resolves llm_router fresh each tick, re-raises CancelledError, survives tick exceptions), started unconditionally at startup so hot-reloaded routers are covered. - ComplexityRouter._warm_aware_pick: consulted by _pick_model_for_tier on both the plain and plugin-narrowed branches. Prefers pool members whose warmth stamp is fresh within refresh_interval_seconds plus 60s slack, unions the served model while the session is active, and falls back to the existing pick when there is no session, record, store, or intersection. - README: Cache Warming section covering the YAML shape, the Redis and store_prompts_in_spend_logs prerequisites, the Redis Cluster limitation, spend attribution and tagging, max_sessions semantics, and the session_affinity interplay. |
||
|---|---|---|
| .. | ||
| _experimental/mcp_server | ||
| a2a | ||
| agent_endpoints | ||
| anthropic_endpoints | ||
| auth | ||
| batches_endpoints | ||
| client | ||
| common_utils | ||
| config_resolvers | ||
| db | ||
| discovery_endpoints | ||
| enterprise_billing | ||
| experimental/mcp_server | ||
| google_endpoints | ||
| guardrails | ||
| health_endpoints | ||
| hooks | ||
| image_endpoints | ||
| logging_endpoints | ||
| management_endpoints | ||
| management_helpers | ||
| memory | ||
| middleware | ||
| openai_files_endpoint | ||
| pass_through_endpoints | ||
| policy_engine | ||
| prompts | ||
| proxy_server | ||
| public_endpoints | ||
| rag_endpoints | ||
| realtime_endpoints | ||
| response_api_endpoints | ||
| shutdown | ||
| spend_tracking | ||
| test_configs | ||
| types_utils | ||
| ui_crud_endpoints | ||
| utils | ||
| vector_store_endpoints | ||
| video_endpoints | ||
| __init__.py | ||
| conftest.py | ||
| test_aiohttp_cleanup_closed.py | ||
| test_aiohttp_session_recovery.py | ||
| test_api_key_masking_in_errors.py | ||
| test_audio_speech_prometheus_hooks.py | ||
| test_batch_expiry.py | ||
| test_batch_metadata_none_fix.py | ||
| test_batch_retrieve_bedrock.py | ||
| test_batch_x_litellm_model_encoding.py | ||
| test_blocked_response_usage.py | ||
| test_budget_reservation.py | ||
| test_caching_routes.py | ||
| test_chat_completion_metadata.py | ||
| test_common_request_processing.py | ||
| test_component_allowlists.py | ||
| test_cors_config.py | ||
| test_custom_proxy.py | ||
| test_dynamic_mcp_route.py | ||
| test_empty_model_list.py | ||
| test_enforce_user_param.py | ||
| test_fallback_management_endpoints.py | ||
| test_fastapi_offline_routes.py | ||
| test_filter_models_by_team_access_group.py | ||
| test_health_check_functions.py | ||
| test_health_check_max_tokens.py | ||
| test_langfuse_passthrough_security.py | ||
| test_lazy_openapi_snapshot.py | ||
| test_litellm_pre_call_utils.py | ||
| test_max_budget_env_var.py | ||
| test_mcp_asgi_response.py | ||
| test_model_based_routing_files_batches.py | ||
| test_model_dump_with_preserved_fields.py | ||
| test_model_id_header_propagation.py | ||
| test_model_info_default_limits.py | ||
| test_model_level_guardrails.py | ||
| test_model_list_healthy_only.py | ||
| test_modify_response_streaming_passthrough.py | ||
| test_openapi_schema_validation.py | ||
| test_plugin_routes.py | ||
| test_pricing_field_strip.py | ||
| test_prometheus_cleanup.py | ||
| test_provider_url_destination_guard.py | ||
| test_proxy_cli.py | ||
| test_proxy_logging_hook_detection.py | ||
| test_proxy_server.py | ||
| test_proxy_types.py | ||
| test_proxy_utils.py | ||
| test_pyroscope.py | ||
| test_read_model_list.py | ||
| test_redis_auth_cache_flag.py | ||
| test_response_model_sanitization.py | ||
| test_route_a2a_models.py | ||
| test_route_llm_request.py | ||
| test_sensitive_route_auth.py | ||
| test_shared_health_check.py | ||
| test_spend_log_cleanup.py | ||
| test_swagger_chat_completions.py | ||
| test_team_member_update.py | ||
| test_team_org_move.py | ||
| test_tools_allowlist_enforcement.py | ||
| test_update_llm_router_resilience.py | ||