Automated failure detection, diagnosis, and recovery for OpenClaw agents. The watchdog that keeps your agent running.
bash
# Full health check — scan all systems, diagnose issues, suggest fixes
python3 scripts/self-healing-agent.py check
# Auto-heal — detect and fix what it can automatically
python3 scripts/self-healing-agent.py heal
# Monitor mode — run continuously, fix issues as they appear
python3 scripts/self-healing-agent.py monitor --interval 300
# Check specific subsystem
python3 scripts/self-healing-agent.py check --target cron
python3 scripts/self-healing-agent.py check --target memory
python3 scripts/self-healing-agent.py check --target config
python3 scripts/self-healing-agent.py check --target sessions
check — Health Check#Runs diagnostic suite:
Options: --target <subsystem> to check one area, --json for machine output.
heal — Auto-Repair#For each detected issue, applies the safest fix:
Options: --dry-run to preview, --aggressive for riskier fixes.
monitor — Continuous Watchdog#Runs in a loop, checking health every N seconds:
memory/self-healing-log.jsonOptions: --interval <seconds> (default: 300), --max-heals <n> per cycle.
report — Health Report#Generates a markdown health report covering:
SubsystemChecksAuto-HealsCronFailed runs, timeouts, consecutive errorsRestart jobs, clear error stateMemoryFile sizes >1MB, growth rate, duplicatesArchive old files, compactConfigJSON validity, required fields, deprecated keysFix syntax, add defaultsSessionsZombie processes, bloated contextsKill zombies, archive contextsSkillsSyntax errors, missing deps, broken importsLog issue, skip broken skillNetworkAPI endpoints, DNS, SSL certsRetry with backoff, switch endpoints
All actions are logged to memory/self-healing-log.json:
json
{
"timestamp": "2026-04-05T06:00:00Z",
"issue": "cron job 'daily-intel' failed 3 consecutive times",
"diagnosis": "Script timeout — API rate limit hit",
"action": "Reset error count, added 30s backoff, restarted",
"result": "success",
"mttr_seconds": 12
}