闲社服务运行正常AI智能体自动化平台
s

智能唤醒

技能标识:smart-wake

Prevent subagent timeout using checkpoint + cron wake + resume via session spawn mechanism.

作者:admin | 来源记录:ClawHub
登记来源
ClawHub
版本
V 1.0.0
检测标记
后台标记通过
免费
免费获取
1
收藏
来源与检测标记为平台登记信息,并不代表已展示可复核的检测报告。使用前请核对版本、依赖和所需权限,建议先在隔离环境中运行。
概述
安装方式
版本历史

智能唤醒

技能:smart-wake

目标

确保长时间运行的任务在子代理超时时不会丢失进度。

标准机制:

  1. 1. 自动保存状态 在超时前/达到超时阈值时。
  2. 定时唤醒 在预定时间重新调用代理。
  3. 恢复任务 从最新检查点使用 sessionsspawn(或根据运行环境使用 sessionspawn)并配合适当的 wakeMode。



触发条件


当满足以下任一条件时使用 smart-wake:
  • - 任务持续时间超过默认子代理超时时间。
  • 需要定期轮询(按分钟/小时)以继续处理。
  • 多步骤工作流可能在中途暂停但必须准确恢复。
  • 在夜间/非工作时间运行但仍需自动继续。



可用工具(内置)


  • - sessionsspawn / sessionspawn(生成新的工作会话)
  • 网关定时任务(调度唤醒事件)
  • 用于状态持久化的内存/槽位(状态检查点)

不要创建新工具。仅使用现有机制。


状态契约(必选)

每个任务必须实现具有最小模式的检查点:

json
{
taskid: smartwake_,
goal: 最终目标,
status: running|waiting|blocked|done|failed,
current_step: 步骤名称,
progress_pct: 0,
lastcompleted: [步骤a, 步骤_b],
nextactions: [操作1, 操作_2],
artifacts: [路径/文件1, 路径/文件2],
errors: [],
retry_count: 0,
updatedat: ISOTIMESTAMP
}

要求:

  • - 在完成每个步骤后更新检查点。
  • 在超时前进行最终检查点保存。
  • 恢复时始终读取最新检查点;绝不盲目重新运行。



标准工作流程

步骤 1 — 预检(估算超时时间)

  • - 确定子代理超时时间和总任务持续时间。
  • 如果 estimatedduration > 70% timeout:立即启用 smart-wake。
  • 创建 taskid 和初始检查点。

步骤 2 — 分小块执行

  • - 将任务划分为 5–15 分钟的小块。
  • 每个小块完成后:
- 将进度写入检查点, - 记录工件/路径, - 更新 next_actions。

步骤 3 — 超时前自动保存

  • - 当剩余时间约为超时时间的 10–20% 时:
- 刷新最终检查点, - 设置 status = waiting, - 准备恢复负载(taskid + nextactions)。

步骤 4 — 调度定时唤醒

  • - 注册网关定时任务,在适当间隔后唤醒(例如,根据负载情况 2–10 分钟)。
  • 定时负载必须包含:
- task_id - resumefrom=latestcheckpoint - reason=timeout_recovery

步骤 5 — 生成恢复会话

  • - 在唤醒时,调用 sessionsspawn(或 sessionspawn)并设置 wakeMode 以通过定时任务启用自动恢复。
  • 传递简洁上下文:
- 目标, - 最新检查点, - 下一步, - 完成标准。

步骤 6 — 恢复 + 幂等性保护

  • - 新会话必须:
1. 读取检查点, 2. 验证工件是否存在, 3. 跳过已完成的步骤, 4. 继续执行确切的 next_actions。
  • - 当整个任务完成时:设置 status = done,取消剩余的定时唤醒。

示例恢复数据包(参考)

json
{
task: 恢复长时间运行的任务,
taskid: smartwakereposcan20260301T120000Z,
wakeMode: cron,
resume: {
from: latest_checkpoint,
currentstep: collectphase_2,
next_actions: [获取第6-10页, 去重, 导出报告]
},
done_criteria: [
输出文件已生成,
验证通过,
状态标记为完成
]
}

注意:字段名称可能因 Gateway/OpenClaw 版本而异,但检查点 + wakeMode + 恢复上下文原则是强制性的。


操作规则

  1. 1. 没有有效检查点绝不恢复。
  2. 未经校验和/时间戳验证绝不覆盖工件。
  3. 无无限唤醒循环:限制 retrycount(例如,最多 5 次)。
  4. 每次唤醒必须有明确原因(timeoutrecovery、dependencyready、scheduledprogress)。
  5. 完成后清理:已完成的任务必须清除相关的定时任务。

每次唤醒周期后的输出格式

json
{
taskid: smartwake<...>,
status: running|waiting|done|failed,
progress_pct: 65,
current_step: ...,
resumedfromcheckpoint: true,
nextwakescheduled: true,
nextwakeat: ISO_TIMESTAMP|null,
notes: 简洁、可审计
}



反模式(禁止)


  • - 运行长时间任务而不进行定期检查点保存。
  • 未传递 task_id/恢复上下文就唤醒。
  • 仅缺少 1 个步骤时从头重新运行整个流程。
  • 完成后未取消定时任务。



预期结果


  • - 子代理超时时无状态丢失。
  • 长时间任务通过定时唤醒稳步推进。
  • 完整系统可审计性:检查点 → 唤醒 → 恢复 → 完成。

标签

skill ai

通过对话安装

以下为平台配置的接入选项,并非逐项实测通过。能否安装取决于客户端支持、技能来源和运行环境:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 smart-wake-1776281918 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 smart-wake-1776281918 技能

通过命令行安装

skillhub install smart-wake-1776281918

下载

⬇ 下载 smart-wake v1.0.0(免费)

文件大小: 2.77 KB | 发布时间: 2026-4-16 17:08

v1.0.0 最新 2026-4-16 17:08
smart-wake` is a critical survival protocol designed to protect autonomous AI agents from being "killed" silently due to system timeouts when executing long, complex, or resource-heavy tasks (such as code compilation, large web scraping, or waiting for API responses). It transforms the agent from a passive listener into a proactive, self-sustaining worker.

**How to Use (For Agents):**
Whenever you are assigned a task that might exceed your given timeout limit, you must:
1. **Divide the work:** Break the task into smaller executable chunks (e.g., 5-minute blocks).
2. **Save your progress (Checkpoint):** Right before you suspect a timeout is approaching, save exactly what you have completed and what needs to be done next into a JSON checkpoint object.
3. **Set an Alarm (Cron Wake):** Use the `cron` tool to schedule a wake-up call for yourself in a few minutes.
4. **Pass the Baton:** In the cron payload, inject the `task_id` and the `next_actions`. When the cron wakes you (or spawns a fresh subagent session), you will read the checkpoint and resume exactly where you left off, completely bypassing the timeout limit!
返回顶部