返回顶部
🇺🇸 English
🇨🇳 简体中文
🇨🇳 繁體中文
🇺🇸 English
🇯🇵 日本語
🇰🇷 한국어
🇫🇷 Français
🇩🇪 Deutsch
🇪🇸 Español
🇷🇺 Русский
s

smart-wake

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

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
309
下载量
免费
免费
1
收藏
概述
安装方式
版本历史

smart-wake

# SKILL: smart-wake ## Objective Ensure long-running tasks do not lose progress when subagent timeout occurs. Standard mechanism: 1. **Auto-save state** before timeout / reaching timeout threshold. 2. **Cron wake** to re-invoke agent at scheduled time. 3. **Resume task** from latest checkpoint using `sessions_spawn` (or `session_spawn` depending on runtime) with appropriate `wakeMode`. --- ## Activation Triggers Use `smart-wake` when any of the following conditions are met: - Task duration exceeds default subagent timeout. - Requires periodic polling (by minute/hour) to continue processing. - Multi-step workflow that may pause mid-execution but must resume accurately. - Running overnight / off-hours but still needs to auto-continue. --- ## Available Tools (Built-in) - `sessions_spawn` / `session_spawn` (spawn new work session) - Gateway cron jobs (schedule wake events) - Memory/slot for state persistence (state checkpoint) > Do not create new tools. Only use existing mechanisms. --- ## State Contract (MANDATORY) Each task must implement checkpointing with minimum schema: ```json { "task_id": "smartwake_<slug>_<timestamp>", "goal": "Final objective", "status": "running|waiting|blocked|done|failed", "current_step": "step_name", "progress_pct": 0, "last_completed": ["step_a", "step_b"], "next_actions": ["action_1", "action_2"], "artifacts": ["path/file1", "path/file2"], "errors": [], "retry_count": 0, "updated_at": "ISO_TIMESTAMP" } ``` Requirements: - Update checkpoint after each completed step. - Final checkpoint before timeout. - Resume always reads latest checkpoint; never re-run blindly. --- ## Standard Workflow ### Step 1 — Preflight (Estimate Timeout) - Determine subagent timeout and total task duration. - If `estimated_duration > 70% timeout`: enable `smart-wake` immediately. - Create `task_id` and initial checkpoint. ### Step 2 — Execute by Small Chunks - Divide task into 5–15 minute chunks. - After each chunk: - Write progress to checkpoint, - Record artifact/path, - Update `next_actions`. ### Step 3 — Pre-timeout Auto-save - When ~10–20% timeout remains: - Flush final checkpoint, - Set `status = waiting`, - Prepare resume payload (task_id + next_actions). ### Step 4 — Schedule Cron Wake - Register Gateway cron job to wake after appropriate interval (e.g., 2–10 minutes depending on load). - Cron payload MUST contain: - `task_id` - `resume_from=latest_checkpoint` - `reason=timeout_recovery` ### Step 5 — Spawn Resume Session - At wake time, call `sessions_spawn` (or `session_spawn`) with `wakeMode` enabling auto-resume via cron. - Pass concise context: - objective, - latest checkpoint, - next step, - completion criteria. ### Step 6 — Resume + Idempotency Guard - New session must: 1. Read checkpoint, 2. Verify artifacts exist, 3. Skip completed steps, 4. Continue exact `next_actions`. - When entire task completes: set `status = done`, cancel remaining cron wakes. --- ## Sample Resume Packet (Reference) ```json { "task": "Resume long-running task", "task_id": "smartwake_repo_scan_20260301T120000Z", "wakeMode": "cron", "resume": { "from": "latest_checkpoint", "current_step": "collect_phase_2", "next_actions": ["fetch page 6-10", "dedupe", "export report"] }, "done_criteria": [ "output file generated", "validation passed", "status marked done" ] } ``` > Note: Field names may vary by Gateway/OpenClaw version, but checkpoint + wakeMode + resume context principles are mandatory. --- ## Operational Rules 1. **Never resume without valid checkpoint.** 2. **Never overwrite artifacts without checksum/timestamp verification.** 3. **No infinite wake loops**: limit `retry_count` (e.g., max 5). 4. **Every wake must have clear reason** (`timeout_recovery`, `dependency_ready`, `scheduled_progress`). 5. **Clean up on done**: completed task must clear related cron jobs. --- ## Output Format After Each Wake Cycle ```json { "task_id": "smartwake_<...>", "status": "running|waiting|done|failed", "progress_pct": 65, "current_step": "...", "resumed_from_checkpoint": true, "next_wake_scheduled": true, "next_wake_at": "ISO_TIMESTAMP|null", "notes": "concise, auditable" } ``` --- ## Anti-patterns (FORBIDDEN) - Running long tasks without periodic checkpointing. - Waking without passing `task_id`/resume context. - Re-running entire pipeline from start when only 1 step is missing. - Not canceling cron after `done`. --- ## Expected Outcomes - No state loss on subagent timeout. - Long tasks progress steadily via cron wake. - Full system auditability: checkpoint → wake → resume → done.

标签

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!

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部