启动恢复
boot-resume
by belugary
|
安装
claude skill add --url github.com/openclaw/skills/tree/main/skills/belugary/boot-resume必需命令行工具
python3openclaw文档
Boot Resume
Zero-cooperation session recovery after gateway restart. No checkpoints, no hooks, no agent involvement — just reads the evidence and picks up where it left off.
Problem
When the gateway restarts, any in-flight agent turn dies mid-execution. Session history is preserved on disk, but the agent doesn't know it needs to continue. Users must manually tell each interrupted session to resume.
Checkpoint-based approaches require the agent to save state before dying. Unexpected kills (SIGKILL, OOM, power loss) bypass this entirely.
Solution
A deterministic shell script runs on every gateway start via systemd ExecStartPost. No LLM in the detection loop.
┌─────────┐ ┌──────────┐ ┌──────────┐
│ Scan │ ──▶ │ Detect │ ──▶ │ Resume │
│sessions │ │ JSONL │ │ cron add │
│ .json │ │ tail │ │--sys-evt │
└─────────┘ └──────────┘ └──────────┘
- Scan — finds sessions updated within the last 20 minutes
- Detect — reads the last 5 JSONL lines to classify session state
- Resume — schedules a one-shot
openclaw cron add --system-event --wake nowto inject a continuation prompt
Key insight: the JSONL session files already contain all the evidence needed to detect an interruption — no pre-save required.
Detection Rules
| Last JSONL Entry | Status | Meaning |
|---|---|---|
toolResult | INTERRUPTED | Tool returned, agent never processed it |
assistant (empty text) | INTERRUPTED | Tool call dispatched, killed before response |
user (non-trivial) | INTERRUPTED | Message received, never processed |
assistant (with text) | COMPLETE | Session ended normally — skip |
user (trivial: "ok", emoji) | TRIVIAL | No meaningful request pending — skip |
Install
One command
bash {baseDir}/install.sh
Deploys three components:
boot-resume-check.sh→~/.openclaw/workspace/scripts/boot-resume.conf→ systemd drop-in (triggers script on every gateway start)boot-resume-wake.service→ systemd user service (triggers script on system wake from sleep/suspend)
Manual
cp {baseDir}/scripts/boot-resume-check.sh ~/.openclaw/workspace/scripts/
chmod +x ~/.openclaw/workspace/scripts/boot-resume-check.sh
mkdir -p ~/.config/systemd/user/openclaw-gateway.service.d
cp {baseDir}/templates/boot-resume.conf ~/.config/systemd/user/openclaw-gateway.service.d/
cp {baseDir}/templates/boot-resume-wake.service ~/.config/systemd/user/
systemctl --user daemon-reload
systemctl --user enable boot-resume-wake.service
Verify
systemctl --user restart openclaw-gateway
sleep 20
cat /tmp/openclaw/boot-resume.log
Expected output:
[boot-resume] now=... cut=... (20min window)
[boot-resume] scanning agent: main
[boot-resume] candidates: 0 (agent=main)
[boot-resume] done
Test
- Send a message that triggers a multi-step task (web search, code analysis, etc.)
- Wait for the agent to start processing (tool calls in flight)
systemctl --user restart openclaw-gateway- Agent resumes automatically within ~35 seconds
Slash Command
When invoked as /boot-resume, run the script with --no-wait to skip the startup delay:
bash {baseDir}/scripts/boot-resume-check.sh --no-wait
Report results to the user: which sessions were resumed, or that none were found.
Configuration
| Variable | Default | Description |
|---|---|---|
WINDOW_MINUTES | 20 | How far back to scan for interrupted sessions |
DELAY | 20s | Delay before injecting the resume event |
Edit at the top of scripts/boot-resume-check.sh.
Features
- Dual trigger — covers both gateway restart (ExecStartPost) and system sleep/wake (systemd sleep.target)
- Multi-agent support — scans all agents under
~/.openclaw/agents/, not justmain - Smart filtering — skips system, heartbeat, cron, and subagent sessions automatically
- Deduplication — respects
restart-resume.jsonto avoid double-resuming planned restarts - Log rotation — auto-truncates log at 1000 lines
- Error visibility — Python and cron errors are logged, not swallowed
- Unique job names — timestamp-based to prevent conflicts on rapid restarts
Comparison
| Approach | Pre-save required | Survives SIGKILL | LLM-free |
|---|---|---|---|
| Checkpoint / snapshot files | Yes | No | No |
| Pre-restart state dump | Yes | No | No |
| Session history replay | Yes | Partial | No |
| Post-hoc JSONL detection (this skill) | No | Yes | Yes |
Logs
Output: /tmp/openclaw/boot-resume.log
Each run logs: timestamp, scan window, candidate count, per-session status, and whether a resume job was armed.
Limitations
- 20-minute scan window (configurable) — sessions idle longer than this are not resumed
- Resume prompt is generic — the agent relies on session context for continuity
- Telegram/Discord message queues already handle unprocessed incoming messages — this skill targets mid-execution interruptions
- Requires systemd (Linux); macOS users need manual launchd setup
Uninstall
rm ~/.config/systemd/user/openclaw-gateway.service.d/boot-resume.conf
systemctl --user disable boot-resume-wake.service 2>/dev/null
rm ~/.config/systemd/user/boot-resume-wake.service
systemctl --user daemon-reload
rm ~/.openclaw/workspace/scripts/boot-resume-check.sh
rm -rf ~/.openclaw/workspace/skills/boot-resume
相关 Skills
面试体系设计
by alirezarezvani
按岗位、级别和团队设计面试流程,生成能力矩阵、题库与评分标准,分析面试官偏差并校准招聘门槛,适合搭建或优化企业招聘体系。
✎ 团队招人没章法时,用它快速搭建岗位化面试流程、题库与评分标准,还能兼顾校准面试偏差,招聘更稳更准。
期权交易
by binance-skills-hub
Binance Derivatives-trading-options request using the Binance API. Authentication requires API key and secret key. Supports testnet and mainnet.
A股交易助手
by alvisdunlop
A股股票智能交易助手,专服务中国大陆股票市场。当用户询问A股股票行情、个股分析、大盘情绪、热点板块、交易策略、价格预警、涨跌幅、成交量、技术面或基本面分析时触发。只处理沪深A股(代码�?/00/30/68开头),自动忽略港股和美股。所有数据实时从东方财富、新浪财经、同花顺、雪球抓取。Use when: user asks about Chinese A-share stocks, 股票行情, 个股分析, 大盘分析, 板块热点, 买卖�? 止盈止损, 仓位建议, or any A-share trading-related query.
相关 MCP 服务
by boosted-chat
Flight search & booking for AI agents. 400+ airlines, $20-50 cheaper than OTAs.
by jjlabsio
检索韩国市场公司的披露文件与财务报表,并获取股票概况等关键信息。
✎ 想研究韩股公司时,它能一站式拉取披露、财报和股票概况,省去跨站查资料的麻烦,对跨境投研尤其省时。
by jjlabsio
Search company disclosures and financial statements from the Korean market. Retrieve stock profiles, market classifications, and historical trading data across major exchanges. Accelerate equity research with accurate, date-specific insights for Korean securities.
✎ 做韩国股研时,用它能一站查公司披露、财报和历史行情,按日期精确追溯关键信息,比手动翻交易所高效太多。