AI Agent Governance

July 28, 2026

~ 9 min

Runaway Agents: AI agent observability for Loops, Drift, and Recursion Before They Burn Your Budget

On this page
    Explore how these evaluation metrics work in practice?
    Live Demo mode

    An agent calls the same tool forty times in a row with near-identical arguments. It doesn't crash. It doesn't throw. Every response is a 200, latency sits inside the SLO, CPU is flat – and the session quietly spends a week of that agent's normal budget before anyone opens the billing dashboard. The tell isn't an error – it's the absence of progress underneath a stack of perfectly successful calls.

    Conventional APM can't see this because, from an infrastructure point of view, nothing is wrong. That is the gap AI agent observability exists to close: it measures what the agent actually did – iterations, token burn rate, recursion depth, repeated tool calls – not whether the service running it stayed healthy. Below: three failure patterns worth naming, the metrics that detect them, and the point where detection has to become enforcement.

    Why Traditional Monitoring Doesn't Catch Runaway Agents – the AI Agent Observability Gap

    Application monitoring answers three questions: is the service up, how fast does it respond, what share of requests fail. Uptime, latency, error rates – signals designed for systems where one request produces one response and cost tracks infrastructure hours rather than output volume. Autonomous AI agents invert nearly every one of those assumptions. One goal goes in; an unknown number of steps come out. The agent is stateful, carries context between calls, acts through tools, and decides for itself how hard to try. Its real behavior only exists at runtime.

    Agent observability measures a different object than application monitoring. Application monitoring tracks the request; agent observability tracks the goal – how many reasoning steps the agent took, how many tool calls it issued, how many tokens the whole session consumed, and whether the same call pattern repeats without moving closer to completion. A single goal can fan out into hundreds of model calls, and every one of them can return successfully while the session as a whole never converges.

    Question Application monitoring answers AI agent observability answers
    Unit of measurement One request, one response One goal, from prompt to terminal state
    "Healthy" means 200 response, latency inside SLO Task completed in bounded steps at bounded cost
    Cost signal Infrastructure hours, request count Tokens per session, cost per completed task
    Failure signal Error rates, timeouts, 5xx Repeated tool calls, rising recursion depth, semantic drift
    A runaway agent looks like Completely healthy 40 identical tool calls, call stack depth 12, 3× baseline burn

    The pattern is easy to miss because each component reports success independently. Per-call rate limits cap one request; they cannot see that a single goal just triggered nine hundred of them. A perfectly healthy service can loop forever.

    The cost asymmetry makes this expensive fast. Anthropic reported in June 2025 that in its own production data, agents typically consume around 4× more tokens than chat interactions and multi-agent systems around 15× more. A malfunction that would have cost $2 in a chat product costs $30 in an agent product before anything looks abnormal. AI agent observability therefore has to collect telemetry data at the session and goal level rather than per call – per-agent usage, full prompt visibility, per-task benchmarking. That is the layer OptScale AI's Team & Agent AI Performance pillar is built on.

    Three Patterns Worth Naming: Loops, Drift, and Recursion

    Most writing on this subject stops at "monitor your agents." That isn't actionable. Three observable patterns account for the bulk of runaway spend, and each leaves a distinct signature in an agent trace.

    Loop repetition without progress

    A loop is when an agent repeats the same action without making progress toward its goal. The observable signal is the same tool call, with identical or near-identical arguments, executed N times in sequence while the task state does not change.

    In a trace, this shows up as sibling spans with the same tool name and matching argument hashes, each returning successfully, with no new entities entering the agent's context. Agent loop detection is therefore a comparison problem, not a machine-learning one: hash the tool name plus normalized arguments and count consecutive matches.

    This is not an edge case. MAST – the Multi-Agent System Failure Taxonomy from UC Berkeley (Cemri et al., 2025), built from more than 1,600 annotated execution traces across seven multi-agent frameworks – lists both "Step Repetition" and "Unaware of Termination Conditions" among its 14 documented failure modes.

    Drift the task quietly changes

    Drift is when an agent's behavior gradually diverges from the task it was given, without any single step being wrong. The observable signal is growing semantic distance between the agent's recent outputs and the original prompt or goal statement, usually alongside token usage climbing above the agent's own baseline.

    Where this gets expensive is that drift produces work – plausible, well-formed, billable work that nobody asked for. Detection is comparative: embed the original goal and each successive output, then track cosine distance across the session. A rising curve over several steps is the anomaly pattern; one distant step is noise.

    Recursion depth without a ceiling

    Recursion is when an agent spawns sub-agents or sub-tasks without a bounded depth limit. The observable signal is call-stack depth in the agent graph increasing over time with no enforced maximum – each level individually reasonable, the total unbounded.

    Here's what that looks like in practice: a planner decomposes a goal into four sub-tasks, and each sub-agent decides its own sub-task is still too broad and decomposes again. At depth 5 with a branching factor of 4, one request becomes over a thousand leaf calls. Recursion has the worst cost profile of the three because it compounds multiplicatively – and the easiest fix, because a hard maximum depth stops it outright.

    Metrics That Actually Catch This

    Naming patterns is useless without numbers attached. Four AI agent evaluation metrics do most of the work, and all four are computable from standard trace and span data.

    Metric Definition What it catches Starting threshold
    Token burn rate per session Total tokens ÷ session duration (or ÷ completed steps) Drift, runaway fan-out Flag above ~3× the agent's rolling 7-day median
    Recursion depth Maximum depth of the sub-agent call stack in one run Recursion Hard cap of 3–5 for most production agents
    Repeated-call ratio Identical (tool + normalized args) calls ÷ total tool calls in a session Loops Investigate above 0.3; near-certain loop above 0.5
    Cost-per-completed-task vs cost-per-abandoned-task Session cost split by terminal outcome Systemic waste Abandoned-task spend above ~20% of the agent's total

    The fourth is the one most teams skip, and the one finance actually asks about. Cost-per-completed-task tells you what the agent is worth; cost-per-abandoned-task tells you what it costs when it fails. The ratio between them is the clearest single signal in AI agent analytics that an agent burns budget without producing value – two agents with identical average session cost have entirely different economics if one abandons 5% of runs and the other 40%.

    Treat these as starting points. The right baseline is per-agent and empirical: run the agent for a week, take the median, set ceilings against observed behavior.

    Monitoring vs Evaluation Tools Where Each One Stops

    The observation side of this category is well served. Langfuse offers open-source tracing, session grouping, prompt management, and per-trace cost attribution. Arize – and its open-source Phoenix project – concentrates on evaluation, drift analysis, and LLM-as-a-judge scoring. LangSmith gives step-level traces of agent workflows built on LangChain and LangGraph, plus dataset-driven evals. All three map onto OpenTelemetry's GenAI semantic conventions, which standardize attributes such as gen_ai.usage.input_tokens, define spans for agent invocations, and keep prompt bodies opt-in so sensitive data stays out of the trace backend by default – though that spec's agent portion was still marked Development in the 1.40.0 conventions as of April 2026.

    To be clear about where the line is: these AI agent observability tools are built to show you what happened. They record the agent trace, score the output, and surface the anomaly on a dashboard. That work is necessary. But observation ends at the alert – most AI monitoring tools sit beside the execution path and consume telemetry after the fact, with no position from which to refuse the next call. That's a monitoring problem. Stopping it is a different one.

    Setting Budget Ceilings, Not Just Alerts

    Detecting a runaway agent is half the job. Stopping it before the invoice arrives requires sitting in the request path, not beside it. Consider the arithmetic: an agent looping at 30 calls per minute, carrying roughly 10,000 tokens of context per call, moves about 300,000 tokens a minute – on the order of a dollar a minute at current frontier-model input pricing, per agent, for as long as it runs. An alert that reaches an on-call engineer in fifteen minutes has already let the incident play out. Overnight, it runs for eight hours.

    Gateway-level enforcement changes the shape of the problem. Every model call, tool call, and retrieval an agent makes has to leave the process, so routing that outbound traffic through one control point/gateway creates the single place where a limit can be applied rather than recorded. A budget ceiling set there is enforced: max cost per task, max tokens, max execution time, max recursion depth – with auto-stop the moment one is breached. AI agent anomaly detection at the same layer catches the pattern; the ceiling ends it.

    This is where AI agent monitoring stops being a dashboard and becomes a control, and where runtime monitoring earns its keep: loops caught mid-execution, token bursts flagged live, unauthorized MCP servers and vector stores blocked rather than logged after the fact. It pairs directly with AI cost optimization, too – the same gateway that enforces the ceiling can compress context, align prompt caches and route to the best-value model that still meets quality, cutting the cost of the calls that should happen while eliminating the ones that shouldn't.

    Frequently asked questions

    What's the difference between an agent loop and normal iterative reasoning?

    Progress. Normal iterative reasoning changes state on every pass: new information enters the context, the next tool call's arguments differ, the plan narrows. A loop repeats the same call with identical arguments and adds nothing to the agent's state. The practical test is the repeated-call ratio – hash the tool name plus normalized arguments and count consecutive matches. Three identical calls can be a retry; ten is a loop.

    How do you detect agent drift without manually reviewing every session?

    Two automated signals cover most cases. The first is semantic: embed the original goal and each successive output, then track cosine distance across the session – a monotonic rise over several steps is drift, a single spike is noise. The second is statistical and far cheaper: compare the session's token burn rate and tool-call mix against the agent's rolling baseline, flagging deviations beyond a set multiple (3× is a common start). Manual review then applies only to flagged sessions.

    Can you stop a runaway agent automatically, or only alert on it?

    You can stop it, but only from inside the execution path. AI agent monitoring that receives traces asynchronously can alert; it cannot refuse a call it has already been told about. Automatic stopping requires the limit to be enforced where the agent's outbound traffic passes – at a gateway or proxy layer – so a breached cost, time, or recursion-depth ceiling terminates the run instead of generating a notification. Mature teams run both: alerts for investigation, hard ceilings for containment.

    Do observability tools like Langfuse or Arize already solve this, or is something else needed?

    They solve the visibility half well. Langfuse, Arize, and LangSmith give you traces, spans, session cost attribution, evaluation scoring, and drift analysis – everything needed to understand what a production agent did and why. What they are not designed to do is enforce. AI agent observability tells you an agent breached its budget; gateway-level enforcement stops the breach continuing. Most mature setups pair an evaluation stack with a governance layer holding the hard limits.

    Conclusion

    Runaway agents are not a reliability problem in the traditional sense. They are a class of failure in which everything works, and money disappears. Three named patterns cover most of it: loops (the same call repeated without progress), drift (behavior diverging from the original goal), and recursion (call stack depth growing without a ceiling). Four metrics detect them: token burn rate per session, recursion depth, repeated-call ratio, and cost-per-completed-task against cost-per-abandoned-task. Detection only matters if something acts on it – which is why AI agent observability without enforcement leaves the expensive half of the problem unsolved. Gartner's June 2025 forecast that over 40% of agentic AI projects will be canceled by the end of 2027 named escalating costs and inadequate risk controls among its three causes: governance failures, not model failures.

    Tracing and evaluation tools already cover the detection half well. OptScale AI's Agent Control covers the enforcement half that has to follow it. Register the agents you already run — LangChain, CrewAI, AutoGen or custom code — and govern them: hard per-agent limits on cost, time, tokens and recursion depth with auto-stop on breach; real-time anomaly detection for loops, drift and token bursts; an allowlist of MCP servers and vector stores per agent; and a full audit trail.

    Take your agents under control

    Stop guessing what your agents are doing. Watch it happen in the live demo.