Autonomous DevOps agent for diagnosing and fixing OpenClaw Gateway issues.
Uses an AI-powered REPL loop (observe β think β act β verify) with function calling to autonomously identify and resolve problems.
- REPL Loop β AI agent iteratively diagnoses and fixes issues (up to 20 iterations)
- 12 Built-in Tools β gateway status, logs, systemd journal, resource monitoring, channel probes, shell commands, doc fetching, process management, Telegram notifications
- 5 Modes β auto, check (read-only), problem-specific, interactive REPL, watchdog
- Safety First β dangerous commands blocked, config never modified without approval, diagnoses before acting
- Telegram Notifications β sends alerts when issues are found/fixed
- OpenClaw Skill β installable as a native OpenClaw skill
- Python 3.10+
- OpenClaw CLI (
openclaw) in PATH - OpenAI API key
pip install openai
# Option 1: Run directly
python3 scripts/openclaw-doctor.py --check
# Option 2: Install as OpenClaw skill
openclaw skills install openclaw-doctor.skillexport OPENAI_API_KEY="sk-..."# Full auto-diagnosis + fix
python3 scripts/openclaw-doctor.py
# Check only (read-only, no changes)
python3 scripts/openclaw-doctor.py --check
# Fix a specific problem
python3 scripts/openclaw-doctor.py --problem "Telegram Π½Π΅ Π΄ΠΎΡΡΠ°Π²Π»ΡΠ΅Ρ ΡΠΎΠΎΠ±ΡΠ΅Π½ΠΈΡ"
# Interactive REPL
python3 scripts/openclaw-doctor.py --interactive
# Watchdog mode (continuous monitoring + auto-fix)
python3 scripts/openclaw-doctor.py --watch
# Use a different model
python3 scripts/openclaw-doctor.py --model gpt-4.1βββββββββββββββββββββββββββββββββββββββββββ
β OpenClaw Doctor β
β β
β βββββββββββ βββββββββ βββββββββ β
β β OBSERVE ββββββ THINK ββββββ ACT β β
β β (tools) β β (LLM) β β(tools)β β
β ββββββ²βββββ βββββββββ βββββ¬ββββ β
β β β β
β β ββββββββββ β β
β ββββββ VERIFY βββββββββββββ β
β β(tools) β β
β ββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββ
The AI agent (GPT-5.2 by default) decides which tools to call at each step. It can:
- Check gateway status and RPC probe
- Read and filter logs by severity
- Inspect system resources (RAM, disk, CPU)
- Probe channel connectivity (Telegram, etc.)
- Read systemd journal for crash details
- Run diagnostic shell commands
- Fetch OpenClaw documentation for troubleshooting
- Kill zombie processes (Chrome/Playwright)
- Restart the gateway (with verification)
- Send Telegram notifications
| Tool | Description | Mutating |
|---|---|---|
check_gateway |
Gateway status + RPC probe | No |
get_logs |
Gateway logs with level filter | No |
run_doctor |
openclaw doctor config check |
No |
check_resources |
RAM, disk, CPU, top processes, ports | No |
check_channels |
Channel probe (Telegram etc.) | No |
systemd_journal |
systemd unit journal | No |
read_config |
Read openclaw.json | No |
fetch_docs |
Fetch docs.openclaw.ai page | No |
run_command |
Shell command (dangerous blocked) | Maybe |
restart_gateway |
systemctl restart + verify | Yes |
kill_zombie_processes |
Kill hung processes by pattern | Yes |
notify_telegram |
Send Telegram notification | No |
| Environment Variable | Default | Description |
|---|---|---|
OPENAI_API_KEY |
β | OpenAI API key (required) |
DOCTOR_MODEL |
gpt-5.2 |
AI model for diagnosis |
DOCTOR_MAX_ITERATIONS |
20 |
Max REPL loop iterations |
DOCTOR_WATCH_INTERVAL |
30 |
Watchdog check interval (seconds) |
TG_BOT_TOKEN |
β | Telegram bot token for notifications |
TG_CHAT_ID |
β | Telegram chat ID for notifications |
| Issue | Detection | Auto-Fix |
|---|---|---|
| Zombie Chrome processes | ps aux | grep chrome |
Kill + restart |
| OOM kill | dmesg, journal |
Clean cache + restart |
| Port conflict (EADDRINUSE) | ss -tlnp |
Kill conflicting process |
| Disk full | df -h |
Clean old logs |
| Channel disconnect | openclaw channels status |
Probe + report |
| Config errors after upgrade | openclaw doctor |
Report (no auto-modify) |
openclaw-doctor/
βββ README.md
βββ SKILL.md # OpenClaw skill metadata
βββ scripts/
β βββ openclaw-doctor.py # Main agent
βββ references/
βββ common-issues.md # Known issues reference
This project is also an OpenClaw skill. When installed, OpenClaw will automatically use it when you ask about gateway diagnostics or health checks.
# Install the skill
openclaw skills install openclaw-doctor.skill
# Then just ask your agent:
# "ΠΏΡΠΎΠ²Π΅ΡΡ Π·Π΄ΠΎΡΠΎΠ²ΡΠ΅ gateway"
# "ΠΏΠΎΡΠ΅ΠΌΡ Telegram Π½Π΅ ΡΠ°Π±ΠΎΡΠ°Π΅Ρ"
# "ΠΏΠΎΡΠΈΡΡΠΈ Π·ΠΎΠΌΠ±ΠΈ-ΠΏΡΠΎΡΠ΅ΡΡΡ"MIT
Built for OpenClaw β the open-source AI gateway.