Restart Guard技能使用说明
2026-04-01
新闻来源:网淘吧
围观:14
电脑广告
手机广告
重启守护
目标
安全重启网关,保留上下文,并保证重启后可主动回报到用户会话。
触发条件
当任务涉及 OpenClaw 网关重启、看门狗恢复、重启后回报时使用。
自然语言触发(必须自动执行,不让用户手工跑脚本):
"可以重启了"

"现在重启吧"
- "restart now"
- "go ahead and restart"
- 前置条件
- openclaw
CLI 可用。
- 重启配置存在(
- “现在重启吧”
- “restart now”
- “go ahead and restart”
Required Preconditions / 前置条件
openclawCLI is available.- Restart config exists (
config.example.yaml或config/restart-guard.yaml.example(已复制到运行时路径)。 - Agent 可以执行 shell 命令。
openclawCLI 可用。- 重启配置文件存在(从示例拷贝到运行路径)。
- agent 具备执行命令能力。
Workflow / 标准流程
0) Default behavior / 默认行为
当用户表达重启意图但未指定渠道详情时:
- 通过以下脚本自动运行完整流程:
scripts/auto_restart.py。 - 默认
--notify-mode origin。 - 自动推断原始会话密钥(环境/上下文/会话),无需用户输入。
- 自动发现外部渠道并持久化
effective_notify_plan。 - 在触发前,主动向源会话预告灾难通知路由与渠道。
- 重启事件到达后,由网络向用户汇总结果。
当用户仅表达重启意图且未指定渠道细节时:
- 使用
scripts/auto_restart.py自动执行全流程。 - 默认
--notify-mode origin。 - 自动推断源会话 key(env/context/sessions),无需用户补参数。
- 自动发现外部渠道并写入
effective_notify_plan。 - 触发前先在源会话预告灾难通知路由与渠道。
- 收到重启事件后,由 net 向用户汇总结果。
1) 发现渠道与模式 / 发现渠道与模式(可选)
python3 <skill-dir>/scripts/discover_channels.py --config <config-path> --json
询问用户:
- 通知模式(
源会话推荐,或选定、全部) - 若需要,选择渠道/目标
询问用户:
- 通知模式(推荐)
原始,可选已选择、全部) - 若需要,指定渠道与目标
2)写入现场
python3 <skill-dir>/scripts/write_context.py \
--config <config-path> \
--reason "config change" \
--verify 'openclaw health --json' 'ok' \
--resume "report restart result to user"
3)执行重启
推荐单命令入口:
python3 <skill-dir>/scripts/auto_restart.py \
--config <config-path> \
--reason "config change" \
--notify-mode origin
选择渠道模式:
python3 <skill-dir>/scripts/auto_restart.py \
--config <config-path> \
--reason "配置变更" \
--notify-mode origin
python3 <skill-dir>/scripts/restart.py \
--config <config-path> \
--reason "config change" \
--notify-mode origin \
--origin-session-key <session-key>
4)事后校验
python3 <skill-dir>/scripts/restart.py \
--config <config-path> \
--reason "config change" \
--notify-mode selected \
--channel telegram \
--target 726647436
契约
python3 <skill-dir>/scripts/postcheck.py --config <config-path>
事件契约:
- 重启保护结果.v1
必填字段: - 状态
、重启ID现场添加: - 重启ID
原始会话密钥origin_session_key通知模式通道选择有效通知方案状态时间戳诊断文件投递状态
- 可选事件字段:
严重性故障阶段错误代码投递尝试次数投递路由投递已穷尽诊断文件
注意事项
webui不再视为禁用通知;主路径是回发到发起会话。webui不再视为禁用通知;主路径是回发到发起会话。- 校验/诊断命令以严格非 shell 模式执行。
- 校验/诊断命令以严格非 shell 模式执行(包含管道等 shell 元字符会被拒绝)。
- 有关实现级别的复制详细信息,请参阅
ENHANCED_RESTART_IMPLEMENTATION_SPEC.md. - 若需按工程级标准复刻实现,请参考
ENHANCED_RESTART_IMPLEMENTATION_SPEC.md。 - Do not expose internal scripts/steps unless user explicitly asks for internals.
- 除非用户明确要求细节,否则不要向用户暴露内部脚本步骤。
- Guardian uses strict success invariant:
down_detected && start_attempted && up_healthy
- Guardian success requires strict invariant:
down_detected && start_attempted && up_healthy
Failure Handling / 故障处理
- On timeout/failure, guardian writes local diagnostics file (
restart-diagnostics-<restart_id>.md/json), sends concise summary, and retries delivery within budget. - 若超时或失败,guardian 会写本地诊断文件(
restart-diagnostics-<restart_id>.md/json),发送简要摘要,并在预算内重试送达。 - Fixed disaster route:
origin session -> agent:main:main -> all discovered external channels. - Fixed Disaster Routing:
Source Session -> agent:main:main -> All Discovered External Channels. - Guardian exits after successful delivery or budget exhaustion; no long-lived watchdog process after disaster handling.
- After disaster handling concludes (successful delivery or budget exhaustion), the guardian must exit without long-term residency.
文章底部电脑广告
手机广告位-内容正文底部


微信扫一扫,打赏作者吧~