How to Build a 24/7 AI Coding Agent

Complete Deployment Guide · 2026  ·  2026.07.15  ·  ~12 min  ·  Architecture diagram · 7-step checklist · FAQ

Code terminal and server racks symbolizing a 24/7 AI Coding Agent deployment environment

In one sentence: if you want an AI Coding Agent that can pick up issues overnight, edit code, and open PRs in 2026, many teams get step one wrong — they think installing Cursor or buying an API key is enough. What actually keeps an autonomous coding agent running is an always-on execution plane, task scheduling, and objective verification. The sections below follow architecture layers, deployment topology, minimum viable stack, and production hardening — a complete deployment guide you can run through step by step.

24/7
Target uptime
5
Core architecture layers
24GB
Recommended RAM (Agent + Runner)

Separate two layers before you deploy

AI Coding Agent is the program that autonomously reads context, edits code, and runs commands (OpenHands, Claude Code, Cursor Background Agent). It runs on an AI coding agent server — a 24/7 online execution and scheduling node. Without an always-on node, the Agent is just a script that stops when you close your laptop; without an Agent, the node is an idle Mac mini.

1. What is a 24/7 AI Coding Agent?

Unlike Copilot or Cursor Tab inside your IDE, a 24/7 AI Coding Agent solves a different problem: when you are not around, who is allowed to change the repo, run commands, and collect verification signals in a real environment?

A working deployment usually includes four capabilities — miss any one and you do not have a true 24/7 autonomous coding agent:

  • Always-on execution environment (L0) — a macOS or Linux node with stable power and network that can run git, npm, and xcodebuild.
  • Coding Agent process (L3/L5) — pairing layer (Claude Code) or autonomous layer (OpenHands) that reads context and writes Diffs.
  • Task entry and queue — GitHub issue labels, webhooks, cron schedules, Slack commands, etc., that feed work to the Agent.
  • Objective verification (L1) — a GitHub Runner or local test scripts that produce Facts the org can trust, not just the Agent saying “done.”

In short: the execution node is foundation and utilities; the Agent is the worker; the Runner is QA. Many teams fail because they bought a model API, ran a script on a MacBook, and expected a 24/7 AI Coding Agent — lid close, sleep, memory contention, and changing egress IP all kill jobs at 3 a.m.

2. One diagram: from task entry to mergeable PR

The causal chain below summarizes a typical autonomous coding agent pipeline. The left column is the main chain; the right contrasts what makes it work vs what breaks it.

24/7 AI Coding Agent main chain

Task entry Issue label · Webhook · Cron
Execution node (L0) AI coding agent server · 24/7 online
AI Coding Agent (L5) Plan → Execute → Observe → Debug
Diff + PR Branch push · auto-open Pull Request
GitHub Runner (L1) Tests green · build passes · mergeable

What you need to succeed

  • Node 24/7 with stable power
  • Agent token separated from git permissions
  • MCP read-only by default
  • Branch protection + required CI
  • Task timeout and concurrency caps

Typical failures

  • Laptop lid closes, job dies
  • No Runner — nobody dares merge the PR
  • Agent writes to production DB
  • Large repo, no CodeGraph — blind refactor
  • Concurrent tasks swap 16GB machine to death
Left: main chain from task entry to CI green for a 24/7 AI Coding Agent; right: production requirements and common failure modes in 2026.

3. Five-layer component breakdown

Aligned with AI Agent infrastructure layers — you do not need every layer on day one, but you should know what breaks when one is missing:

Layer Role in deployment Typical choice Required for 24/7?
L0 Execution 24/7 runtime base for the Agent Cloud Mac / Mac mini ✅ Required
L1 Verification Objective signal for mergeable PRs GitHub self-hosted Runner Required for teams
L3 Pair coding Daytime human-in-loop, complex changes Claude Code / Cursor Agent Optional (stack with L5)
L4 Context Large-repo navigation, issues, APIs MCP (GitHub / CodeGraph) Strongly recommended for large repos
L5 Autonomous workflow Core of autonomous coding agent OpenHands, Cursor Background Agent Required for unattended operation

Claude Code produces Diff, Runner produces Fact, OpenHands produces Workflow — three lines to remember when deploying an AI Coding Agent. For overnight lint-issue cleanup, L0 + L5 + L1 is often enough; add L3 for daytime architecture pairing. When stacking on one machine, watch memory scheduling (see parallel memory scheduling).

4. Deployment topology: local Mac mini vs Cloud Mac

The execution node for a 24/7 AI Coding Agent can be physical hardware, a VM, or a cloud rental — choose by uptime SLA, not brand:

Dimension Office Mac mini Cloud Mac (datacenter)
24/7 reliability Depends on office power and network Datacenter power and backbone egress
Egress IP Home broadband may change Often dedicated IPv4 — stable webhook allowlists
Co-locate with Runner Yes — check if 16GB is enough Common pattern — one job, one workspace
Best for Spare Mac on hand, can manage hardware No hardware purchase, fast autonomous agent go-live
iOS / Xcode builds Real macOS — works Real macOS — works (not a simulator substitute)

Pure backend repos (Go / Node / Python) can theoretically run an AI Coding Agent on Linux VPS, but once the workflow hits xcodebuild, swift test, or Apple signing, execution must return to macOS. That is why most 2026 deployment guides default to Mac — not sentiment, ABI boundaries.

5. Minimum viable stack (MVP): run one overnight task first

Do not start with Kubernetes + a vector DB. Below is the fastest path we have seen to issue → PR → CI green:

  • Node: M4 Mac mini 16GB or equivalent Cloud Mac; 24GB recommended if stacking OpenHands + Runner.
  • Agent: OpenHands (autonomous) or Claude Code + a simple shell wrapper (semi-automatic).
  • Model: Claude / GPT API; local Ollama optional, not required for 24/7.
  • Entry: GitHub webhook triggered by agent issue label.
  • Verification: self-hosted Runner on the same machine, runs-on: [self-hosted, macOS].
  • Context: read-only GitHub MCP + AGENTS.md in the repo documenting red lines.

How to pick the first task

Start with lint cleanup, minor dependency bumps, or adding unit tests — clear input, verifiable behavior, easy rollback. Do not make the first autonomous coding agent task a large untested refactor.

6. 7-step deployment checklist

Execute in order; each step is independently verifiable — the core hands-on section of this guide, so you do not discover the Runner was never registered after installing everything.

Step 1 — Prepare the L0 node. Ensure SSH, clock sync, and disk ≥ 256GB (Xcode + multiple workspaces eat space). Cloud Mac users: finish instance init and confirm static IP.

Step 2 — Create a restricted git identity. Stand up a dedicated GitHub App or deploy key for the Agent: write only to feature branches, no main write by default. Production secrets and npm tokens do not belong in Agent environment variables.

Step 3 — Install the coding Agent. OpenHands example (Docker or native per official docs):

OpenHands · example startup
# On the L0 node, clone OpenHands and configure LLM API key per official docs
git clone https://github.com/OpenHands/OpenHands.git
cd OpenHands
# Configure .env: MODEL, GITHUB_TOKEN (read-only issues), WORKSPACE_BASE
make run

Step 4 — Connect MCP (optional but recommended). For large repos, add CodeGraph MCP so the autonomous agent can see dependency relationships before editing.

Step 5 — Register GitHub Runner. Register on the same machine as the Agent, labels like macos-agent. Workflow snippet:

# .github/workflows/agent-verify.yml
name: Agent PR Verify
on:
  pull_request:
    types: [opened, synchronize]
jobs:
  verify:
    runs-on: [self-hosted, macOS, agent]
    steps:
      - uses: actions/checkout@v4
      - run: swift test   # or npm test / go test

Step 6 — Configure task entry. Point a GitHub webhook to a lightweight HTTP service on the server, or use OpenHands built-in integration; filter with label agent-ready so every comment does not trigger a run.

Step 7 — Monitor and circuit-break. Log token usage, duration, and files changed per task; auto-kill on timeout (e.g. 90 minutes); concurrency 1 until stable, then try 2.

7. Production hardening: don’t let the Agent break main at 3 a.m.

The biggest risk with an autonomous coding agent is not “the model is dumb” — it is excessive permissions + no human review. Before go-live, at minimum:

Red line Practice
Branch protection main blocks direct push; Agent may only open PRs
Required CI Required checks include Runner job — no merge without green
Secret isolation Production DB, App Store Connect API not in Agent environment
MCP minimal exposure Read-only by default; writes need human gate (see MCP permissions)
Audit logs Retain every Agent shell step, diff, and model request ID
Resource limits cgroup / ulimit on child processes — prevent fork bombs

“Auto-merge” is the next phase

The first goal of a 24/7 AI Coding Agent should be stable, reviewable PRs, not automatic merge. Human or policy-Agent review before merge is far cheaper than auto-merging a backdoored PR at 3 a.m.

8. Cost and sizing estimates

A 24/7 AI Coding Agent bill usually splits three ways:

  • Compute node: Mac mini one-time + power; Cloud Mac daily/weekly subscription (compare rent vs buy).
  • Model API: autonomous agents loop many rounds — one task often uses 5–20× the tokens of pairing; set per-task budget caps.
  • Human ops: early on, a few hours per week on logs, prompts, and stuck tasks; do not assume zero maintenance after install.

Sizing rule of thumb: OpenHands + medium repo alone, 16GB runs but swaps easily; with Agent, Runner, and optional Ollama on one machine, 24GB is the saner starting point (see 16GB vs 24GB).

9. Common failure modes

  • Treating pairing tools as autonomous agents — Claude Code stops when the session ends unless you wrap it in a scheduler.
  • No Fact layer — Agent claims tests passed; Runner never ran (why self-hosted Runner is worth it).
  • Too much concurrency — two autonomous tasks on 16GB swaps the machine into oblivion.
  • Bare context — million-line monorepo without CodeGraph is blind refactoring.
  • Ignoring timezone and alerts — failed tasks with no notification; half-baked PRs waiting until morning.

10. FAQ

Q: Does Cursor Background Agent count as a 24/7 AI Coding Agent?
A: Cursor provides hosted execution — you do not need a 24/7 local machine. Repo permissions, CI verification, and compliance boundaries are still yours to configure. Self-hosted deployment means data and execution fully on nodes you control.

Q: Can I use GitHub Copilot Workspace / OpenAI Codex?
A: Yes as L3/L5 model and UI layers; deployment is still execution environment + scheduling + verification. After Codex merged into ChatGPT it leans more pairing — unattended operation still needs workflow wrapping (see Codex merge guide).

Q: Is Docker OpenHands on Linux enough?
A: For pure web/backend, yes; any Apple toolchain step must run on a macOS node. Mixed teams often run scheduling on Linux and builds + Agent on macOS Cloud Mac.

Q: As a solo maintainer, do I need 24/7?
A: If you only pair-code during the day, no. 24/7 AI Coding Agent fits issue backlogs, cross-timezone teams, or moving tech-debt cleanup to overnight machine time.

Q: Compared to commercial autonomous agents like Devin / Factory?
A: Commercial products sell bundled Agent + execution + UI; self-deployed means auditable, customizable permissions, alignment with your existing Runner/MCP stack. Many teams end up with “commercial Agent for exploration, self-hosted node for production tasks.”

ZavCloud Cloud Mac

Deploy your AI Coding Agent on always-on macOS

Datacenter-grade Mac mini M4 dedicated instances — ideal for stacking OpenHands, Claude Code, and GitHub Runner as the execution base for a 24/7 AI Coding Agent.

View Cloud Mac plans
Cloud Mac 24/7 Agent deployment base