Skip to content

Governance

Add Budget + Health Kill-Switches to a Runtime Agent

To configure AI agent budget and health kill-switches you should not need a monitoring side-project, a supervisor loop, or a scatter of try/except blocks around every tool call — you need one config block on the process. This is the copy-paste recipe, not the why-you-need-it explainer: paste one ProcessConfig (or one .agent YAML manifest), fill in your per-run and daily limits, your irreversible-action cap, the four behavioral-health detectors, pick pause / stop / escalate, point a webhook at Slack, and ship a governed, self-limiting agent in a single file. The runtime enforces the whole declaration for you, around every invocation, out-of-band. Below is the exact block.

Limit an AI Agent's Irreversible Actions Per Run

To limit irreversible actions an AI agent takes in a single run, you need a control that counts destructive calls separately from everything else the agent does. This is a different problem from stopping a runaway loop, and it is the one that keeps operators awake. A looping agent that calls get_status(id=42) forty times is embarrassing and cheap. An agent that reasons its way into ten issue_refund calls, or fires the same dunning email to your entire customer list, or deletes ten accounts because a webhook payload looked plausible — that is not embarrassing, it is a Monday-morning incident review. The failure isn't volume. It's a small number of destructive calls, each one individually reasonable, that together are unrecoverable.

How to Stop a Runaway AI Agent (Runtime Kill Switches)

To reliably stop a runaway AI agent you need a kill switch that acts on the process, not a counter that raises an exception inside one function call. That distinction is the whole game. Almost every framework hands you a per-run cap — max_iterations, recursion_limit, a usage limit — and calls it a safety control. But those caps raise an exception inside a single ainvoke(), and an exception only exists if there is a caller sitting there to catch it. The moment your agent is running unattended on a cron, a webhook, or a file trigger, there is no such caller: each trigger fires a fresh invocation, the counter resets to zero, and nothing halts the thing that is actually misbehaving. This post reframes the runaway agent kill switch as runtime enforcement — budget, behavioral-health, and mission breaches that become out-of-band pause/stop/escalate actions on a supervised AgentProcess — and shows you how to wire one in a few lines.