From 8a8be608a06c96ae6c38d139b63239cd7e6ffb9d Mon Sep 17 00:00:00 2001 From: Kagamine Rin Date: Thu, 4 Jun 2026 21:31:53 -0400 Subject: [PATCH] feat: add show_failed parameter to litellm_history (default true) When show_failed=False, filters out requests with metadata.exception or metadata.status='failure' before applying the limit. Useful for hiding auth probe noise and routing failures. Header shows '(failed requests hidden)' when active. --- litellm_dashboard.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/litellm_dashboard.py b/litellm_dashboard.py index 682657d..54776cd 100644 --- a/litellm_dashboard.py +++ b/litellm_dashboard.py @@ -247,11 +247,13 @@ class Tools: self, limit: int = 20, show_cost: bool = True, + show_failed: bool = True, ) -> str: """ Get recent LiteLLM proxy request history. :param limit: Number of recent requests to show (1-50, default 20) :param show_cost: Include per-request cost (default True) + :param show_failed: Include failed requests in output (default True). Set False to hide auth failures, routing errors, etc. Returns a formatted table of recent LLM requests with model, status, tokens, duration, and optional cost. """ if not self.valves.litellm_master_key: @@ -282,12 +284,24 @@ class Tools: # Sort by startTime descending and take the most recent `limit` entries sorted_logs = sorted(data, key=lambda e: e.get("startTime", ""), reverse=True) + + # Filter out failed requests if show_failed is False + if not show_failed: + sorted_logs = [ + e for e in sorted_logs + if not ( + (e.get("metadata", {}) or {}).get("exception", "") + or (e.get("metadata", {}) or {}).get("status", "") == "failure" + ) + ] + recent = sorted_logs[:limit] total_count = len(data) + filtered_note = " (failed requests hidden)" if not show_failed else "" lines = [] lines.append(f"LiteLLM Request History — {self._base_url()}") - lines.append(f"Showing {len(recent)} of {total_count} total requests (most recent first)") + lines.append(f"Showing {len(recent)} of {total_count} total requests{filtered_note} (most recent first)") lines.append("=" * 90) for i, entry in enumerate(recent, 1):