Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(llma): keep clusters page populated past the 7-day read window (#62867)

posthog[bot]f38d9f6e039a
diff --git a/products/ai_observability/frontend/clusters/clustersLogic.ts b/products/ai_observability/frontend/clusters/clustersLogic.ts
index 51f54456dd6f..5599db318f54 100644
--- a/products/ai_observability/frontend/clusters/clustersLogic.ts
+++ b/products/ai_observability/frontend/clusters/clustersLogic.ts
@@ -20,6 +20,7 @@ import type { clustersLogicType } from './clustersLogicType'
import {
FILTER_QUERY_MAX_ROWS,
AI_OBSERVABILITY_CLUSTERS_SCENE_TAG,
+ CLUSTERING_RUNS_LOOKBACK_DAYS,
MAX_CLUSTERING_RUNS,
NOISE_CLUSTER_ID,
OUTLIER_COLOR,
@@ -319,6 +320,10 @@ export const clustersLogic = kea<clustersLogicType>([
loadClusteringRuns: async () => {
const eventName = eventNameForLevel(values.clusteringLevel)
+ // Look back a wide window rather than a hard 7 days: scheduled runs are
+ // emitted ~daily but a team can go several days without a fresh one, and a
+ // narrow window made the page go empty the moment the last run aged out.
+ // MAX_CLUSTERING_RUNS still bounds the result.
const response = await api.queryHogQL(
hogql`
SELECT
@@ -327,7 +332,7 @@ export const clustersLogic = kea<clustersLogicType>([
timestamp
FROM events
WHERE event = ${eventName}
- AND timestamp >= now() - INTERVAL 7 DAY
+ AND timestamp >= now() - INTERVAL ${hogql.raw(String(CLUSTERING_RUNS_LOOKBACK_DAYS))} DAY
ORDER BY timestamp DESC
LIMIT ${MAX_CLUSTERING_RUNS}
`,
diff --git a/products/ai_observability/frontend/clusters/constants.ts b/products/ai_observability/frontend/clusters/constants.ts
index 8fac2ee92bdc..ae4534aba50f 100644
--- a/products/ai_observability/frontend/clusters/constants.ts
+++ b/products/ai_observability/frontend/clusters/constants.ts
@@ -10,6 +10,12 @@ export const TRACES_PER_PAGE = 50
// Query limits
export const MAX_CLUSTERING_RUNS = 20
+// How far back to look for clustering runs. Scheduled runs are emitted (roughly) daily, but
+// a team can go several days without a fresh run — low-traffic days, sampling, or a paused
+// schedule. A wide window keeps the most recent run visible instead of the page going empty
+// the moment the last run ages past a day or two. MAX_CLUSTERING_RUNS still bounds the result.
+export const CLUSTERING_RUNS_LOOKBACK_DAYS = 90
+
// Cluster detail URL pattern. Mirrored in `manifest.tsx`'s route registration so any
// `urlToAction` matcher (e.g. `clusterDetailLogic`, `aiObservabilitySharedLogic`)
// stays in lockstep with the actual route.
diff --git a/products/ai_observability/frontend/components/clustersTabContentLogic.ts b/products/ai_observability/frontend/components/clustersTabContentLogic.ts
index 4d55b7e110f3..6cbd0efc6ba7 100644
--- a/products/ai_observability/frontend/components/clustersTabContentLogic.ts
+++ b/products/ai_observability/frontend/components/clustersTabContentLogic.ts
@@ -6,7 +6,7 @@ import api from 'lib/api'
import { hogql } from '~/queries/utils'
-import { NOISE_CLUSTER_ID } from '../clusters/constants'
+import { CLUSTERING_RUNS_LOOKBACK_DAYS, NOISE_CLUSTER_ID } from '../clusters/constants'
import { Cluster } from '../clusters/types'
import type { clustersTabContentLogicType } from './clustersTabContentLogicType'
@@ -45,7 +45,7 @@ export const clustersTabContentLogic = kea<clustersTabContentLogicType>([
timestamp
FROM events
WHERE event = '$ai_trace_clusters'
- AND timestamp >= now() - INTERVAL 7 DAY
+ AND timestamp >= now() - INTERVAL ${hogql.raw(String(CLUSTERING_RUNS_LOOKBACK_DAYS))} DAY
ORDER BY timestamp DESC
LIMIT 20
`,