← Back to Skills Marketplace
jeffchang2024

DeepSleep

by JeffChang2024 · GitHub ↗ · v3.0.0 · MIT-0
cross-platform ✓ Security Clean
167
Downloads
0
Stars
0
Active Installs
3
Versions
Install in OpenClaw
/install deepsleep
Description
Two-phase daily memory persistence for AI agents. v3.0: unified pack+dispatch cron, smart silence handling, memory importance tiers, cross-group correlation,...
README (SKILL.md)

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, \x3C5000 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/\x3Cchat_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)

  1. Lock date — Prevent midnight race condition
  2. Auto-discover sessionssessions_list(kinds=['group', 'main'], activeMinutes=1440)
  3. Silent day detection — If no real user messages, enter fast path (no history pull, \x3C5000 tokens)
  4. Silent Day Carry-Forward with Decay — 4-tier decay: Days 1-3 full, 4-7 slim, 8-14 minimal, 15+ archive to MEMORY.md
  5. [Active day] Pull conversation history — Parallel batch sessions_history
  6. Filter and summarize with importance tiers — 🔴P0 strategic, 🟡P1 important, 🟢P2 routine
  7. Cross-group correlation — Detect related topics across groups
  8. OQ health check — Track age, warn at 7d, escalate at 14d, archive at 30d
  9. Schedule update — With P0/P1/P2 priorities, key-based dedup
  10. Write daily file — Idempotent, with dispatch_policy flag and importance tiers
  11. Self-check — Validate chat_id annotations, importance tags, OQ dates
  12. Update MEMORY.md — Only for P0 items, with guard rails

Phase 2: Morning Dispatch (same session, immediately after pack)

  1. Dedup checkdispatch-lock.md prevents double-sending
  2. Failure recovery — If pack somehow failed, do emergency mini-pack
  3. Read daily file — Already in context from pack (skip re-read in unified mode)
  4. Check dispatch_policyactive = send briefs; silent = update snapshots only
  5. Smart send decision — Per-group: send only if new content, P0 due items, or stale OQs
  6. Send per-group briefs — With importance-highlighted summaries, cross-group hints, OQ warnings
  7. Schedule reminders — P0 due/overdue = 🔥 in brief; P1 due = mention; P2 = summary only
  8. Write per-group snapshots — Tiered retention: 🔴7d, 🟡5d, 🟢3d. OQs and todos never expire
  9. Write dispatch log — Including send/skip counts and policy
  10. Write dispatch lock

Phase 3: Session Memory Restore (on demand)

When the agent receives a message in a group:

  1. Check memory/groups/\x3Cchat_id>.md — load if exists
  2. Priority loading — If token budget is tight, load 🔴+🟡 entries first, skip 🟢
  3. Check cross-group correlations — If this group has related groups, note it
  4. Check memory/schedule.md — Any P0 items due today? Proactively mention them
  5. 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:

  1. Pick 2-3 random groups from the past week
  2. Pull raw sessions_history for those groups
  3. Compare raw conversation vs the daily summary that was generated
  4. 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
  5. Write audit findings to memory/audit-log.md
  6. If patterns emerge (e.g., consistently missing technical decisions), update filtering criteria in pack-instructions.md

Daily Summary Template

## DeepSleep Daily Summary
\x3C!-- dispatch_policy: active|silent -->
\x3C!-- pack_version: 3.0 -->
\x3C!-- silent_days: N (only if silent) -->

> Auto-discovered N active groups (24h). schedule.md: [items due / none].

### [Group Name] \x3C!-- 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/\x3Cchat_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 \x3Cpack-job-id>
openclaw cron remove \x3Cdispatch-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.visibility set to all
  • Single cron job using agentTurn mode (--session isolated) with --timeout-seconds 900
  • --no-deliver on 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

  1. Cron timezone: --tz Asia/Shanghai means cron expression is in LOCAL time. Don't convert to UTC.
  2. Must use isolated agentTurn: systemEvent ignores timeoutSeconds (hardcoded ~120s). Use --session isolated.
  3. Timeout must be generous: 900s (15 min). Real-world unified pack+dispatch with 8 sessions takes ~3-5 min.
  4. Parallel tool calls: Batch sessions_history and snapshot writes in parallel.
  5. Chat ID in headers: Every ### GroupName MUST have \x3C!-- chat:oc_xxx -->. Missing = group loses memory.
  6. Header must be exact: ## DeepSleep Daily Summary — no variations.
  7. dispatch_policy flag: Pack MUST set \x3C!-- dispatch_policy: active|silent -->. Dispatch reads this.
  8. Time perspective: Briefs use reader perspective: "yesterday did X / today do Y".
  9. Midnight race: Lock PACK_DATE at start, never re-fetch.
  10. Dispatch dedup: dispatch-lock.md written AFTER sends complete.
  11. Schedule Key dedup: Check existing keys before writing.
  12. Silent Day Decay: 4-tier (1-3d full / 4-7d slim / 8-14d minimal / 15+d archive).
  13. MEMORY.md guard rails: Append/update only. Never delete/restructure.
  14. DM privacy: Daily summary is broadcast; MEMORY.md is diary. Don't mix.
  15. Importance tiers: 🔴P0 retained 7d in snapshots, 🟡P1 5d, 🟢P2 3d.
  16. OQ age tracking: All OQs must have [since: MM-DD, pending N days] annotation.
  17. 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 \x3Cjob-id>

# 2. Check completion
openclaw cron runs --id \x3Cjob-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).

Usage Guidance
This skill is coherent with its stated purpose (nightly packing, summarization, and conditional morning dispatch) and does not contain obvious external exfiltration or hidden downloads, but it will (if enabled) read full conversation histories and write persistent memory files under your agent's data directory. Before installing: 1) Verify you trust the skill source (registry shows no homepage/source repo). 2) Confirm an administrator is comfortable setting tools.sessions.visibility = all — that grants access to group and DM histories. 3) Review or sandbox the skill in a non-production environment to inspect generated files (memory/, MEMORY.md, schedule.md) and confirm guard rails behave as expected. 4) Inspect the chat-id mapping file (chat-id-mapping.local.md) and ensure it doesn't contain unwanted mappings. 5) Decide retention/encryption for memory files and whether you need additional access controls or an audit trail for the cron's isolated session. If you need higher assurance, request source code or a canonical repo from the author before deployment.
Capability Assessment
Purpose & Capability
Name/description (daily pack+dispatch memory persistence) match the instructions: the SKILL.md describes packing session history, summarizing with importance tiers, writing daily files and per-group snapshots, and conditionally dispatching morning briefs. The requested operations (sessions_list, sessions_history, read/write under ~/clawd/memory, sending via the platform message tool) are proportionate to that purpose.
Instruction Scope
Instructions explicitly direct the agent to read full session histories, generate summaries, and write persistent files (memory/YYYY-MM-DD.md, memory/groups/<chat_id>.md, schedule.md, dispatch-log.md, dispatch-lock.md, MEMORY.md). This is expected for a memory persistence skill but is privacy-sensitive: the agent will collect and persist cross-session/group content and open questions. The SKILL.md includes guard rails (e.g., only P0 updates to MEMORY.md, per-group privacy rules, cross-group hints without content), which is appropriate, but these are policy-level controls implemented in prose rather than enforced code.
Install Mechanism
Instruction-only skill (no install spec, no downloads, no code files executed). Runtime relies on platform tool calls and the OpenClaw CLI examples in README. Absence of an install step reduces disk-level risk.
Credentials
The skill declares no environment variables or external credentials — consistent with contents. However it requires (and documents) OpenClaw platform configuration changes (tools.sessions.visibility set to 'all') and creation of a cron job that runs an isolated agentTurn which will be able to read session histories and send messages via the platform gateway. Those platform privileges are necessary for the stated purpose but are significant: enabling full session visibility allows the skill to access DMs and group histories, so enable only if you trust the skill and the operator.
Persistence & Privilege
always:false (not forced) and the design expects a cron that runs periodically in an isolated session; pack+dispatch run in the same session. The skill writes multiple persistent files under ~/clawd/memory and updates MEMORY.md per its guard rails. This is consistent with the declared function and does not appear to attempt to modify other skills or system-wide agent config.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install deepsleep
  3. After installation, invoke the skill by name or use /deepsleep
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v3.0.0
v3.0: Unified pack+dispatch cron, silent day fast path, importance tiers (P0/P1/P2), cross-group correlation, OQ health tracking, schedule priorities, weekly quality audit
v2.1.0
v2.1: midnight race fix, dispatch dedup, DM privacy, schedule dedup, 3-day rolling snapshots, send logging, MEMORY guard rails, time perspective fix
v1.0.0
- Initial release of deepsleep skill: automated two-phase daily memory management for AI agents. - Nightly "deep sleep pack" phase at 23:40 summarizes and persists key conversation data, filters by importance, and tracks open questions. - Morning "dispatch" phase at 00:10 delivers per-group briefs and alerts from the stored summaries. - Auto-discovers sessions and filters persisted content by criteria such as decisions, lessons, and milestones. - Requires cron setup for both phases and initial memory configuration.
Metadata
Slug deepsleep
Version 3.0.0
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 3
Frequently Asked Questions

What is DeepSleep?

Two-phase daily memory persistence for AI agents. v3.0: unified pack+dispatch cron, smart silence handling, memory importance tiers, cross-group correlation,... It is an AI Agent Skill for Claude Code / OpenClaw, with 167 downloads so far.

How do I install DeepSleep?

Run "/install deepsleep" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is DeepSleep free?

Yes, DeepSleep is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does DeepSleep support?

DeepSleep is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created DeepSleep?

It is built and maintained by JeffChang2024 (@jeffchang2024); the current version is v3.0.0.

💬 Comments