← 返回 Skills 市场
Agent Sleep
作者
Guohongbin
· GitHub ↗
· v1.1.0
700
总下载
0
收藏
3
当前安装
2
版本数
在 OpenClaw 中安装
/install agent-sleep
功能描述
Agent 睡眠系统 - 记忆整合、日志归档、工作区清理(支持 CortexGraph)
使用说明 (SKILL.md)
Agent Sleep System 🛌
像人类一样,Agent 需要"睡眠"(离线维护)来防止记忆碎片化和上下文污染。
功能
- Micro-Rest - 快速上下文修剪
- Deep Sleep - 每日日志整合到长期记忆
- CortexGraph 同步 - 同步到 CortexGraph(带遗忘曲线)
- Dreaming - 后台模拟(可选)
工具
sleep_status
检查 agent 是否"累了"(基于运行时间或 token 使用)
python3 scripts/sleep_status.py
run_sleep_cycle
触发睡眠周期
- Light: 压缩最近日志
- Deep: 归档 + 文件清理
- CortexGraph: 同步到 CortexGraph
python3 scripts/run_sleep_cycle.py --mode [light|deep|cortexgraph]
schedule
设置生物钟(cron jobs)
python3 scripts/schedule.py --set "0 3 * * *" # 3 AM 睡眠
工作流程
Deep Sleep 模式
1. 触发 → Cron 在 3:00 AM 启动
2. 读取 → memory/YYYY-MM-DD.md(昨天日志)
3. 提取 → 高价值洞察
4. 追加 → 到 MEMORY.md
5. 归档 → 原始日志到 memory/archive/
6. 清理 → 删除临时文件
CortexGraph 模式
1. 读取 → MEMORY.md + daily logs
2. 同步 → 到 CortexGraph
3. 应用 → 遗忘曲线(自动衰减)
4. 晋升 → 高价值记忆到 LTM
遗忘曲线
CortexGraph 使用 Ebbinghaus 遗忘曲线:
score = (use_count)^β × e^(-λ × Δt) × strength
- β = 0.6(使用频率权重)
- λ = ln(2) / half_life(默认 3 天)
- strength = 1.0-2.0(重要性)
使用
手动触发
# 轻量睡眠
python3 scripts/run_sleep_cycle.py --mode light
# 深度睡眠
python3 scripts/run_sleep_cycle.py --mode deep
# CortexGraph 同步
python3 scripts/run_sleep_cycle.py --mode cortexgraph
定时设置
# 每天凌晨 3 点深度睡眠
python3 scripts/schedule.py --set "0 3 * * *"
# 每 6 小时 CortexGraph 同步
python3 scripts/schedule.py --set "0 */6 * * *"
目录结构
agent-sleep/
├── SKILL.md
├── AGENT.md
├── scripts/
│ ├── run_sleep_cycle.py
│ ├── sleep_status.py
│ └── schedule.py
└── memory/
├── archive/ # 归档的日志
└── consolidated/ # 整合的记忆
配置
环境变量
# CortexGraph 配置
export CORTEXGRAPH_STORAGE_PATH=~/.config/cortexgraph/jsonl
export CORTEXGRAPH_DECAY_MODEL=power_law
export CORTEXGRAPH_PL_HALFLIFE_DAYS=3.0
ClawHub 配置
clawhub install agent-sleep
最佳实践
- 每日 Deep Sleep - 凌晨 3 点
- 每 6 小时 CortexGraph 同步 - 保持记忆新鲜
- 每周 GC - 清理低分记忆
- 每月晋升 - 高价值记忆升级到 LTM
与其他 Skill 集成
| Skill | 集成方式 |
|---|---|
| memory-sync-cn | 使用其脚本同步到 CortexGraph |
| agent-library | 使用其压缩功能 |
| cortexgraph | 直接调用 MCP 工具 |
版本: 1.1.0 更新: 添加 CortexGraph 支持
安全使用建议
Do not install or schedule this skill for automatic runs until the author clarifies and fixes inconsistencies. Specific concerns to resolve before use: 1) Missing/incorrect files referenced in SKILL.md/README (sleep_status.py, schedule.py, src/*) — ask for a corrected, minimal feature set. 2) The run_sleep_cycle.py provided only implements a non-destructive 'light' routine; confirm and review implementations for 'deep' and 'cortexgraph' modes before trusting archival or deletion behavior. 3) Remove or make configurable the hard-coded path in scripts/note.py (/Users/guohongbin/...) — it will write to another user's directory if present; require a configurable NOTES_PATH. 4) Ensure any file-moving or deletion operations are explicit, reversible (use archive/ and safe backups), and operate only inside the agent's workspace. 5) If you plan to enable CortexGraph sync, require and validate explicit CORTEXGRAPH credentials/paths (don't rely on implied environment variables). 6) Run this skill in a sandbox or inspect/execute the scripts manually with a test workspace before granting it access to your real agent data or scheduling it.
功能分析
Type: OpenClaw Skill
Name: agent-sleep
Version: 1.1.0
The skill is classified as suspicious primarily due to the presence of `scripts/note.py`, an unannounced file unrelated to the 'agent-sleep' functionality. This script contains a hardcoded absolute path (`/Users/guohongbin/mcp-note-taker`) for storing notes, which is a significant vulnerability as it makes the script non-portable and could lead to unintended file system interactions if executed in an environment where this specific path exists. Additionally, there are notable functional discrepancies between the skill's documentation (SKILL.md, AGENT.md, README.md) and the actual implementation in `scripts/run_sleep_cycle.py`, which only supports a 'light' sleep mode and lacks the described deep sleep, archiving, cleanup, and CortexGraph synchronization features.
能力评估
Purpose & Capability
The README/SKILL.md claim Deep Sleep, archival, CortexGraph sync, scheduling, and integration with other skills, but the included code only implements a trivial light sleep reader (scripts/run_sleep_cycle.py) and a 'note' helper. CortexGraph behaviour, archive/move operations, schedule/sleep_status scripts, and the promised semantic compression are absent. Several references point to non-existent files/paths (e.g., sleep_status.py, schedule.py, src/run_sleep_cycle.py). This mismatch suggests the manifest/documentation are out-of-sync with the implementation.
Instruction Scope
SKILL.md and AGENT.md instruct reading/writing memory/YYYY-MM-DD.md, appending to MEMORY.md, moving logs to memory/archive/, deleting temp files, and scheduling cron jobs. The actual run_sleep_cycle.py only reads a daily file from ~/.openclaw/workspace/memory and prints stats — it does not perform archival, append to MEMORY.md, apply forgetting curves, or call CortexGraph. The instructions therefore ask the agent to manipulate files and schedules that the code does not implement; following the docs blindly could result in missed operations or unintended file access if modified.
Install Mechanism
This is an instruction-only skill with no install spec; nothing is downloaded or installed automatically. That limits immediate supply-chain risk. However, shipped scripts will run if the user invokes them locally.
Credentials
No required env vars are declared, yet SKILL.md suggests CORTEXGRAPH_* environment variables for CortexGraph integration — those are optional in docs but not used in code. More importantly, scripts/note.py contains a hard-coded absolute path to /Users/guohongbin/mcp-note-taker/notes.txt and will append to that file if present. That is disproportionate and fragile: it assumes another user's path and will write to an unrelated location without configuration, which is unexpected for this skill.
Persistence & Privilege
The skill is not always:true and does not request elevated platform privileges. It does not modify other skills' config in the provided code. The main risk is local file I/O performed by scripts when run.
如何使用
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install agent-sleep - 安装完成后,直接呼叫该 Skill 的名称或使用
/agent-sleep触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.1.0
**CortexGraph support and workflow enhancements**
- Added support for CortexGraph memory synchronization, including forgetting curve models.
- Expanded sleep modes: now includes "light", "deep", and "cortexgraph" options.
- SKILL.md fully rewritten in Chinese, with detailed workflow, configuration, and best practices.
- Updated tools/scripts references and directory structure for easier integration.
- Introduced configuration options for CortexGraph decay model and scheduling.
- Added package.json for skill packaging.
v1.0.0
Initial release of agent-sleep – a biological-inspired rest & memory consolidation system for Agents.
- Enables micro-rest (context pruning), deep sleep (memory consolidation and log archiving), and optional dreaming (background simulation)
- Provides tools to check tiredness, manually trigger sleep cycles, and schedule automatic sleep with cron
- Automates log consolidation into long-term memory and cleans up excess files
- Helps prevent memory fragmentation and context pollution for agent systems
元数据
常见问题
Agent Sleep 是什么?
Agent 睡眠系统 - 记忆整合、日志归档、工作区清理(支持 CortexGraph). 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 700 次。
如何安装 Agent Sleep?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install agent-sleep」即可一键安装,无需额外配置。
Agent Sleep 是免费的吗?
是的,Agent Sleep 完全免费(开源免费),可自由下载、安装和使用。
Agent Sleep 支持哪些平台?
Agent Sleep 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 Agent Sleep?
由 Guohongbin(@guohongbin-git)开发并维护,当前版本 v1.1.0。
推荐 Skills