What anomaly detection does
KavachOS scans the audit log for behavioral patterns that suggest an agent is operating outside its intended scope. The most common signal is a cluster of denied calls that match privilege escalation patterns, an agent repeatedly attempting to access resources it was never granted. Anomaly detection is not a background process. You callscan() and get back a list of findings at that point in time. This keeps the system predictable: there are no background threads, no persistent state, and no surprise side effects.
Anomaly types
| Type | Severity | Description |
|---|---|---|
privilege_escalation | critical | Denied calls with reasons matching INSUFFICIENT_PERMISSIONS, privilege, or escalation. |
high_denial_rate | warning | More than 20% of the agent’s recent calls were denied. |
rapid_fire | warning | Call volume in the last hour exceeds a configurable threshold. |
unusual_resource_access | info | The agent accessed a resource it has no explicit permission for, even if the call succeeded. |
off_hours_activity | info | Calls outside the agent’s declared timeWindow constraint, if one is set. |
scan() queries audit logs directly, it is not a background process and does not push alerts. Call it from a scheduled job, a webhook handler, or a dashboard endpoint.Anomaly fields
The agent where the anomaly was detected.
type
'privilege_escalation' | 'high_denial_rate' | 'rapid_fire' | 'unusual_resource_access' | 'off_hours_activity'
Classification of the detected pattern.
How urgent the finding is.
Human-readable explanation of what was observed.
Number of matching events in the scanned window.
ISO timestamp of when the scan ran.
The specific audit log entries that triggered this finding.
AnomalyConfig options
Start of the window to scan. Defaults to 24 hours ago.
End of the window to scan. Defaults to now.
Denial rate percentage above which high_denial_rate fires. Default is 20.
Calls per hour above which rapid_fire fires. Default is 100.
Scope the scan to a single agent. Omit to scan all agents.
Code examples
Scan a single agent for anomalies
Get a denial-rate summary for all agents
Act on critical findings
The most effective response to a privilege escalation detection is to pause the agent while you investigate:Use trust scores as the anomaly aggregate
TheanomalyCount field on a trust score is a pre-computed count of privilege escalation attempts, updated each time computeScore runs. It is a cheaper signal than a full scan when you only need the count:
Next steps
Trust scoring
Translate anomaly counts into a graduated trust level.
Approval flows
Route flagged agents through human review before they act.
Audit trail
Query the raw log data that anomaly detection reads.