agents/recent-patterns: adaptive lookback window + weekly cycle detection #116

Closed
opened 2026-05-05 09:26:02 +00:00 by alvis · 0 comments
Owner

Goal

Make RecentPatternsAgent'''s lookback window adapt to activity volume, and surface day-of-week / time-of-day cyclical patterns as structured tags on its snippet.

Why

A fixed 24h lookback misses weekly cycles for casual users and overwhelms the snippet for active ones. The agent should look back as far as it needs to find a clear signal, no further.

Inferred parameters

Key Shape Default
lookbackDays int (1–30) 7
weeklyCycle { dow: 0–6, strength: 0–1, sample: 'completes most Tuesdays' }[] empty
dailyCycle { hour: 0–23, strength: 0–1 }[] empty

Method (sketch)

  • Adapt lookback so window contains ≥ N events (target: 30) up to 30d cap.
  • Autocorrelation on completions-by-day for weekly cycles.
  • Autocorrelation on completions-by-hour for daily cycles.
  • Strength = peak-to-mean ratio.

Done when

  • Inference function plugged into the framework with TTL = 24h.
  • Cold-start uses 7d lookback, no cycle tags.
  • Snippet renders cycle hints when strength > 0.5.
  • Tests cover: weekend-warrior, weekday-only, evening-person, no-pattern.

Depends on

## Goal Make `RecentPatternsAgent`'''s lookback window adapt to activity volume, and surface day-of-week / time-of-day cyclical patterns as structured tags on its snippet. ## Why A fixed 24h lookback misses weekly cycles for casual users and overwhelms the snippet for active ones. The agent should look back as far as it needs to find a clear signal, no further. ## Inferred parameters | Key | Shape | Default | |---|---|---| | `lookbackDays` | int (1–30) | 7 | | `weeklyCycle` | `{ dow: 0–6, strength: 0–1, sample: 'completes most Tuesdays' }[]` | empty | | `dailyCycle` | `{ hour: 0–23, strength: 0–1 }[]` | empty | ## Method (sketch) - Adapt lookback so window contains ≥ N events (target: 30) up to 30d cap. - Autocorrelation on completions-by-day for weekly cycles. - Autocorrelation on completions-by-hour for daily cycles. - Strength = peak-to-mean ratio. ## Done when - Inference function plugged into the framework with TTL = 24h. - Cold-start uses 7d lookback, no cycle tags. - Snippet renders cycle hints when `strength > 0.5`. - Tests cover: weekend-warrior, weekday-only, evening-person, no-pattern. ## Depends on - #111
alvis added this to the M2 — AI tips + multi-source signals milestone 2026-05-05 09:26:02 +00:00
alvis closed this issue 2026-05-06 05:59:52 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: alvis/oO#116