litellm/tests/test_litellm/proxy/proxy_server
Tin Chi Lo e79ea57fb4 feat(complexity_router): consume plane for provider prompt-cache warming
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.
2026-07-28 17:47:33 -07:00
..
.coverage_baseline test(proxy): add harness for proxy_server.py behavior-pinning (#28827) 2026-05-25 20:26:44 -07:00
__init__.py test(proxy): add harness for proxy_server.py behavior-pinning (#28827) 2026-05-25 20:26:44 -07:00
_coverage_check.py test(proxy): add harness for proxy_server.py behavior-pinning (#28827) 2026-05-25 20:26:44 -07:00
_pin_check.py test(proxy): add harness for proxy_server.py behavior-pinning (#28827) 2026-05-25 20:26:44 -07:00
conftest.py test(proxy): add harness for proxy_server.py behavior-pinning (#28827) 2026-05-25 20:26:44 -07:00
test_background_health.py feat(complexity_router): consume plane for provider prompt-cache warming 2026-07-28 17:47:33 -07:00
test_exception_handlers.py test(proxy): pin both branches of the validation exception handler 2026-07-27 09:59:47 -07:00
test_harness_smoke.py test(proxy): add harness for proxy_server.py behavior-pinning (#28827) 2026-05-25 20:26:44 -07:00
test_lifecycle.py fix(proxy): redact secrets on the db-config and litellm_settings log paths too 2026-07-03 13:03:45 -07:00
test_openapi_customization.py tests(proxy_server): surface current behavior in tests (#29309) 2026-05-29 23:17:24 -07:00
test_proxy_config.py feat(proxy): make DB config-reload interval configurable via config.yaml and UI (#34130) 2026-07-21 22:03:22 +00:00
test_routes_anthropic_beta.py tests(proxy_server): surface current behavior in tests (#29309) 2026-05-29 23:17:24 -07:00
test_routes_assistants.py tests(proxy_server): surface current behavior in tests (#29309) 2026-05-29 23:17:24 -07:00
test_routes_audio.py fix(proxy): extend response headers hook to streaming, TTS, image gen, and pass-through (#24232) 2026-06-09 22:10:23 +02:00
test_routes_chat_completions.py tests(proxy_server): surface current behavior in tests (#29309) 2026-05-29 23:17:24 -07:00
test_routes_completions.py tests(proxy_server): surface current behavior in tests (#29309) 2026-05-29 23:17:24 -07:00
test_routes_config.py feat(proxy): make DB config-reload interval configurable via config.yaml and UI (#34130) 2026-07-21 22:03:22 +00:00
test_routes_embeddings.py tests(proxy_server): surface current behavior in tests (#29309) 2026-05-29 23:17:24 -07:00
test_routes_invitation.py tests(proxy_server): surface current behavior in tests (#29309) 2026-05-29 23:17:24 -07:00
test_routes_login_sso.py feat(mcp): gateway DCR session admission at the aggregate /mcp endpoint (LIT-3637) 2026-07-23 00:24:28 -07:00
test_routes_misc.py fix(router): tag-aware pre-routing strategy selection for shared model_name (#33691) 2026-07-17 09:26:07 -07:00
test_routes_model_cost_map.py tests(proxy_server): surface current behavior in tests (#29309) 2026-05-29 23:17:24 -07:00
test_routes_model_info.py fix(proxy): restore wildcard expansion in /v1/model/info (#31444) 2026-06-26 08:50:58 -07:00
test_routes_model_metrics.py tests(proxy_server): surface current behavior in tests (#29309) 2026-05-29 23:17:24 -07:00
test_routes_models.py tests(proxy_server): surface current behavior in tests (#29309) 2026-05-29 23:17:24 -07:00
test_routes_moderations.py tests(proxy_server): surface current behavior in tests (#29309) 2026-05-29 23:17:24 -07:00
test_routes_onboarding.py tests(proxy_server): surface current behavior in tests (#29309) 2026-05-29 23:17:24 -07:00
test_routes_queue.py tests(proxy_server): surface current behavior in tests (#29309) 2026-05-29 23:17:24 -07:00
test_routes_threads.py tests(proxy_server): surface current behavior in tests (#29309) 2026-05-29 23:17:24 -07:00
test_routes_utils.py tests(proxy_server): surface current behavior in tests (#29309) 2026-05-29 23:17:24 -07:00
test_spend_counters.py perf(spend): gather independent per-scope spend-counter increments (#31578) 2026-06-30 12:07:47 -07:00
test_streaming_helpers.py feat(complexity-router): add return_raw_model_name toggle for response model field (#33875) 2026-07-18 19:24:56 -07:00
test_team_model_name_translation.py fix(vertex_ai): exclude Gemini Google Search grounding tokens from input token billing (#33742) 2026-07-17 21:17:49 -07:00