Guardian is a lightweight Node.js process that runs alongside your agent. It has no AI, uses zero tokens, and has one job: keep the agent online and let you manage it from chat.
What it watches
Every 30 seconds, Guardian:
- Runs
tmux capture-pane -pagainst the agent's session - Scans the captured output for error patterns (
API Error:,Overloaded,Could not process, etc.) - Looks for incoming messages tagged
← discord,← telegram, etc. to know the agent is receiving traffic - Checks for "working" indicators (Baked, Crunching, tool-use markers) to distinguish stuck from idle
If the session is dead, it restarts. If errors are piling up and no work is happening, it flags the agent as stuck and restarts after one additional failed check.
Restart policy
- Max 3 restarts per 30 minutes. Past that, Guardian stops trying and pages you via your channel.
- Every restart is logged to
~/workspace/memory/guardian.logand state written to/tmp/sento-guardian-<agent>.json. - On clean restart, Guardian sends a ✅ notification: "agent is back online."
Channel paging
Guardian detects which channel your agent uses (Discord, Telegram, or Slack), reads the bot token from the plugin's .env file, and uses the appropriate API to message you directly:
- Discord: webhook if configured, otherwise Bot API to the monitor channel
- Telegram:
sendMessageto your monitor chat ID - Slack:
chat.postMessageto your monitor channel
Interactive commands from chat
Guardian also polls the monitor channel for user messages, so you can manage the agent without SSH:
restart— Guardian stops and restarts the agent, resets restart countlogs— dumps the last 15 lines of tmux output back to the channelstatus— prints health summary (alive / stuck / restart count / state)
Why no AI
Because anything with AI can fail. Guardian's whole point is to be the thing that's still alive when the agent isn't. Node.js, regex, tmux capture-pane. That's the whole stack.
Files to know
src/templates/guardian.jsin the Sentō repo — the Guardian template (rendered per-agent)~/workspace/memory/guardian.log— Guardian's log output/tmp/sento-guardian-<agent>.json— persistent state (restart list, status flag)~/.claude/channels/<channel>/.env— read by Guardian at startup to pick up the token
How it starts and persists
- On install:
sento initstarts Guardian vianohup node guardian.js &and drops a@rebootcron line so it comes back on restart. - On reboot: the cron entry re-runs the start script, Guardian launches, agent launches.
- No systemd, no launchd by default — nohup + tmux + cron is the simplest reliable pattern across distros and containers.