check-context
Accurately check current context window and token usage. Use when the user asks about context usage, token consumption, or when…
Guardian service that monitors the active runtime agent's state and automatically restarts it if stopped. Use when checking agent liveness state or understanding the auto-restart mechanism.
$ npx -y skills add zylos-ai/zylos-core --skill activity-monitor --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/activity-monitorContext preview
The summary Claude sees to decide when to auto-load this skill.
Guardian service that monitors the active runtime agent's state and automatically restarts it if stopped. Use when checking agent liveness state or understanding the auto-restart mechanism.
name: activity-monitor description: Guardian service that monitors the active runtime agent's state and automatically restarts it if stopped. Use when checking agent liveness state or understanding the auto-restart mechanism. user-invocable: false
PM2 guardian service that monitors the active runtime agent's (Claude or Codex) activity state and ensures it's always running.
This is a **PM2 service** (not directly invoked by Claude). It runs continuously in the background.
1. **Activity Monitoring**: Tracks the agent's busy/idle state every second 2. **Status File**: Writes `~/zylos/activity-monitor/agent-status.json` with current state (busy/idle, idle_seconds, health) 3. **Guardian Mode**: Automatically restarts the agent if it stops or crashes 4. **Maintenance Awareness**: Waits for restart/upgrade scripts to complete before starting the agent 5. **Recovery Liveness Detection**: Sends C4 heartbeat probes during recovery and after restarts; healthy sessions have no periodic primary heartbeat 6. **Health Check**: Periodically enqueues system health checks (PM2, disk, memory) via the C4 control queue 7. **Daily Upgrade**: Enqueues a Claude Code upgrade via the C4 control queue at 5:00 AM local time daily (disabled by default; enable with `zylos config set daily_upgrade_enabled true`) 8. **Context Monitoring**: Receives context usage data after every turn; triggers early memory sync and new-session handoff at thresholds read from `config.json` (`new_session_threshold` for Claude, `codex_new_session_threshold` for Codex), each with a built-in runtime fallback if the key is unset
{
"state": "idle",
"last_activity": 1738675200,
"last_check": 1738675210,
"last_check_human": "2026-02-04 20:30:10",
"idle_seconds": 5,
"inactive_seconds": 10,
"source": "conv_file",
"health": "ok"
}# Start pm2 start ~/zylos/.claude/skills/activity-monitor/scripts/activity-monitor.js --name activity-monitor # Restart pm2 restart activity-monitor # View logs pm2 logs activity-monitor # Check status pm2 list
1. **Monitor Loop** (every 1s):
2. **Guardian Logic**:
3. **Activity Detection**:
The health engine uses the C4 control queue to verify runtime responsiveness during recovery. Healthy sessions do not receive periodic `primary` probes, and there is no heartbeat enable/interval setting. The internal maintenance timer still processes pending probe results and recovery scheduling.
| Phase | Trigger | On Success | On Failure | |-------|---------|------------|------------| | `recovery` | Unavailable/recovering maintenance retry or user-message recovery | Return to `ok` | Apply existing rate-limit detection or recovery handling | | `post_restart` | Restart notification or process-running signal after its grace period | Return to `ok` | Apply existing recovery handling | | `down-check` | Legacy `down` state retry interval | Return to `ok` | Stay `down` and retry later |
Retries in unavailable/recovering use exponential backoff (1m, 5m, 25m, then 60m). Rate-limit cooldown expiry only clears the wait; a later recovery trigger verifies responsiveness. Failed or expired pending probes still run their existing failure handling, including API-error fast scanning while waiting.
Recovery and post-restart probes require end-to-end acknowledgement. The dispatcher retains confirmed-active busy auto-ack for other heartbeat phases; idle heartbeat auto-ack has been removed.
See [Recovery and maintenance behavior](references/health-engine.md) for timing and compatibility details.
When health is not `ok`, C4 intake still records incoming messages as delivered. The MessageRouter returns an immediate status response for the current message when replies are enabled; `--no-reply` messages are accepted silently. If the router IPC is unavailable, `c4-receive.js` falls back to the status file and follows the same delivered/current-message behavior.
The activity monitor periodically enqueues system health checks via the C4 control queue.
The health check control message instructs Claude to: 1. Check PM2 services via the health-check skill's sanitized PM2 snapshot helper 2. Check disk space via `df -h`
Accurately check current context window and token usage. Use when the user asks about context usage, token consumption, or when…
C4 communication bridge — central gateway for ALL external communication (Telegram, Lark, etc.). Use when replying to users via…
Guidelines for managing zylos components via CLI and C4 channels. Use when installing, upgrading, or uninstalling components, or…
Guide for creating effective skills. Use when asked to create a new skill (or update an existing skill) that extends Claude's…
System health check dispatched by the activity monitor via Control queue. Checks PM2 services, disk space, and memory usage. Use…