feat(llm): LLM routing observability panel on the telemetry surface#470
Closed
HomenShum wants to merge 1 commit into
Closed
feat(llm): LLM routing observability panel on the telemetry surface#470HomenShum wants to merge 1 commit into
HomenShum wants to merge 1 commit into
Conversation
Surface the EXISTING per-answer routing telemetry the /ask path persists on
liveEventAnswers (modelId / provider / agentMode / estimatedCostCents) so an
operator can see shared/llm/router.ts working in production: Haiku floor vs.
Sonnet escalation split, escalation rate, avg cost/answer, and provider-
fallback rate. Read-only + additive - does NOT touch routeLLM or the /ask
write path.
Backend (additive, bounded, honest):
- convex/events.ts: new GLOBAL query getAskRoutingTelemetry - a <=1000-row
bounded scan over recent liveEventAnswers (BOUND via .take(cap)). Delegates
the math to a pure aggregator so it is scenario-tested without a DB.
- shared/llm/askRoutingTelemetry.ts: pure aggregateAskRouting() - floor vs.
escalated decided by the same modelId.includes("haiku") convention the cost
estimator + router floor use (DETERMINISTIC, sorted breakdowns). Rates are
null (not a fabricated 0%) when there is no denominator (HONEST_SCORES).
Frontend:
- src/features/telemetry/LlmRoutingPanel.tsx: glass-card panel with headline
stats, model mix, provider mix, an honest "No routed /ask traffic yet" empty
state, loading state, aria labels + reduced-motion-safe.
- Composed into AgentTelemetryDashboard (the named telemetry surface) +
exported from the telemetry barrel.
Tests: shared/llm/askRoutingTelemetry.test.ts - 10 scenario-based tests
(operator floor/escalation split, true-0 vs null, cache/deterministic-only,
provider-fallback, cost-over-routed-only, adversarial pinned/blank models,
1000-row scale, determinism).
Verification: app tsc clean, convex tsc clean, vitest 22 pass (10 new + 12
router) + 78 existing event tests green, npm run build clean.
Note: AgentTelemetryDashboard is currently orphaned (no live route mounts it)
in the prod-parity build, so the panel compiles + is tested but is not yet
visually live until its host is routed. Reported for reviewer.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR size advisoryThis PR adds 642 lines of substantive change. CONTRIBUTING.md defines a soft limit of ~400 LOC. If the PR is genuinely cohesive (e.g. an architecture map, a generated migration, a deletion of a dead module), no action is needed. Otherwise consider:
This is advisory — it does not block the merge. |
✅ Dogfood Visual QA Gate: PASSED
ArtifactsDownload the Generated by Dogfood QA Gate |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Roadmap #3 of the NodeBench LLM Router: a real, honest LLM Routing observability panel that surfaces the existing per-answer routing telemetry the
/askpath already persists onliveEventAnswers(modelId/provider/agentMode/estimatedCostCents). An operator can now seeshared/llm/router.tsworking in production — the Haiku floor vs. Sonnet escalation split, escalation rate, avg cost/answer, and the provider-fallback rate.Read-only and additive. Does NOT touch
routeLLMor the/askwrite path.Real data source
New global, bounded Convex query —
events:getAskRoutingTelemetry(inconvex/events.ts):args: { limit? }, capped at ≤1000 rows via.take(cap)(BOUND). No global time index exists onliveEventAnswers, so this is a bounded table scan — the.take()is the hard cap.aggregateAskRouting()inshared/llm/askRoutingTelemetry.ts, so the logic is scenario-tested directly with plain arrays (no DB), the same wayrouter.tsis tested.Returned fields:
total,capped,routedCount,floorCount,escalatedCount,escalationRate,providerFallbackRate,avgCostCents,totalCostCents,agentModesmix,modelMix(per-model count + floor/escalated/other tier),providerMix.Floor vs. escalated is decided by the same
modelId.includes("haiku")convention the existing cost estimator and the router's Haiku floor use, so the panel can never disagree with what was actually routed/billed.Honesty (agentic_reliability)
null(panel renders "—" / a "No routed /ask traffic yet" card) when there's no denominator — never a fabricated 0% or $0.cache/deterministicanswers (which never invokedrouteLLM) are excluded from the routing denominator but still counted in the agentMode mix.Files changed
convex/events.ts— newgetAskRoutingTelemetryquery (thin bounded DB read → pure aggregator)shared/llm/askRoutingTelemetry.ts— pureaggregateAskRouting()+tierForModelId()+ typesshared/llm/askRoutingTelemetry.test.ts— 10 scenario-based testssrc/features/telemetry/LlmRoutingPanel.tsx— glass-card panel (headline stats, model mix, provider mix, honest empty + loading states, aria labels, reduced-motion-safe)src/features/telemetry/index.ts— barrel exportsrc/features/monitoring/views/AgentTelemetryDashboard.tsx— compose the panel into the named telemetry surfaceVerification
npx tsc --noEmit(app) — 0 errorsnpx tsc -p convex --noEmit— 0 errorsnpx vitest run shared/llm/askRoutingTelemetry.test.ts shared/llm/router.test.ts— 22 pass (10 new scenario + 12 router)npx vitest run convex/__tests__/scratchnode.events.test.ts convex/events.runtime-boundary.test.ts— 78 pass (no regression to existinggetAskTelemetry)npm run build— cleanHonest caveat for the reviewer
AgentTelemetryDashboard(the file the task named as the telemetry surface) is currently orphaned in the prod-parity build — no live route/JSX mounts it, so Vite tree-shakes it (and therefore this panel) out of the bundle. The panel is fully implemented, compiles, and is tested, but it is not yet visually live until its host component is wired into a route. I did not bolt it into the redesign nav (Home/Reports/Chat/Inbox/Me) or add a new route, per the project's "preserve the nav / no sixth tab" rules — that routing decision is yours.🤖 Generated with Claude Code