Repository navigation
fix(stats): keep sub-millisecond precision in avg tool duration - #1267
Conversation
ToolStat.AvgMs truncated the mean duration to whole milliseconds, so averages under 1ms rendered as 0ms in infer stats, /stats and the insights digest. Store the mean as fractional milliseconds and add telemetry.FormatAvg which falls back to microseconds below 1ms, matching the TUI duration formatting convention.
|
@infer /model ollama_cloud/glm-5.3 Can you review this PR? is it ready for merge? use /ponytail:ponytail /ponytail:ponytail-review /go |
|
Model: Todos
Pull Request✅ Infer Result: SuccessAll checks pass locally and in CI. Let me close out the plan and deliver the review. Review complete. All findings verified - here is the full review. Review of PR #1267 - ready for merge: yesVerdict: approve. The only thing blocking the merge is the required review decision itself ( Correctness (fixes the reported bug at the root)
ponytail-review (over-engineering pass)
Go idiomsTable-driven tests with Non-blocking notes
No code changes were made in this run. Approve and merge. Model: Tokens: 334,565 in · 13,065 out · 347,630 total (7 requests) Tool calls: 29 total · 100% success rate TracesStatsTriggered by edenreich · Infer Action · OSS |
|
🎉 This PR is included in version 0.206.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Resolves #1266
Summary
infer stats(and every other surface that renders tool aggregates) truncated themean tool duration to whole milliseconds, so any average under 1ms rendered as
"0ms". The mean is now stored as fractional milliseconds and a shared formatter
falls back to microseconds below 1ms, matching the µs formatting the TUI already
uses for tool-call durations.
Changes
internal/platform/telemetry/stats.go:ToolStat.AvgMsis nowfloat64(theavg_msJSON key is unchanged; values may now be fractional, which also fixesinfer stats --format jsonshowing0for sub-ms averages),toolStats()drops the whole-ms truncation, and a new
telemetry.FormatAvgrendersmicroseconds below 1ms and whole milliseconds above, next to the existing
FormatFailRateso every surface agrees.cmd/stats/stats.go: the Avg column renders viatelemetry.FormatAvg.internal/presentation/shortcuts/stats.go: the/statsmarkdown table andvertical views render via
telemetry.FormatAvg.internal/insights/insights.go: the insights digest tool totals and the reporttable render via
telemetry.FormatAvg(digest header now reads"calls/failures/avg" since the value carries its own unit).
internal/platform/telemetry/stats_test.go(new): table test forFormatAvgplus a regression test that a 0.4ms mean survives aggregation un-truncated.
Note:
avg_msininfer stats --format jsoncan now be a fractional numberinstead of an integer; in-repo consumers are unaffected.