Catch token misuse with Agent Anomaly Detection

DEC. 3, 2026
Kevin Islas Senior Software Engineer

Every token an agent generates ends up on your bill, even the ones nobody reads. Once you open an agent to external users, some will test the agent’s limits. They may push an agent to write far more than anyone could use, or they keep it going and never let it stop. Those tokens used by the agent come out of your quota and your budget. Nothing errors out, so these sessions look like normal traffic.

To catch those sessions without flagging the heavy, honest work your best users do, we added the Token Misuse detector to Agent Anomaly Detection, now in Private Preview on the Gemini Enterprise Agent Platform (see our launch post). In this post, we cover the three token-waste patterns we see most, how a two-stage pipeline separates identifying them from power users, and what we found testing on simulated traffic.

Why a token cap doesn't work

The first fix most teams reach for is a cap on tokens per user or per session. The problem is that a cap also flags the wrong people. An attorney drafting a partner memo over several turns can use as many tokens as someone abusing the agent. So can a team running due diligence over a long list of documents. Both need every token they use. The abusive user produces output nobody reads or spends inefficiently, and you still pay for every token. A token count tells you how much the agent wrote, not how useful or impactful the output was.

Instead of counting tokens, the Token Misuse detector looks at how a session behaves.

fig1
Figure 1: An honest power user and an abusive user can spend the same number of tokens. The Token Misuse detector flags the behavior on the right, not the total.

What abuse looks like

The abusive sessions we looked at tend to fall into three patterns:

  • Token spike: the user asks for more output than any person could read, for example: "Do not summarize or abbreviate any section. The final output must exceed 30,000 words."
  • Recursive meta-summary: each turn reworks the agent's last answer instead of going back to the source. Summarize it in one sentence, expand it to five, then summarize it again.
  • Infinite loop: the user keeps asking for another variation and never lets the agent finish. There is no deliverable, just more output.

An honest power user's session looks different. It has a real goal and a plan, each turn goes back to the source documents, and it ends once the deliverable is done.

How the Token Misuse detector works

Running an LLM over every session just to catch wasted tokens would burn its own budget, so the Token Misuse detector analyzes traces and logs from your Agent Development Kit (ADK) agent in two stages. A cheap statistical first pass screens all traffic; one of its checks, token usage escalation, watches how token counts grow across LLM calls. Sessions that have leading indicators of abusive patterns are then evaluated deeper by an LLM for Token Misuse, where Gemini reads the full session and decides whether it's abuse or heavy, honest work. All of this runs in the background, about two minutes behind your agent, so it adds no latency and never prevents agent execution.

fig2
Figure 2: Every session gets a statistical check. Only the sessions that look off get a full read by the Token Misuse detector.

When the Token Misuse detector flags a session, you get a finding with a severity, a probability score, a plain-language explanation, and recommended fixes. In Figure 3, it catches a user looping the legal-review agent over its own prior answers and recommends breaking recursive meta-operations and capping follow-up turns that add no new source material.

fig3_half_padded
Figure 3: A Token Misuse finding in Agent Anomaly Detection, with its severity, a plain-language explanation of what the user was doing and recommended fixes.

Testing the detector on simulated traffic

We tested the Token Misuse detector on simulated legal document-review sessions at three levels: everyday use, heavy power-user work, and abuse. The power-user sessions ended up being the most important part of the test. If a test set only has everyday sessions and abuse, the abusive sessions are simply the ones with the most tokens, so a plain token threshold scores well. Real traffic also has heavy, honest sessions that use just as many tokens, and that same threshold flags your best customers.

We then ran a seven-hour A/B test across six simulated agents (including 106 runaway-token abuse sessions), comparing our existing detectors alone against the pipeline with the Token Misuse detector enabled. With the detector, recall on runaway-token abuse (the share of abusive sessions that got a finding) rose from 29% to 76%, precision (the share of findings that were actually abuse) rose from 94% to 98%, and the detector added zero false positives on honest power-user sessions. Precision and recall across our other five anomaly scenarios held steady. We tuned and tested the detector on this document-review workflow; token growth looks different in code-generation or data-pipeline agents. Even so, the core trade-off holds: a threshold sees the same count for the attorney and the abusive session, while the detector reads what each session did and flags only the waste.

fig4
Figure 4: Adding the Token Misuse detector raised recall from 29% to 76% and precision from 94% to 98% on simulated document-review traffic.

Get started

The Token Misuse detector is enabled by default in Agent Anomaly Detection, now in Private Preview for teams deploying agents on the Gemini Enterprise Agent Platform with ADK 2.1.0 or later. The documentation covers Private Preview access, prerequisites, and one-click setup.

Once findings start coming in, use the recommended guardrails, such as capping single-turn output length or follow-up turns that add no new source documents, rather than setting a flat session token cap. Detection runs about two minutes behind the session, so for longer sessions like an endless-variations loop, an ADK callback can check for findings through the API and stop the session before its next turn.