DeepSleep v3.0
Two-phase daily memory persistence for AI agents.
Like humans need sleep for memory consolidation, AI agents need DeepSleep to persist context across sessions.
What's New in v3.0
| Change | Impact |
|---|---|
| ๐ด Unified pack+dispatch cron | Single 23:50 job replaces two separate crons. Saves ~2-3ไธ token/day in cron startup overhead |
| ๐ด Silent day fast path | Skips history pull on silent days. Saves ~5-8ไธ token/day when nothing happened |
| ๐ด Smartๆจๆฅ delivery | Only sends morning briefs when there's real content, P0 due items, or stale OQs. Eliminates noise |
| ๐ก Memory importance tiers | ๐ดP0/๐กP1/๐ขP2 per entry. Different retention windows (7/5/3 days). Phase 3 loads P0+P1 first |
| ๐ก Cross-group correlation | Detects related topics across groups. "่ง้ข่ฎญ็ปๅฎ้ชๅฎค โ ๅ้ฎๅพฎ่ฐๅฎ้ชๅฎค: both discussing Qwen-VL" |
| ๐ก OQ health tracking | Tracks age of each Open Question. โ ๏ธ at 7d, escalation at 14d, archive at 30d |
| ๐ก Schedule priority + reminders | P0/P1/P2 priorities with differentiated reminder frequency. P0 overdue = daily nag |
| ๐ข dispatch_policy flag | Pack sets active/silent in daily file header; dispatch reads it to decide behavior |
| ๐ข Memory quality audit | Weekly self-audit: compare raw conversation vs summary to catch missed info |
When to Activate
Activate when user mentions daily summary, memory persistence, sleep cycle, cross-session memory, morning brief, or nightly pack.
Architecture
23:50 cron "deepsleep" (single unified job)
โ
โโโ PACK PHASE
โ โโโ Lock date (midnight race protection)
โ โโโ sessions_list โ detect active/silent
โ โ
โ โโโ [ACTIVE DAY]
โ โ โโโ sessions_history (parallel batch)
โ โ โโโ Filter + summarize with importance tiers
โ โ โโโ Cross-group correlation detection
โ โ โโโ OQ health check (age tracking)
โ โ โโโ Schedule update (priority + dedup)
โ โ โโโ Write daily file (dispatch_policy: active)
โ โ
โ โโโ [SILENT DAY โ fast path, <5000 tokens]
โ โ โโโ Read recent daily file
โ โ โโโ Carry-forward with decay
โ โ โโโ Write daily file (dispatch_policy: silent)
โ โ
โ โโโ Update MEMORY.md (P0 only, guard rails)
โ
โโโ DISPATCH PHASE (same session, skip re-read)
โโโ Dedup check (dispatch-lock.md)
โโโ Smart send decision per group
โโโ Send morning briefs (active groups only)
โโโ Schedule due-date reminders
โโโ Write per-group snapshots (tiered retention)
โโโ Write dispatch log
โโโ Write dispatch lock
On-demand Phase 3: Session Memory Restore
โโโ Load memory/groups/<chat_id>.md
โโโ Priority: load ๐ดP0 + ๐กP1 first
โโโ Check cross-group correlations
โโโ Check schedule.md for P0 due items
Phases
Phase 1: Deep Sleep Pack (23:50)
- Lock date โ Prevent midnight race condition
- Auto-discover sessions โ
sessions_list(kinds=['group', 'main'], activeMinutes=1440) - Silent day detection โ If no real user messages, enter fast path (no history pull, <5000 tokens)
- Silent Day Carry-Forward with Decay โ 4-tier decay: Days 1-3 full, 4-7 slim, 8-14 minimal, 15+ archive to MEMORY.md
- [Active day] Pull conversation history โ Parallel batch
sessions_history - Filter and summarize with importance tiers โ ๐ดP0 strategic, ๐กP1 important, ๐ขP2 routine
- Cross-group correlation โ Detect related topics across groups
- OQ health check โ Track age, warn at 7d, escalate at 14d, archive at 30d
- Schedule update โ With P0/P1/P2 priorities, key-based dedup
- Write daily file โ Idempotent, with
dispatch_policyflag and importance tiers - Self-check โ Validate chat_id annotations, importance tags, OQ dates
- Update MEMORY.md โ Only for P0 items, with guard rails
Phase 2: Morning Dispatch (same session, immediately after pack)
- Dedup check โ
dispatch-lock.mdprevents double-sending - Failure recovery โ If pack somehow failed, do emergency mini-pack
- Read daily file โ Already in context from pack (skip re-read in unified mode)
- Check dispatch_policy โ
active= send briefs;silent= update snapshots only - Smart send decision โ Per-group: send only if new content, P0 due items, or stale OQs
- Send per-group briefs โ With importance-highlighted summaries, cross-group hints, OQ warnings
- Schedule reminders โ P0 due/overdue = ๐ฅ in brief; P1 due = mention; P2 = summary only
- Write per-group snapshots โ Tiered retention: ๐ด7d, ๐ก5d, ๐ข3d. OQs and todos never expire
- Write dispatch log โ Including send/skip counts and policy
- Write dispatch lock
Phase 3: Session Memory Restore (on demand)
When the agent receives a message in a group:
- Check
memory/groups/<chat_id>.mdโ load if exists - Priority loading โ If token budget is tight, load ๐ด+๐ก entries first, skip ๐ข
- Check cross-group correlations โ If this group has related groups, note it
- Check
memory/schedule.mdโ Any P0 items due today? Proactively mention them - If snapshot missing/stale (>48h) โ Fall back to
memory/YYYY-MM-DD.md
Phase 4: Memory Quality Audit (weekly, optional)
Once a week (suggest: Sunday heartbeat or dedicated cron), self-audit pack quality:
- Pick 2-3 random groups from the past week
- Pull raw
sessions_historyfor those groups - Compare raw conversation vs the daily summary that was generated
- Check for:
- Missed important info โ Decisions or lessons that didn't make it into the summary
- Over-compression โ Context that was lost in summarization
- Misclassification โ Items marked P2 that should have been P1/P0
- OQ staleness โ Questions that resolved in conversation but weren't marked done
- Write audit findings to
memory/audit-log.md - If patterns emerge (e.g., consistently missing technical decisions), update filtering criteria in pack-instructions.md
Daily Summary Template
## DeepSleep Daily Summary
<!-- dispatch_policy: active|silent -->
<!-- pack_version: 3.0 -->
<!-- silent_days: N (only if silent) -->
> Auto-discovered N active groups (24h). schedule.md: [items due / none].
### [Group Name] <!-- chat:oc_abc123 -->
- ๐ด Strategic decision summary
- ๐ก Important progress
- ๐ข Routine note
### ๐ Cross-Group Correlations (if any)
- GroupA โ GroupB: related topic description
### Direct Messages
- N DMs processed (no details โ privacy)
### ๐ฎ Open Questions
- Question [since: MM-DD, pending N days]
- โ ๏ธ Question [since: MM-DD, pending 14 days โ escalate or shelve]
### ๐ Today (Next Day)
- Action items (reader perspective)
- ๐ฅ P0 due: [schedule item]
### Todo
- [ ] Immediate action items
Schedule File Format
File: memory/schedule.md
| Key | Date | Source | Item | Priority | Status |
|-----|------|--------|------|----------|--------|
| ds-v30 | 2026-04-04 | DeepSleepๅฎ้ชๅฎค | DeepSleep v3.0 ้ช่ฏ | P0 | pending |
Priority levels:
- P0 โ Must complete on due date. Reminded in morning brief + Phase 3. Overdue = daily nag
- P1 โ Important, mentioned in morning brief on due date
- P2 โ Low priority, noted in daily summary only
Per-Group Snapshot Format
File: memory/groups/<chat_id>.md
# [Group Name] ่ฟๆ่ฎฐๅฟ
> ๆดๆฐๆถ้ด๏ผYYYY-MM-DD HH:MM
> ่ฟ็ปญ้้ป N ๅคฉ๏ผๆๅๆดป่ท๏ผYYYY-MM-DD (only if silent)
## ๆ่ฟ่ฟๅฑ
- ๐ด [YYYY-MM-DD] Strategic item (retained 7 days)
- ๐ก [YYYY-MM-DD] Important item (retained 5 days)
- ๐ข [YYYY-MM-DD] Routine item (retained 3 days)
## ๐ฎ Open Questions
- Question [since: MM-DD, pending N days]
## ๐ Todo
- [ ] Incomplete (never expires)
- [x] Completed (pruned after 3 days)
## ๐ Related Groups
- โ [Related Group]: topic description
Setup
1. Create unified cron job (v3.0: single job)
# v3.0: Single unified pack+dispatch job at 23:50
openclaw cron add \
--name "deepsleep" \
--cron "50 23 * * *" \
--tz "Your/Timezone" \
--session isolated \
--message "Execute DeepSleep v3.0. Read the deepsleep skill pack-instructions.md and follow it strictly. After pack completes, continue with dispatch (pack-instructions.md Step 6)." \
--timeout-seconds 900 \
--no-deliver
โ ๏ธ Migration from v2.x: If you have two separate cron jobs (deepsleep-pack and deepsleep-dispatch), remove them and create the single unified job above:
openclaw cron remove <pack-job-id>
openclaw cron remove <dispatch-job-id>
openclaw cron add ... # the unified job above
2. Optional: Weekly audit cron
openclaw cron add \
--name "deepsleep-audit" \
--cron "0 10 * * 0" \
--tz "Your/Timezone" \
--session isolated \
--message "Execute DeepSleep Phase 4 memory quality audit. Read deepsleep SKILL.md Phase 4 section." \
--timeout-seconds 600 \
--no-deliver
3. Enable cross-session visibility
openclaw config set tools.sessions.visibility all
openclaw gateway restart
4. Initialize schedule
Create memory/schedule.md with the table header.
5. Add Phase 3 restore to AGENTS.md
See Phase 3 section above for the standing order template.
Requirements
- OpenClaw with
tools.sessions.visibilityset toall - Single cron job using
agentTurnmode (--session isolated) with--timeout-seconds 900 --no-deliveron cron job (dispatch sends messages directly via message tool)
Privacy Notes
- Pack writes a daily summary that dispatch may broadcast to groups. Never include private MEMORY.md content.
- Each group only receives its own summary โ no cross-group content leakage.
- Cross-group correlations mention only the topic connection, never specific conversation content from another group.
- MEMORY.md is updated separately and stays in the main session only.
- Per-group snapshots only contain that group's own conversation summaries.
- DM content: only "N DMs processed" in daily summary; details go to MEMORY.md only.
Known Gotchas
- Cron timezone:
--tz Asia/Shanghaimeans cron expression is in LOCAL time. Don't convert to UTC. - Must use isolated agentTurn:
systemEventignorestimeoutSeconds(hardcoded ~120s). Use--session isolated. - Timeout must be generous: 900s (15 min). Real-world unified pack+dispatch with 8 sessions takes ~3-5 min.
- Parallel tool calls: Batch
sessions_historyand snapshot writes in parallel. - Chat ID in headers: Every
### GroupNameMUST have<!-- chat:oc_xxx -->. Missing = group loses memory. - Header must be exact:
## DeepSleep Daily Summaryโ no variations. - dispatch_policy flag: Pack MUST set
<!-- dispatch_policy: active|silent -->. Dispatch reads this. - Time perspective: Briefs use reader perspective: "yesterday did X / today do Y".
- Midnight race: Lock PACK_DATE at start, never re-fetch.
- Dispatch dedup:
dispatch-lock.mdwritten AFTER sends complete. - Schedule Key dedup: Check existing keys before writing.
- Silent Day Decay: 4-tier (1-3d full / 4-7d slim / 8-14d minimal / 15+d archive).
- MEMORY.md guard rails: Append/update only. Never delete/restructure.
- DM privacy: Daily summary is broadcast; MEMORY.md is diary. Don't mix.
- Importance tiers: ๐ดP0 retained 7d in snapshots, ๐กP1 5d, ๐ขP2 3d.
- OQ age tracking: All OQs must have
[since: MM-DD, pending N days]annotation. - Cross-group correlations: Only mention topic keywords, never quote another group's conversations.
Failure Recovery
If pack fails or times out:
- Unified mode: Dispatch won't run (same session). Next day's unified job will detect missing summary and do emergency mini-pack for the missed day.
- Manual recovery: Run dispatch-instructions.md independently โ it has built-in pack-failure detection and emergency mini-pack.
Verification Checklist
# 1. Manually trigger unified job
openclaw cron run <job-id>
# 2. Check completion
openclaw cron runs --id <job-id> --limit 1
# Expected: durationMs > 120000 (proves timeout works)
# 3. Check pack output
cat memory/YYYY-MM-DD.md | grep "DeepSleep Daily Summary"
cat memory/YYYY-MM-DD.md | grep "dispatch_policy"
cat memory/YYYY-MM-DD.md | grep "pack_version: 3.0"
# 4. Check dispatch output
ls -la memory/groups/
# Expected: updated timestamps on group snapshot files
# 5. Check dispatch log
tail -20 memory/dispatch-log.md
# 6. Check Feishu groups (only active groups should receive briefs)
Inspirations
Built with insights from the community: agent-sleep (multi-level sleep), memory-reflect (filtering criteria), jarvis-memory-architecture (cron inbox), memory-curator (open questions).
Scan to join WeChat group