Skip to main content

What exists today

theAuth does not ship an anomaly detector. There is no scan() function and no anomaly finding type. Three small pieces exist, and everything else on this page is something you build on top of the audit log.
The built-in denial reasons are plain sentences such as No permission grants agent "x" access to "write" on "y". They do not contain INSUFFICIENT_PERMISSIONS, privilege, or escalation, so anomalyCount stays at 0 unless a beforeAuthorize hook or your own wrapper produces a reason with one of those words. Do not rely on anomalyCount as a privilege escalation detector without that.

Not implemented

These were described on earlier versions of this page and are not in the TypeScript package: a scan() API, the finding types privilege_escalation, high_denial_rate, rapid_fire, unusual_resource_access, and off_hours_activity, the AnomalyConfig options (since, until, minDenialRate, rapidFireThreshold, agentId), and finding objects with severity, evidence, and detectedAt. If you want these signals, compute them from the audit log as shown below.

Code examples

Find denied calls for an agent

Compute a denial rate per agent

React to denials with the onViolation hook

The hook is called without being awaited, so a slow handler does not delay the authorize() result. Keep counters in a durable store if you need them to survive restarts.

Pause an agent after repeated denials

agent.revoke() is permanent. If you want to temporarily suspend an agent and restore it later, create a new agent with the same configuration instead of revoking.

Read the trust score factors

lastViolation is the timestamp of the most recent denied call of any kind. Computing a score also stores it.

Next steps

Trust scoring

Turn denial history into a graduated trust level.

Approval flows

Route flagged agents through human review before they act.

Audit trail

Query the raw log data these signals are built on.
Last modified on October 18, 2026