Join our Newsletter — 33% off our NHI Course
Home› FAQ› AI Security› How do teams stop a misbehaving agent run…
AI Security

How do teams stop a misbehaving agent run from wasting budget?

← Back to all FAQ
By NHI Mgmt Group Editorial Team Updated November 2, 2026 Domain: AI Security

Use a kill switch in the agent framework that watches token count, tool-call count, retry count, and span depth. When one of those ceilings is crossed, stop the run before it completes the next loop. That containment belongs in the execution path, because post-hoc review arrives too late to prevent the cost.

What a budget kill switch needs to watch during an agent run

The control needs to live in the execution path, not in a later report. If the run is allowed to keep looping after a ceiling is crossed, the budget loss is already baked in. The practical question is not whether the agent is “bad” overall, but which run-level signals show that the current execution has stopped being economically safe.

Token count is the clearest early warning because it captures model consumption even when the agent is still making progress. Tool-call count, retry count, and span depth add important context: a run can be cheap per step and still become expensive through recursion, failed recovery attempts, or overly deep orchestration. A kill switch works best when these measures are treated as hard stop conditions, not as vague monitoring signals.

That is why teams usually pair a kill switch with a policy boundary that defines the maximum acceptable burn for a single task or session. The boundary should reflect the actual value of the run, because a long-running agent can be perfectly legitimate in one workflow and excessive in another.

Why the stop condition has to interrupt the next loop

The key design choice is timing. If the framework waits for the run to finish and then evaluates cost, the agent has already spent the money. Stopping before the next loop matters because the next loop is where repeated tool use, retries, or self-correction can turn a manageable run into a runaway one.

This is especially important when the agent chains tools or revisits the same state after a failure. In those cases, the cost often accelerates non-linearly, because each extra iteration can trigger more model calls, more tool executions, and more logging or tracing overhead. The control should therefore interrupt the run as soon as the threshold is crossed, then hand off to a human or supervisory workflow if the task still matters.

A good implementation also separates “soft warning” from “hard stop.” Warning thresholds help operators see emerging waste, but only a hard enforcement point prevents the agent from continuing past the economically acceptable limit.

How to contain the run without breaking useful work

Containment should preserve evidence and context while cutting off further spend. In practice, that means stopping model calls, blocking additional tool invocations, and freezing the current run state so the team can inspect what happened before deciding whether to restart, narrow the task, or approve more budget.

The most effective controls are usually scoped to the run rather than to the whole agent platform. That keeps a single bad execution from becoming a platform-wide outage. It also lets teams tune ceilings by task class, since a research-heavy workflow, a customer-facing workflow, and an automated maintenance workflow should not share the same tolerance for retries or span depth.

Teams should also avoid treating the kill switch as a substitute for good task design. If the agent routinely reaches the ceiling on normal jobs, the problem is probably the prompt, tool policy, planning loop, or orchestration pattern, not just the stop condition itself.

Risk and Threat Considerations

Unchecked agent loops can waste budget quickly, but the broader risk is that a misbehaving run keeps spending while operators assume it is still productive. The same pattern can also mask a deeper failure mode, such as a tool-selection loop, bad retry logic, or an instruction-following error that causes repeated consumption without useful progress.

Failure mechanism: The run keeps invoking model calls or tools after a safe ceiling has been exceeded, so cost grows before any human notices. Recursive retries, deep span chains, and repeated state checks are the usual accelerants.

Impact: Budget burn, delayed detection of a broken workflow, and a higher chance that the same faulty pattern is reused elsewhere. In a shared environment, one runaway run can also distort capacity planning and hide genuine demand signals.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP Agentic AI Top 10 addresses the attack and risk surface, while NIST AI RMF and NIST CSF 2.0 set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
OWASP Agentic AI Top 10ASI08 — Cascading FailuresRunaway loops and retries can cascade into uncontrolled cost growth.
ASI10 — Rogue AgentsA misbehaving agent can keep acting beyond acceptable budget limits.
Recommendation — Bound agent loops and halt execution when retries or depth start compounding cost. Add hard stop controls that deactivate agents when they exceed run budgets.
NIST AI RMFGV.3 — Measure and manage AI risksBudget overrun from agent runs is an operational AI risk that needs active measurement.
MP.4 — Map and measure AI systemsToken, retry, and tool-call ceilings require measurement of system behavior in use.
Recommendation — Define run-level cost thresholds and monitor them as part of AI risk management. Instrument agent executions so spend, retries, and depth are observable before cutoff.
NIST CSF 2.0PR.AA-05 — Identity Management, Authentication and Access ControlAgent tool actions should be constrained by policy so excess execution can be cut off.
Recommendation — Constrain agent permissions so a runaway run cannot keep invoking tools unchecked.

Practitioner Guidance

What to verify: Make sure the kill switch is enforced inside the same runtime that can issue tool calls, not in a separate dashboard or post-run report. If the agent can continue one more loop after the ceiling is hit, the control is too weak to trust.

Decision rule: Use the lowest ceiling that still fits the task, then raise it only for known exceptions. If a workflow needs frequent override approvals, treat that as a signal to redesign the agent path rather than normalise overspend.

Practitioner takeaway: The control is effective only when it stops the next expensive action, not when it merely records that the run was expensive.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Reviewed and updated by the NHIMG editorial team on November 2, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org