feat(sight): show LLM latency metrics in agent sessions - #2586
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fbe5f7ae6d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const agentName = agentFilter === 'all' ? undefined : agentFilter; | ||
| const data = await fetchLatencyMetrics(startNs, endNs, agentName); |
There was a problem hiding this comment.
Preserve backend casing in latency filters
When merged eBPF and log sessions use different casing for the same agent (the existing code explicitly cites Qoder versus qoder), the case-insensitive dropdown keeps whichever spelling appears first, but this value is sent verbatim to the latency endpoint. The backend applies COALESCE(agent_name, process_name) = ?3 case-sensitively, so selecting a lowercase log-derived label can show matching sessions while the latency table incorrectly reports no data for uppercase eBPF records; normalize the comparison server-side or resolve the filter to the backend's recorded spelling.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Valid point. The latency endpoint was introduced in #2578, and its agent matching semantics are not aligned with the existing case-insensitive Agent Sessions identity handling. I’m addressing that in a separate backend follow-up so this PR can remain scoped to the dashboard integration.
chengshuyi
left a comment
There was a problem hiding this comment.
Review 反馈
感谢这个 PR!代码质量不错——stale request guard、nullable 指标降级为 —、独立 loading 状态等设计都很合理。
设计建议:面板放置位置
建议将 latency metrics 面板从「会话列表」(/sessions) 移到「Agent 看板」(/health) 页面。
理由:
- 语义对齐 — Agent 看板已经在做 per-agent 运行状态监控(健康/卡顿/崩溃/离线),延迟指标(TTFT/TPS/TPOT/E2E)本质上就是 Agent 的性能 vital signs,和 CPU 利用率是同一类信息——看的是"这个 agent 当前工作状态如何"。
- 粒度匹配 —
/api/metrics/latency返回的是 per-agent 聚合数据(GROUP BY agent_name),不是 per-session 的。放在会话列表里,用户需要在"会话明细"和"聚合指标"之间做心理切换。 - 现有结构天然适配 — AgentHealthPage 的 AgentCard 已按 agent 分卡片展示,可以在卡片上追加 mini 指标行(如
TTFT p50: 320ms · TPS p50: 42 t/s),或在卡片网格下方加一个"延迟百分位"表格 section。 - 会话列表保持纯粹 — AgentSessionsPage 的核心职责是"找到某个会话 → 点进去看轨迹",聚合面板会分散注意力。
其他 minor findings
- 合并顺序:#2590 尚未合并,需确保 #2590 → #2586 的顺序,否则 agent filter 大小写不匹配会返回空数据。
- i18n 位置:zh-CN 的 latency 键被插入到对象最顶部(
app.title之前),建议移到与 en-US 相同的相对位置,方便对照维护。 - unit 前导空格:
unit=" tokens/s"与其他unit="ms"不一致,建议统一在组件内部加空格分隔。 - 刷新按钮:
disabled={loading}可考虑加上|| latencyLoading。
以上 minor 项不阻塞,主要想讨论的是面板位置的设计方向。
fbe5f7a to
481a579
Compare
感谢 Review,已经按建议调整了这一版: |


Summary
Completes the AgentSight latency metrics UI part of #2339, following the backend/API work merged in #2578.
This adds per-agent LLM latency and throughput percentiles to the Agent Health page using the existing
/api/metrics/latencyendpoint. The Agent Sessions page remains focused on session history.Refs #2339
Changes
fetchLatencyMetrics()for/api/metrics/latency—instead of0The current branch is based on main after the Agent-name casing follow-up was merged; no frontend casing workaround is included.
Validation
npm run test:api-client— 12 passednpm run test:i18n— 4 passednpm run typechecknpm run buildnpm run build:embedgit diff --checkAll passed. Builds emit only the existing bundle-size warning.
Manual UI verification
TTFT/TPS/TPOTshown as—, while E2E remains available)Scope
This PR is frontend-only. It does not change backend metric semantics, Rust code, eBPF, schema, or add the cleanup changes from #2583.
Screenshot