Lesson 871 of 2116
Heartbeat Budgets And Runaway Prevention
An autonomous soul without a budget is a credit-card-on-fire. Rate limits, max iterations, kill-switches, and cost caps are not optional — they're how heartbeats stay safe. Why heartbeats need budgets A reactive agent costs tokens when the user prompts.
Lesson map
What this lesson covers
Learning path
The main moves in order
- 1Why heartbeats need budgets
- 2rate limit
- 3max iterations
- 4cost cap
Concept cluster
Terms to connect while reading
Section 1
Why heartbeats need budgets
A reactive agent costs tokens when the user prompts. A heartbeat soul costs tokens every time it beats — even when it decides to do nothing. A bug, a recursive trigger, or a self-paced soul that picks 'wake me in 1 second' can drain a $200 monthly budget in an afternoon. Budgets are the line between an autonomous agent and a financial incident.
The four layers of safety
- 1Rate limit: the runtime caps how often a soul can beat (e.g. no more than once per 5 seconds, no matter what it asks for)
- 2Max iterations: the soul automatically stops after N beats unless explicitly extended — a watchdog that catches forgotten loops
- 3Cost cap: a token or dollar ceiling per soul, per day or per run — the runtime kills the soul when it's hit
- 4Kill switch: a one-command (or one-click) shutdown for any soul, ideally one that survives runtime restarts
All four layers in one block. Rate limits stop runaways; max_iterations stops forgotten loops; cost caps stop billing surprises; on_cap_hit decides what 'stop' means.
soul:
name: pr-reviewer
heartbeat:
type: event
on: [webhook: github.pull_request.opened]
budget:
rate_limit:
max_per_minute: 6
min_interval_seconds: 5
max_iterations: 500 # auto-stop after 500 beats
cost_cap:
tokens_per_day: 2000000
usd_per_day: 25
on_cap_hit: pause_and_notifyCircuit breakers — the smart layer
A circuit breaker watches the soul's behavior and trips when something looks wrong. Three patterns are worth setting up by default: error-rate breakers (pause if more than 50% of beats fail), no-op breakers (pause if 100 beats in a row produced zero useful action — the soul might be stuck), and divergence breakers (pause if the soul's tool calls suddenly look unlike its baseline). Breakers don't kill the soul — they pause it and notify a human.
Compare the options
| Failure mode | What you'd see | Which guard catches it |
|---|---|---|
| Self-paced loop picks tiny intervals | Token graph spikes, hundreds of beats per minute | Rate limit + min_interval |
| Misconfigured event trigger fires on every log line | Beats per second go vertical | Rate limit + debounce |
| Soul stuck retrying same failed tool | Same error every beat for an hour | Error-rate circuit breaker |
| Forgotten experiment soul running forever | Steady drip of cost over weeks | max_iterations + cost cap |
| Prompt injection redirects soul's tools | Tool calls suddenly outside baseline | Divergence breaker + audit log |
The kill switch you actually need
A good kill switch has three properties: it's fast (one command, no menus), it's authoritative (the runtime guarantees the soul stops, not 'tries to stop'), and it survives a restart (a killed soul stays killed even if the runtime reboots). Test the kill switch before you ship — a switch you've never pulled is not a switch you can trust.
Three escalating levels. Pause is graceful. Kill aborts mid-beat. The --all panic button is for incidents — drill it once a quarter so you know it works.
# Pause one soul (next beat won't fire, current beat finishes)
openclaw soul pause pr-reviewer
# Hard kill (current beat aborted, soul marked stopped)
openclaw soul kill pr-reviewer
# Pause every heartbeat soul in the workspace — the panic button
openclaw heartbeat pause --allApply: budget-first soul creation
- 1Before writing any heartbeat config, write its budget block first
- 2Set rate limit = the highest sane beat-rate for the job, then add 50% headroom
- 3Set max_iterations = your worst-case 'how many beats over 24h' estimate
- 4Set cost cap = the dollar number you'd be embarrassed to explain to your team
- 5Drill the kill switch on a staging soul; confirm it actually stops it
Key terms in this lesson
The big idea: a heartbeat without a budget is a runaway waiting to happen. Four layers — rate limit, max iterations, cost cap, kill switch — plus circuit breakers for the smart cases. Build them before the first beat fires.
End-of-lesson quiz
Check what stuck
15 questions · Score saves to your progress.
Tutor
Curious about “Heartbeat Budgets And Runaway Prevention”?
Ask anything about this lesson. I’ll answer using just what you’re reading — short, friendly, grounded.
Progress saved locally in this browser. Sign in to sync across devices.
Related lessons
Keep going
Creators · 9 min
What Perplexity Is: Search-Augmented LLM, Not A Chatbot
Perplexity is built around the idea that every answer should cite its sources. Treating it like ChatGPT misses the point — and the reliability gap that comes with it.
Creators · 10 min
Spaces: Building Team Knowledge Bases In Perplexity
Spaces are Perplexity's project containers — system prompts, files, and shared chat history. They turn the search engine into a research workspace.
Creators · 10 min
Comet Browser: What It Does That Atlas And Operator Don't
Comet is Perplexity's full browser with a research-native sidebar and an action-capable agent. It plays differently than ChatGPT Atlas or Operator — and the differences matter.
