Heartbeat
An autonomous work loop for AI coding agents: cheap deterministic gates, tight blast-radius envelopes, and predictions before actions.
An autonomous heartbeat loop for AI agent sessions. Wakes itself, inspects ground truth, advances one task per cycle within a strict blast-radius envelope, and queues irreversible actions to human review. The execution pillar of Stewardship Engineering.
The Problem
Unattended loops present two major hazards:
- Economic Runaway: Polling every minute with a full frontier reasoning model burns hundreds of dollars per day even when there is zero work to perform.
- Blast Radius Disasters: Without structural guardrails, an unattended agent with broad permissions can force-push branches, delete test fixtures, or touch production data while you sleep.
Key Mechanisms
1. Cost-Tiered Execution Gate
Always-on cannot mean always-expensive. Heartbeat implements a strict cost cascade:
- Cheap Gate: Every cycle begins with an instantaneous, deterministic local script (checking git status, lock files, and actionable cards). It makes zero LLM calls. More than 90% of ticks terminate here in under 200ms at virtually zero cost.
- Escalation: Only when a concrete, verified task is discovered does the loop invoke an agent model.
2. The Blast-Radius Envelope
Every action is categorized by reversibility:
- Reversible Actions: Branch creation, local test execution, technical research, draft authoring, and documentation run freely without human intervention.
- Irreversible Actions: Deployments, external communications, database migrations, and financial commitments are halted at the boundary and staged onto a review board for human sign-off.
3. Recovery and Durability
Heartbeat tracks cycle state as plain files in Git. If a host crashes, reboots, or loses internet connectivity, the loop resumes cleanly upon restart without duplicating work or losing transaction logs.
Open Source & Reading
- Repository: github.com/eprouveze/heartbeat (MIT)
- Architecture Context: Stewardship Engineering: How Agents Earn Autonomy