From 71e4210386173785a76253ecda3d5908de02484b Mon Sep 17 00:00:00 2001 From: Kagamine Rin Date: Thu, 4 Jun 2026 21:26:35 -0400 Subject: [PATCH] fix: detect status: failure in addition to exception for request history MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Entry 3 in our logs had metadata.status='failure' but no exception string, so it was incorrectly shown as ✅ OK. Now checks both exception AND metadata.status == 'failure'. Also updates failed count in summary. --- litellm_dashboard.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/litellm_dashboard.py b/litellm_dashboard.py index c2e3184..1d89d92 100644 --- a/litellm_dashboard.py +++ b/litellm_dashboard.py @@ -310,7 +310,9 @@ class Tools: # Status — check for errors metadata = entry.get("metadata", {}) or {} exception = metadata.get("exception", "") - status = "❌ FAIL" if exception else "✅ OK" + status_flag = metadata.get("status", "") + is_failed = bool(exception) or status_flag == "failure" + status = "❌ FAIL" if is_failed else "✅ OK" # Duration duration_ms = entry.get("request_duration_ms", 0) or 0 @@ -358,9 +360,12 @@ class Tools: base += f" | ${spend:.4f}" # Error info - if exception: - # Truncate long error messages - err_short = exception[:80] + "…" if len(exception) > 80 else exception + if is_failed: + # Show exception if present, otherwise show status failure + if exception: + err_short = exception[:80] + "…" if len(exception) > 80 else exception + else: + err_short = "status: failure" base += f"\n └─ {err_short}" lines.append(base) @@ -371,7 +376,7 @@ class Tools: recent_prompt = sum(e.get("prompt_tokens", 0) or 0 for e in recent) recent_completion = sum(e.get("completion_tokens", 0) or 0 for e in recent) recent_cache = sum(e.get("cache_read_input_tokens", 0) or 0 for e in recent) - recent_failed = sum(1 for e in recent if (e.get("metadata", {}) or {}).get("exception")) + recent_failed = sum(1 for e in recent if ((e.get("metadata", {}) or {}).get("exception")) or ((e.get("metadata", {}) or {}).get("status", "")) == "failure") lines.append("") lines.append(f" Summary ({len(recent)} shown): ${recent_spend:.4f} spent | "