perf: reduce MetricSamples from 100 to 24 points

100 samples was causing 326k+ input tokens which is expensive.
24 samples (hourly resolution) still provides good pattern visibility
while significantly reducing token cost.

Estimated reduction: ~75% fewer metric tokens.
This commit is contained in:
rcourtman 2025-12-21 22:56:19 +00:00
parent 812df96377
commit e83a6ab525

View file

@ -486,9 +486,9 @@ func (b *Builder) computeGuestMetricSamples(guestID string) map[string][]MetricP
if len(points) < 3 { if len(points) < 3 {
continue continue
} }
// Downsample to ~100 points (~15 min resolution over 24h) // Downsample to ~24 points (hourly resolution over 24h)
// Modern LLMs have 100k+ token contexts - we can afford detailed history // Balances token cost with pattern visibility
sampled := DownsampleMetrics(points, 100) sampled := DownsampleMetrics(points, 24)
if len(sampled) >= 3 { if len(sampled) >= 3 {
samples[metric] = sampled samples[metric] = sampled
} }