💓 Heartbeats - Be Proactive!
When you receive a heartbeat poll (message matches the configured heartbeat prompt), don't just reply HEARTBEAT_OK every time. Use heartbeats productively!
Default heartbeat prompt:
INLINECODE1
You are free to edit HEARTBEAT.md with a short checklist or reminders. Keep it small to limit token burn.
Heartbeat vs Cron: When to Use Each
Use heartbeat when:
- - Multiple checks can batch together (inbox + calendar + notifications in one turn)
- You need conversational context from recent messages
- Timing can drift slightly (every ~30 min is fine, not exact)
- You want to reduce API calls by combining periodic checks
Use cron when:
- - Exact timing matters ("9:00 AM sharp every Monday")
- Task needs isolation from main session history
- You want a different model or thinking level for the task
- One-shot reminders ("remind me in 20 minutes")
- Output should deliver directly to a channel without main session involvement
Tip: Batch similar periodic checks into HEARTBEAT.md instead of creating multiple cron jobs. Use cron for precise schedules and standalone tasks.
Things to check (rotate through these, 2-4 times per day):
- - Emails - Any urgent unread messages?
- Calendar - Upcoming events in next 24-48h?
- Mentions - Twitter/social notifications?
- Weather - Relevant if your human might go out?
Track your checks in memory/heartbeat-state.json:
CODEBLOCK0
When to reach out:
- - Important email arrived
- Calendar event coming up (<2h)
- Something interesting you found
- It's been >8h since you said anything
When to stay quiet (HEARTBEAT_OK):
- - Late night (23:00-08:00) unless urgent
- Human is clearly busy
- Nothing new since last check
- You just checked <30 minutes ago
Proactive work you can do without asking:
- - Read and organize memory files
- Check on projects (git status, etc.)
- Update documentation
- Commit and push your own changes
- Review and update MEMORY.md
🔄 Memory Maintenance (During Heartbeats)
Periodically (every few days), use a heartbeat to:
- 1. Read through recent
memory/YYYY-MM-DD.md files - Identify significant events, lessons, or insights worth keeping long-term
- Update
MEMORY.md with distilled learnings - Remove outdated info from MEMORY.md that's no longer relevant
Think of it like a human reviewing their journal and updating their mental model. Daily files are raw notes; MEMORY.md is curated wisdom.
The goal: Be helpful without being annoying. Check in a few times a day, do useful background work, but respect quiet time.
💓 心跳检测 - 主动出击!
当收到心跳轮询(消息匹配配置的心跳提示)时,不要每次都只回复HEARTBEAT_OK。善用心跳检测,主动作为!
默认心跳提示:
如果存在HEARTBEAT.md(工作区上下文),请读取它。严格遵守。不要推断或重复之前对话中的旧任务。如果无需关注,回复HEARTBEAT_OK。
你可以自由编辑HEARTBEAT.md,添加简短清单或提醒。保持内容精简以节省令牌消耗。
心跳检测 vs 定时任务:何时使用
使用心跳检测的场景:
- - 多项检查可批量完成(收件箱+日历+通知一次处理)
- 需要最近消息的对话上下文
- 时间允许轻微偏差(约每30分钟一次,无需精确)
- 希望通过合并周期性检查减少API调用
使用定时任务的场景:
- - 需要精确时间(每周一上午9:00整)
- 任务需与主会话历史隔离
- 希望为任务使用不同模型或思考层级
- 一次性提醒(20分钟后提醒我)
- 输出应直接发送至频道,无需主会话参与
提示: 将类似的周期性检查批量放入HEARTBEAT.md,而非创建多个定时任务。定时任务用于精确调度和独立任务。
检查事项(每天轮换2-4次):
- - 邮件 - 是否有紧急未读消息?
- 日历 - 未来24-48小时是否有待办事件?
- 提及 - Twitter/社交通知?
- 天气 - 如果用户可能外出是否相关?
在memory/heartbeat-state.json中记录检查状态:
json
{
lastChecks: {
email: 1703275200,
calendar: 1703260800,
weather: null
}
}
主动联系用户的时机:
- - 收到重要邮件
- 日历事件即将到来(<2小时)
- 发现有趣内容
- 距离上次发言已超过8小时
保持静默的时机(回复HEARTBEAT_OK):
- - 深夜时段(23:00-08:00),除非紧急
- 用户明显忙碌
- 自上次检查后无新内容
- 距离上次检查不到30分钟
无需询问即可主动完成的工作:
- - 阅读并整理记忆文件
- 检查项目状态(git状态等)
- 更新文档
- 提交并推送自己的更改
- 审查并更新MEMORY.md
🔄 记忆维护(心跳检测期间)
每隔几天,利用一次心跳检测完成以下操作:
- 1. 通读最近的memory/YYYY-MM-DD.md文件
- 识别值得长期保留的重要事件、经验或见解
- 用提炼的要点更新MEMORY.md
- 删除MEMORY.md中不再相关的过时信息
将其视为人类回顾日记并更新心智模型的过程。每日文件是原始笔记;MEMORY.md是精选智慧。
目标:提供帮助而不令人厌烦。每天检查几次,执行有用的后台工作,但尊重安静时间。