Skip to content

Behavior-Based Token Misuse Detection for User-Facing Agents

Behavior-based token misuse detection flags agent sessions by spending pattern, such as endless rework or variation, and still needs a per-turn output cap.

Use it when external users drive your agent's token spend and a flat per-user or per-session token cap would also stop your heaviest honest users. It replaces that flat cap as the way to tell waste from heavy work. It does not replace the per-turn output cap or the other bounds in Unbounded Consumption, because detection lags the session and never stops a running turn (Google Developers Blog, 2026).

Why a flat cap misfires

Token waste raises no error: "Nothing errors out, so these sessions look like normal traffic." A count also cannot separate two heavy sessions, because "An attorney drafting a partner memo over several turns can use as many tokens as someone abusing the agent" (Google). A cap low enough to stop the abuser stops the attorney too.

Session shapes that separate waste from work

Google reports that the abusive sessions it examined "tend to fall into three patterns" (Google):

  • Token spike: a request for more output than any person could read.
  • Recursive meta-summary: each turn reworks the agent's previous answer instead of returning to the source.
  • Infinite loop: repeated requests for another variation, with no deliverable at the end.

In an honest heavy session, "each turn goes back to the source documents, and it ends once the deliverable is done" (Google). The three patterns are one vendor's observed set, not a complete taxonomy.

Screen every session, judge only flagged ones

"Running an LLM over every session just to catch wasted tokens would burn its own budget," so Google's detector works in two stages. A cheap statistical pass screens all traffic, and one of its checks "watches how token counts grow across LLM calls." Gemini then reads each flagged session in full and decides "whether it's abuse or heavy, honest work" (Google). The launch post for Agent Anomaly Detection, the product the detector ships in, describes the same layered pipeline for the whole product (Google launch post, 2026).

graph TD
    A[Every session] --> B[Statistical screen]
    B -->|no signal| C[No finding]
    B -->|tokens escalate| D[LLM reads session]
    D -->|honest heavy work| C
    D -->|abuse| E[Finding]
    E --> F[Callback stops next turn]

Act on a finding before the next turn

The detector runs "about two minutes behind your agent, so it adds no latency and never prevents agent execution" (Google). Each finding carries a severity and a probability score, and an agent callback can pull findings through an API and halt the next turn "when it crosses a threshold you set" (Google launch post).

For the fix, Google recommends targeted 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" (Google).

Test with honest heavy sessions in the set

Google explains that if a test set holds only everyday sessions and abuse, a plain token threshold scores well, because the abusive sessions are the ones with the most tokens. Real traffic adds honest sessions that "use just as many tokens, and that same threshold flags your best customers" (Google).

Google's seven-hour A/B test ran across six simulated agents, including 106 runaway-token abuse sessions. Against its existing detectors alone, adding the Token Misuse detector raised recall on runaway-token abuse from 29% to 76% and precision from 94% to 98%, with zero added false positives on honest power-user sessions (Google). The baseline was Google's existing detectors, and the post reports no comparison with a token cap. The traffic was simulated document review, and Google ran the test itself. Google also states that "token growth looks different in code-generation or data-pipeline agents."

Why it works

Abuse and heavy work can match on token count but differ in behavior. In Google's words, "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" (Google). The statistical screen is cheap enough for every session but leaves the abuse decision to the LLM stage, which costs too much to run everywhere (Google). Running the cheap check first spends the expensive judge where abuse is most likely. Hua et al. formalize this budget trade for runtime monitors and find that "combining two monitors can Pareto dominate using either monitor alone" (arXiv 2507.15886v4). Their setting is detecting backdoored code, so the paper supports the cascade economics only.

When this backfires

A flat cap has no lag, no LLM bill, and no transcript for an attacker to write into. Prefer a cap, or add controls beside the detector, under these conditions:

  • Low traffic or few external users. An LLM read has its own cost, which is why Google does not run one on every session (Google). With few external users, a cap with a higher tier for known heavy users avoids that cost and the work of building a labeled set of power-user sessions.
  • One oversized turn. A finding can only stop the next turn, so only a per-turn output cap stops a token spike inside one turn.
  • Honest sessions that share an abuse shape. Iterative editing that reworks the last answer looks like recursive meta-summary, and variant exploration looks like the infinite loop. Google reports tuning and testing the detector on document review (Google).
  • Users who write for the judge. The LLM stage reads a transcript the abuser wrote. Agent-as-a-Proxy concludes that resilient control "requires treating a monitor's observations as an untrusted input surface rather than passive telemetry" (arXiv 2602.05066v3). It tested indirect injection after agent compromise, not token-misuse detectors; see Monitor Observation-Channel Injection.
  • Low-and-slow abuse. Many serverless denial-of-wallet attacks "are difficult to distinguish from legitimate traffic patterns, especially when conducted at low rates over extended periods" (Dorsett et al., arXiv 2508.19284v1). A token-escalation check has nothing to flag in a session that never escalates. Sampling unflagged sessions into the deeper review stage, as Layered Misalignment Monitoring does, covers part of that gap.
  • Internal or first-party callers behind authentication, where the denial-of-wallet vector collapses (Unbounded Consumption).

Example

Google's post shows one finding. The detector "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" (Google). The fix targets the shape the finding names, recursive meta-summary, rather than the session's total spend.

Key Takeaways

  • Put honest heavy sessions in any test of a cost-abuse control; without them a plain token threshold scores well and still flags your best customers.
  • Check for a finding before each new turn, because the detector itself never blocks a session.
  • Keep a per-turn output cap, because a single oversized turn completes before an asynchronous finding can act.
  • Treat the transcript the LLM judge reads as attacker-written input.
  • Read the 29%-to-76% recall gain as one vendor's simulated document-review result against its own prior detectors; the post reports no comparison with a token cap.