Install
openclaw skills install hz-error-guardMonitors, classifies, intercepts errors in real-time, enforces auto-retry and circuit breaking, and ensures graceful recovery and prevention.
openclaw skills install hz-error-guard实时监控错误、自动拦截、预防问题
def detect_error_pattern(errors):
# 检测重复错误
if len(set(errors[-5:])) == 1:
return "repeating_error"
# 检测错误累积
if error_rate() > threshold:
return "error_accumulation"
# 检测级联错误
if has_cascade(errors):
return "cascade_failure"
return "isolated_error"
IF 同一错误出现 3 次 THEN
记录并警告
暂停相关操作
进入熔断模式
END
IF 错误率 > 10% THEN
降低操作频率
增加重试延迟
通知管理员
END
IF 致命错误 THEN
保存完整上下文
执行优雅关闭
触发重启
END
# 执行前验证
async def pre_execution_check(command):
checks = {
"auth": verify_token(),
"resources": check_resources(),
"rate_limit": check_rate_limit(),
"dependencies": check_services()
}
if not all(checks.values()):
raise PreExecutionError("验证失败")
return True
async def error_recovery(error):
strategies = {
"auth_error": refresh_and_retry,
"timeout_error": retry_with_backoff,
"rate_limit_error": wait_and_retry,
"resource_error": free_resources_and_retry
}
strategy = strategies.get(error.type, default_retry)
return await strategy(error)
🦞 辉仔 - 错误终结者