Skip to content

feat(agent-platform): observability KPIs as quill MetricCards + clamp negative cost - #2840

Merged
dmarticus merged 1 commit into
agent-config-identitiesfrom
agent-observability-metric-cards
Jun 22, 2026
Merged

feat(agent-platform): observability KPIs as quill MetricCards + clamp negative cost#2840
dmarticus merged 1 commit into
agent-config-identitiesfrom
agent-observability-metric-cards

Conversation

@benjackwhite

Copy link
Copy Markdown
Contributor

Replaces the hand-rolled observability KPI tiles with quill-charts MetricCard — a "headline number with a graph behind it" — and fixes the confusing negative cost ($-2.74) along the way.

Stacked on agent-config-identities (#2837) — base is that branch, so the diff is just the two files. Retarget to posthog-code/m3a-final once #2837 merges.

KPI strip → MetricCard

  • Drops the bespoke KpiTile + DeltaChip and the Sparkline import; each of the 4 tiles (Spend / Sessions / Failure rate / p95) is now a MetricCard.
  • Headline value with an embedded sparkline; hover a point to read that day's value; built-in change pill (arrow from the sign, colour from goodDirection, label from formatChange).
  • Failure rate gains a sparkline (its daily.failureRate series was already computed, just unused).
  • Compact uppercase labels preserved via a tileTitle node; connected-strip look kept via a small KpiCell wrapper.
  • Net ~-32 lines.

Negative-cost fix

A negative $ai_total_cost_usd aggregate (an upstream LLM-observability cost-calc artifact) was rendering as a literal $-2.74 on the Spend KPI. Now clamped to ≥ 0:

  • Spend tile: value={Math.max(0, spendUsd)}, sparkline clamped, formatValue floors at 0.
  • formatSpendUsd (fleet rows) returns $0 for non-positive values instead of mis-bucketing them as <$0.01.

Notes

  • Visual: MetricCard's headline is text-4xl (vs the old text-[18px]) — bigger, dashboard-style numbers. Easy to dial back if too large in the 4-across strip.
  • The tile's change pill is the fixed 7d-vs-prior delta; the headline updates on hover.
  • Typecheck + Biome clean. First adopter of MetricCard in the app.
  • Not yet eyeballed in the running app.

🤖 Generated with Claude Code

… negative cost

Replace the hand-rolled KpiTile + DeltaChip + Sparkline in the observability
KPI strip with quill-charts MetricCard. Each tile now shows the headline value
with an embedded sparkline (hover a point to read that day's value), a built-in
change pill (arrow + colour driven by goodDirection), and consistent theming —
dropping the bespoke tile/chip/sparkline code. Failure rate gains a sparkline
too (its daily series was already computed, just unused).

Also clamps cost to >= 0, fixing the confusing "$-2.74" spend KPI: a negative
`$ai_total_cost_usd` aggregate (an upstream cost-calc artifact) is no longer
shown as a negative dollar value. MetricCard's formatValue floors the spend
tile + sparkline, and formatSpendUsd (fleet rows) now returns "$0" for
non-positive values instead of mis-bucketing them as "<$0.01".

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 5d93f92.

@greptile-apps

greptile-apps Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Comments Outside Diff (1)

  1. packages/ui/src/features/agent-applications/components/AgentAnalyticsView.tsx, line 355-358 (link)

    P2 Loading skeleton height mismatch: the AgentAnalyticsKpiStrip standalone loading path was bumped to h-28 to fit the taller MetricCard, but LoadingSkeleton (the full-page loading state rendered by AgentAnalyticsView) was not updated and still uses h-20. Anyone landing on the Applications page while data is loading will see shorter placeholder tiles that visually pop to a larger size once the real cards appear.

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Reviews (1): Last reviewed commit: "feat(agent-platform): observability KPIs..." | Re-trigger Greptile

Comment on lines +173 to +190
<KpiCell>
<MetricCard
title={tileTitle("Failure rate · 7d")}
value={kpis.failureRate}
data={daily.failureRate}
labels={daily.labels}
theme={theme}
formatValue={pct}
change={
deltas.failureRatePoints != null
? { value: deltas.failureRatePoints }
: null
}
formatChange={ppDelta}
goodDirection="down"
sparklineHeight={28}
/>
</KpiCell>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Amber attention color for non-zero failure rates is no longer present. The old KpiTile applied text-(--amber-11) to the headline whenever kpis.failureRate > 0, giving a persistent visual alert independent of trend direction. The new MetricCard's goodDirection="down" only colours the change pill (and only when a delta is available). The ToolTable in the same file still applies text-(--red-11) on non-zero error rates (line 262), so the "warn on any non-zero value" pattern appears intentional. If this signal matters for the KPI tile, MetricCard would need a custom wrapper or an alternative approach to replicate it.

@benjackwhite
benjackwhite requested a review from a team June 22, 2026 16:20
@benjackwhite
benjackwhite marked this pull request as ready for review June 22, 2026 16:20
@dmarticus
dmarticus merged commit 69dc255 into agent-config-identities Jun 22, 2026
20 checks passed
@dmarticus
dmarticus deleted the agent-observability-metric-cards branch June 22, 2026 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants