Skip to content

feat: lower echo threshold + clustering for broader behavioral pattern detection#377

Merged
BYK merged 1 commit into
mainfrom
feat-echo-clustering
May 18, 2026
Merged

feat: lower echo threshold + clustering for broader behavioral pattern detection#377
BYK merged 1 commit into
mainfrom
feat-echo-clustering

Conversation

@BYK
Copy link
Copy Markdown
Owner

@BYK BYK commented May 18, 2026

Summary

Lowers the pattern echo similarity threshold and adds greedy clustering to detect behavioral patterns that individual pair comparisons miss.

Eval Results

PR-2 (implicit preferences): 4.58 → 4.63 (tail-window: ~4.85)

Question Before After
Tests alongside implementation 3.6 5.0
ORM stance 4.6 5.0
Error handling in API endpoints 4.2 4.2
Route handler error pattern 4.2 2.8
All other questions 5.0 5.0

How it works

Before: Single threshold at 0.78 — requires each candidate to be highly similar to the current segment. Misses patterns where surface text varies across sessions.

After: Two-stage approach:

  1. Wide net (CANDIDATE_THRESHOLD = 0.65): Retrieve more candidates
  2. Cluster by mutual similarity (CLUSTER_SIMILARITY = 0.72): Group candidates that are similar to each other, not just to the current segment
  3. Count clusters: A cluster spanning 3+ distinct sessions triggers pattern extraction

This catches 'tests alongside implementation' — individual test-related observations are only 0.65-0.75 similar to each other (below the old 0.78 threshold), but they form a coherent cluster across sessions.

Files Changed

  • packages/core/src/pattern-echo.ts — clustering logic, lower threshold, new constants

…n detection

Lower ECHO_THRESHOLD from 0.78 to 0.65 (CANDIDATE_THRESHOLD) to cast a
wider net for pattern candidates. Add greedy clustering that groups
candidates by mutual similarity (CLUSTER_SIMILARITY >= 0.72). A cluster
spanning 3+ distinct sessions triggers pattern extraction.

This catches patterns where individual pairs don't reach 0.78 but a
cluster of related observations across sessions reveals the behavior.

Eval PR-2: 4.58 → 4.63 (tail-window: ~4.85)
- Tests alongside implementation: 3.6 → 5.0
- ORM stance: 4.6 → 5.0
@BYK BYK self-assigned this May 18, 2026
@BYK BYK merged commit 6ceafa0 into main May 18, 2026
10 checks passed
@BYK BYK deleted the feat-echo-clustering branch May 18, 2026 22:42
This was referenced May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant