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.

feat(llma): raise clustering eligibility thresholds (#65278)

posthog[bot]88e564884dfd
diff --git a/posthog/temporal/ai_observability/evaluation_clustering/constants.py b/posthog/temporal/ai_observability/evaluation_clustering/constants.py
index bb40e1e661c7..3d5eff6a4ee0 100644
--- a/posthog/temporal/ai_observability/evaluation_clustering/constants.py
+++ b/posthog/temporal/ai_observability/evaluation_clustering/constants.py
@@ -76,4 +76,4 @@ EVENT_NAME_EVALUATION_CLUSTERS = "$ai_evaluation_clusters"
# Minimum accumulated embeddings required before clustering will run for a job.
# For a new eval job sampling up to 250/hour this is typically reached within an hour
# of activity; until then the Stage B workflow reports "not enough embeddings yet".
-MIN_EMBEDDINGS_FOR_CLUSTERING = 20
+MIN_EMBEDDINGS_FOR_CLUSTERING = 100
diff --git a/posthog/temporal/ai_observability/trace_clustering/README.md b/posthog/temporal/ai_observability/trace_clustering/README.md
index 7f4ccaf8e842..af775122e11f 100644
--- a/posthog/temporal/ai_observability/trace_clustering/README.md
+++ b/posthog/temporal/ai_observability/trace_clustering/README.md
@@ -101,7 +101,7 @@ graph TB
- `team_id` (required): Team ID to cluster traces for
- `lookback_days` (optional): Days of trace history to analyze (default: 7)
-- `max_samples` (optional): Maximum traces to sample (default: 2500)
+- `max_samples` (optional): Maximum traces to sample (default: 1500)
- `min_k` (optional): Minimum clusters for k-means (default: 2)
- `max_k` (optional): Maximum clusters for k-means (default: 10)
- `embedding_normalization` (optional): L2 normalize embeddings - "none" or "l2" (default: "l2")
@@ -337,8 +337,8 @@ Key constants in `constants.py`:
| `WORKFLOW_NAME` | llma-trace-clustering | Temporal workflow name |
| `COORDINATOR_WORKFLOW_NAME` | llma-trace-clustering-coordinator | Temporal coordinator workflow name |
| `DEFAULT_LOOKBACK_DAYS` | 7 | Days of trace history to analyze |
-| `DEFAULT_MAX_SAMPLES` | 2500 | Maximum traces to sample |
-| `MIN_TRACES_FOR_CLUSTERING` | 20 | Minimum traces required for workflow |
+| `DEFAULT_MAX_SAMPLES` | 1500 | Maximum traces to sample |
+| `MIN_TRACES_FOR_CLUSTERING` | 1000 | Minimum items per level required for workflow |
| `COMPUTE_ACTIVITY_TIMEOUT` | 120s | Clustering compute timeout |
| `EMIT_ACTIVITY_TIMEOUT` | 60s | Event emission timeout |
| `LABELING_AGENT_MODEL` | gpt-5.4 | OpenAI model for labeling agent |
@@ -389,7 +389,7 @@ Key constants in `constants.py`:
## Error Handling
-- **Insufficient data**: Skip clustering if fewer than 20 traces
+- **Insufficient data**: Skip clustering if fewer than 1000 items (per analysis level)
- **Compute activity retries**: 3 attempts with exponential backoff
- **LLM activity retries**: 2 attempts with longer intervals (for rate limits)
- **Emit activity retries**: 3 attempts with exponential backoff
diff --git a/posthog/temporal/ai_observability/trace_clustering/constants.py b/posthog/temporal/ai_observability/trace_clustering/constants.py
index 03f8cb06eee9..865ff8e26fc4 100644
--- a/posthog/temporal/ai_observability/trace_clustering/constants.py
+++ b/posthog/temporal/ai_observability/trace_clustering/constants.py
@@ -10,8 +10,11 @@ DEFAULT_MAX_SAMPLES = 1500
DEFAULT_MIN_K = 2
DEFAULT_MAX_K = 10
-# Minimum traces required for clustering
-MIN_TRACES_FOR_CLUSTERING = 20
+# Minimum items required for clustering, checked per analysis level over the
+# lookback window (~1 week). A team qualifies for trace clustering with >= this
+# many traces, and independently for generation clustering with >= this many
+# generations.
+MIN_TRACES_FOR_CLUSTERING = 1000
# Coordinator concurrency settings
DEFAULT_MAX_CONCURRENT_TEAMS = 4 # Max teams to process in parallel