Run a 24/7 AI agent on free cloud

The operational half nobody writes about: watchdogs, memory tuning, browser reapers and the real free-tier limits — measured on a system that is actually running non-stop.

2 OCPUfree ARM instance, non-stop
12 GBRAM ceiling — planned around
5.8 GBzram compressed swap (zstd)
$0–5monthly infrastructure cost

Why this exists

Every "run your own AI agent" guide stops at "it works on my laptop." The hard part starts after: the agent dies at 3 AM, a bot token returns conflicts, memory fills until the OOM killer picks a victim, and the free tier refuses to scale. This project documents what actually breaks on a small box — and ships the scripts that keep it alive.

What you get

Resource watchdog

RAM, swap, disk and load checks. Silent when healthy, loud when broken, with a per-alert cooldown.

Headless-browser reaper

Reclaims leaked browser trees — but only when no live client is attached. Dry-run by default.

Compressed swap

Idempotent zram setup: 50% of RAM with zstd at priority 100. Pressure insurance without disk thrash.

Channel patterns

One token per agent, webhook vs polling, 409 diagnostics, health checks for chat bridges.

Restore drills

Backups you never restore are not backups. Weekly verification into a scratch path.

CI that enforces it

Shell syntax, shellcheck, Python compile and a docs-link gate run on every push.

Quickstart

git clone https://github.com/Amz34/selfhosted-agent-stack.git
cd selfhosted-agent-stack

sudo bash scripts/zram_setup.sh 6144     # compressed swap
bash scripts/resource_watchdog.sh        # silent unless unhealthy
bash scripts/chrome_reaper.sh --dry-run  # reclaim leaked browsers

Lessons that cost real uptime

Unmanaged memory is the limit, not RAM size. One leaked browser session tree held 3.0 GB; reaping stale trees dropped usage to 1.9 GB with no visible effect.
Free quotas are hard ceilings. The ARM allowance on this tenancy was fully consumed — a resize request is rejected outright. Measure before you design.
One bot token, one poller. Sharing a token across processes causes conflicts and a bot that silently stops answering.
A watchdog that says "all good" daily gets deleted. Write nothing when healthy; speak only when something is wrong.

The honest cost

ItemFree allowanceUsed
Compute1× ARM instance, 2 OCPU / 12 GB1 instance, 24/7
Boot volume200 GB totalat ceiling
Outbound transfer10 TB / montha few GB
Monthly bill—$0–5 (model API only)