From 96cde25dd6c05aa8d2c3afaccbfa3c5a03016d79 Mon Sep 17 00:00:00 2001 From: yuneng Date: Thu, 27 Aug 2026 22:27:13 +0000 Subject: [PATCH] fix(ui): show cache key for cache-populating requests Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .../LogDetailContent.test.tsx | 21 +++++++++++++++++++ .../LogDetailsDrawer/LogDetailContent.tsx | 8 ++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/LogDetailContent.test.tsx b/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/LogDetailContent.test.tsx index e48fd555dda..7cf111bfc60 100644 --- a/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/LogDetailContent.test.tsx +++ b/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/LogDetailContent.test.tsx @@ -366,9 +366,30 @@ describe("LogDetailContent", () => { expect(screen.getByText("abc123cachekey")).toBeInTheDocument(); }); + it("should display a cache miss and Cache Key for the request that populates the response cache", () => { + render( + , + ); + + expect(screen.getByText("Response Cache")).toBeInTheDocument(); + expect(screen.getByText("Miss")).toBeInTheDocument(); + expect(screen.getByText("Cache Key")).toBeInTheDocument(); + expect(screen.getByText("abc123cachekey")).toBeInTheDocument(); + }); + it("should hide the Cache Key row when caching is off", () => { render(); + expect(screen.getByText("Response Cache")).toBeInTheDocument(); + expect(screen.queryByText("Cache Key")).not.toBeInTheDocument(); + }); + + it("should hide response cache metadata when caching is off and cache_hit is None", () => { + render(); + + expect(screen.queryByText("Response Cache")).not.toBeInTheDocument(); expect(screen.queryByText("Cache Key")).not.toBeInTheDocument(); }); diff --git a/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/LogDetailContent.tsx b/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/LogDetailContent.tsx index 79fb60b9646..585f8db90c8 100644 --- a/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/LogDetailContent.tsx +++ b/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/LogDetailContent.tsx @@ -382,8 +382,10 @@ function MetricsSection({ logEntry, metadata }: { logEntry: LogEntry; metadata: : null; const responseCacheValue = String(logEntry.cache_hit ?? "").toLowerCase(); + const responseCacheKey = + logEntry.cache_key && logEntry.cache_key !== "Cache OFF" ? logEntry.cache_key : undefined; const isResponseCacheHit = responseCacheValue === "true"; - const showResponseCache = isResponseCacheHit || responseCacheValue === "false"; + const showResponseCache = isResponseCacheHit || responseCacheValue === "false" || responseCacheKey != null; const promptCacheReadTokens = Number(metadata?.additional_usage_values?.cache_read_input_tokens) || 0; const promptCacheCreationTokens = Number(metadata?.additional_usage_values?.cache_creation_input_tokens) || 0; @@ -438,11 +440,11 @@ function MetricsSection({ logEntry, metadata }: { logEntry: LogEntry; metadata: )} - {showResponseCache && logEntry.cache_key && logEntry.cache_key !== "Cache OFF" && ( + {responseCacheKey && ( } > - + )} {promptCacheReadTokens > 0 && (