Purpose

Monitors LLM token spend and quota usage to prevent budget overages. This was implemented as a proactive safeguard following the 2026-04-14 overage audit to detect token-bleed from parallel script execution. Reads from the tool_calls Supabase table (CHOKEPOINT-1) and the Portkey proxy.

Schedule

OnUnitActiveSec=300s — Runs every 5 minutes after the last activation, with a randomized jitter of up to 60 seconds to prevent thundering herd issues.

Service

Runs cost-monitor.service which executes the Node.js script located at /home/opsadmin/.openclaw/workspace/scripts/cost-monitor.js.

Resource cap: MemoryMax=256M to keep the monitor itself lightweight and outside VPS pressure.

Failure behavior

The service is configured as a oneshot. Failures are logged via systemd journal. When thresholds are crossed or a quota violation is detected, the script triggers an alert to the #ops Discord channel.

Health signal

Verify execution via:

  • systemctl --user status cost-monitor.timer
  • journalctl --user -u cost-monitor.service
  • Check for recent cost alerts or budget summaries in Discord #ops.