From 7d9a95f7d9914aeea579cc892414a7613758bd67 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 19 Feb 2026 20:24:19 +0000 Subject: [PATCH 1/2] Initial plan From af87fcdcce2957c89deef9dd7effdab60eb7ef37 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 19 Feb 2026 20:27:29 +0000 Subject: [PATCH 2/2] fix: compute quality_avg from average final_score instead of completion rate Co-authored-by: rafaelob <814981+rafaelob@users.noreply.github.com> --- .../ailine_runtime/api/routers/observability.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/runtime/ailine_runtime/api/routers/observability.py b/runtime/ailine_runtime/api/routers/observability.py index 2ce4301..f72271b 100644 --- a/runtime/ailine_runtime/api/routers/observability.py +++ b/runtime/ailine_runtime/api/routers/observability.py @@ -118,17 +118,22 @@ async def observability_dashboard( # Provider status provider_info = obs_store.get_provider_status() + # Compute average quality score from completed traces with a valid final_score + completed_quality_scores = [ + t.final_score + for t in recent_traces + if t.status == "completed" and t.final_score is not None + ] + quality_avg_value = ( + (sum(completed_quality_scores) / max(len(completed_quality_scores), 1)) * 100 + ) + return { # Flat fields expected by the frontend ObservabilityDashboard interface "provider": provider_info.get("name", "unknown"), "model": provider_info.get("model", "unknown"), "scores": { - "quality_avg": round( - sum(1 for t in recent_traces if t.status == "completed") - / max(len(recent_traces), 1) - * 100, - 1, - ), + "quality_avg": round(quality_avg_value, 1), "latency_p50_ms": round(latency_percentiles.get("p50", 0) * 1000, 1), "latency_p95_ms": round(latency_percentiles.get("p95", 0) * 1000, 1), },