#21611: feat(memory-neo4j): add Phase 3b temporal staleness detection
docs
channel: telegram
channel: voice-call
gateway
extensions: memory-lancedb
cli
scripts
commands
agents
size: XL
Cluster:
Memory Management Enhancements
## Summary
Adds a new sleep cycle phase (3b) that detects and removes memories about past events/dates that are no longer relevant.
### Problem
Memories about ephemeral events (ferry bookings, download progress, meeting times) persist indefinitely. The existing decay mechanism uses importance-based half-life but has no concept of temporal relevance — it can't tell that a ferry booking from 2 weeks ago is now useless.
### Solution
**Phase 3b: Temporal Staleness Detection** runs between Phase 3 (Decay) and Phase 4 (Cleanup):
1. **Regex pre-filter** in Neo4j catches memories with date/time patterns, progress indicators, or temporal keywords — avoids wasting LLM calls on non-temporal memories
2. **LLM classifier** (`classifyTemporalStaleness`) evaluates each candidate as `stale` or `lasting`
3. Stale memories are invalidated; lasting ones are kept
### Design decisions
- **Conservative by default**: returns `lasting` on any LLM failure or uncertainty
- **Only checks memories ≥ 3 days old** (configurable via `temporalStalenessMinAgeDays`) — won't remove upcoming events
- **Skips core memories** — user-curated memories are never touched
- **Regex pre-screen** keeps LLM costs low (typically filters 90%+ of memories)
- **Parallel batch processing** like other phases
- **Configurable**: `skipTemporalStaleness` to disable entirely
### Files changed
- `extractor.ts` — Added `classifyTemporalStaleness()` (+75 lines)
- `neo4j-client.ts` — Added `fetchMemoriesForTemporalCheck()` (+35 lines)
- `sleep-cycle.ts` — Added Phase 3b implementation (+81 lines)
### Testing
- Build ✅ | Lint ✅ | All 42 sleep cycle tests pass ✅
- Tested regex pre-filter against live Neo4j: 17/237 memories matched (efficient filtering)
Most Similar PRs
#18919: feat: importance-weighted temporal decay for memory search
by ruypang · 2026-02-17
60.7%
#19685: feat: Dreaming Process — Autonomous Memory Consolidation
by jduartedj · 2026-02-18
59.2%
#18912: feat: periodic fact extraction from conversations
by ruypang · 2026-02-17
58.8%
#20791: Feature/aeon memory plugin
by mustafarslan · 2026-02-19
58.7%
#7480: feat: Add CoreMemories hierarchical memory system
by Itslouisbaby · 2026-02-02
56.7%
#17895: fix(cron): add staleness check for runningAtMs on manual trigger
by PlayerGhost · 2026-02-16
56.4%
#20183: fix(memory): index reset/deleted session transcripts
by VACInc · 2026-02-18
56.1%
#17129: feat(memory): compaction-aware conversation memory with smart-trim
by cintia09 · 2026-02-15
56.1%
#22220: feat(bootstrap): cache session's bootstrap files so we don't invali...
by anisoptera · 2026-02-20
55.9%
#7894: Memory improvements: Give OpenClaw better memory + REM sleep
by bornio · 2026-02-03
55.9%