OpenClaw 通过任务、定时任务、推断承诺、事件钩子和常驻指令在后台运行工作。
快速决策指南
| 需求 | 推荐机制 | 原因 |
|---|---|---|
| 每天 9 点发报告 | Scheduled Tasks (Cron) | 精确时间,隔离执行 |
| 20 分钟后提醒我 | Scheduled Tasks (Cron) | 一次性精确时间(--at) |
| 每 30 分钟检查收件箱 | Heartbeat | 批量检查,有会话上下文 |
| 面试后跟进 | Inferred Commitments | 记忆式跟进,无需精确提醒 |
| 查看子 Agent 状态 | Background Tasks | 任务台账追踪所有后台工作 |
| 多步研究后汇总 | Task Flow | 持久化编排,带修订追踪 |
| 会话重置时运行脚本 | Hooks | 事件驱动,生命周期触发 |
| 每次工具调用执行代码 | Plugin hooks | 进程内钩子,可拦截工具调用 |
| 每次回复前检查合规 | Standing Orders | 自动注入每个会话 |
Cron vs Heartbeat 对比
| 维度 | Scheduled Tasks (Cron) | Heartbeat |
|---|---|---|
| 时间精度 | 精确(cron 表达式/一次性) | 近似(默认每 30 分钟) |
| 会话上下文 | 新鲜(隔离)或共享 | 完整主会话上下文 |
| 任务记录 | 始终创建 | 从不创建 |
| 投递方式 | Channel/Webhook/静默 | 内联到主会话 |
| 适合 | 报告、提醒、后台任务 | 收件箱检查、日历、通知 |
六种自动化机制
1. Scheduled Tasks (Cron)
Gateway 内置调度器,精确时间触发,持久化任务定义。 → concepts/automation-cron
2. Background Tasks
后台任务台账,追踪所有后台工作(ACP/子 Agent/Cron/CLI)。 → concepts/automation-tasks
3. Inferred Commitments
从对话推断的短期跟进记忆,通过 Heartbeat 投递。 → commitments
4. Task Flow
多步流程编排层,持久化状态,修订追踪。 → concepts/automation-taskflow
5. Standing Orders
工作区文件中的永久操作授权,注入每个会话。 → concepts/automation-standing-orders
6. Hooks
事件驱动脚本,响应 Agent 生命周期事件。 → concepts/automation-hooks
协同工作
- Cron 处理精确调度(日报、周报)和一次性提醒
- Heartbeat 处理例行监控(收件箱、日历)
- Hooks 响应特定事件(会话重置、压缩、消息流)
- Standing Orders 给 Agent 持久上下文和权限边界
- Task Flow 协调多步流程
- Tasks 自动追踪所有后台工作
相关
- commitments — 推断承诺
- gateway/heartbeat — 心跳机制