litellm/litellm-rust/crates/redis-connect/AGENTS.md
yujonglee a1b87bcca8
feat(redis): extend the native Redis foundation for the store families (#50169)
Reworks the redis-client, connect, resolve and testing crates, adds python-compat json loads and
TTL seconds, replaces the redis-store memory tier with a DualCache plus a shared failure log, and
gives the Python side the Redis timeout log throttle and a request OTEL parent span for service events

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 12:30:07 +09:00

3.4 KiB

  • Turns a litellm_redis_types::Resolution into a RedisClient, the same way for every host. It depends on litellm-redis-types, never on litellm-config, so a host that resolves Redis some other way connects the same way. redis-client stays cloud-agnostic, so credential providers and cloud token sources are built here
  • The host passes only what it alone can build in HostServices: the event sink, the HTTP client and the environment lookup. The breaker config comes from Resolution::breaker, which config reads from REDIS_CIRCUIT_BREAKER_* with Python's fallback, so a bad value keeps the default instead of failing connect. Each cloud source asks its auth crate for one explicit identity, the way the Python SDK builds it: AwsAuthService::default_chain_credentials (botocore's default chain), CredentialSource::application_default (google.auth.default) and AzureIdentity (the class _build_azure_credential picks). LiteLLM's provider settings such as AWS_ROLE_NAME, AZURE_AD_TOKEN or VERTEXAI_CREDENTIALS belong to Bedrock, Azure OpenAI and Vertex and never reach those constructors. Auth::Provider (a handle for a Python credential_provider object) fails at connect with an error naming the key, since no host can supply one yet
  • Every expiring credential goes through the one refresh loop in refresh.rs. A cloud source only fetches. Never add a second loop or let a source sleep. The expiry deadline lives only in the published Latest::Ready, so expiring it leaves Ready and cannot fire again. Never keep a copy of the deadline in the loop
  • AWS SDK identity settings must be in the process environment. aws-config cannot take the host lookup, so config-only overrides for profiles, role/web-identity settings, credentials, files and metadata sources fail before connecting rather than silently using another identity. Equal process/config values are allowed. Bedrock-only settings remain unrelated to Redis
  • redis-rs subscribes once for the connection handshake and again for re-authentication, so a new connection sends a redundant initial AUTH. Unchanged refreshes do not trigger another AUTH. Do not skip a provider's first or alternating subscriptions, because concurrent connections and retries each need the current token. Removing the initial duplicate requires an upstream connection-level fix
  • The loop starts on the first subscribe(), which redis-rs calls inside its runtime, so connect is safe off a runtime
  • A token-only credential (Azure without REDIS_USERNAME, GCP) is sent as AUTH default <token>, because redis-rs always sends a username with a credentials provider. On Redis 6+ that is the same as Python's AUTH <token>
  • Tests for the refresh loop use a fake source and real Redis ACL users. Cloud sources are proven against the live service, unit tests only pin request shapes we own
  • Rotation tests must retain the same server-side connection IDs across re-AUTH, then force a reconnect after removing the old user and verify the new identity still works
  • Live cloud tests live in tests/live/. Set LITELLM_REDIS_AWS_LIVE_CONFIG, LITELLM_REDIS_AZURE_LIVE_CONFIG or LITELLM_REDIS_GCP_LIVE_CONFIG to a JSON file containing redis settings and hold_seconds. Set the waiting period from the deployment's token lifetime when checking expiry. Optional fixtures return early when unset, and configured tests run under plain cargo test. An unconfigured run never counts as live proof