From e83a6ab525a0700f2dce4340d2ce914a26e6670f Mon Sep 17 00:00:00 2001 From: rcourtman Date: Sun, 21 Dec 2025 22:56:19 +0000 Subject: [PATCH] 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. --- internal/ai/context/builder.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/ai/context/builder.go b/internal/ai/context/builder.go index 1be2fc1..913cf5f 100644 --- a/internal/ai/context/builder.go +++ b/internal/ai/context/builder.go @@ -486,9 +486,9 @@ func (b *Builder) computeGuestMetricSamples(guestID string) map[string][]MetricP if len(points) < 3 { continue } - // Downsample to ~100 points (~15 min resolution over 24h) - // Modern LLMs have 100k+ token contexts - we can afford detailed history - sampled := DownsampleMetrics(points, 100) + // Downsample to ~24 points (hourly resolution over 24h) + // Balances token cost with pattern visibility + sampled := DownsampleMetrics(points, 24) if len(sampled) >= 3 { samples[metric] = sampled }