Know When Your Agents Misbehave

Scheduled and on-demand anomaly checks for AI agent authorization. The implemented detector evaluates high action volume, high failure rates, new agent-principal pairs, and off-hours activity, then stores findings for review.

grantex.dev/dashboard/anomalies

Anomaly Detection

Illustrative UI preview
3
Critical
7
High
12
Medium
4
Low
High action volume for ag_crm_bot CRITICAL 2m ago
High failure rate for ag_data_sync HIGH 8m ago
New agent-principal pair for ag_support_bot MEDIUM 14m ago
Off-hours activity for ag_billing_agent LOW 1h ago

AI Agents Operate Unsupervised

Agents run 24/7, make thousands of API calls, and delegate to sub-agents. Without real-time monitoring, compromised or misbehaving agents go unnoticed.

Scheduled or On Demand

The worker runs on startup and then hourly by default. The protected detection endpoint can also run the same checks on demand.

🔍

Pattern-based Analysis

Four SQL-backed checks currently evaluate action volume, failure rate, new agent-principal pairs, and off-hours activity.

🛠

Stored Rule Definitions

Create and manage custom condition objects through the API. An evaluator for those custom definitions is not currently wired into detection.

🔔

Channel Configuration

Store Slack, generic webhook, or email channel configuration and severity filters. Automatic finding delivery requires a separate worker.

🔄

Alert Lifecycle

Finding APIs support open, acknowledged, and resolved status with timestamps and optional resolution notes.

🚫

One-click Revocation

Use the alert action to request grant revocation. Enforcement changes only after protected services receive current grant state; local JWT validation alone is not immediate revocation.

Four evaluated checks; additional rules are illustrative

The server currently evaluates four SQL-backed checks: high action volume, high failure rate, new agent-principal pairs, and off-hours activity. The ten rows below are stored or illustrative rule definitions; the remaining definitions are not active detectors today.

Rule ID Name Trigger Severity
velocity_spike Velocity Spike Request rate exceeds 3x the rolling 1-hour average HIGH
scope_escalation Scope Escalation Agent requests scopes beyond its registered set CRITICAL
unknown_agent Unknown Agent Token presented by an unregistered agent DID CRITICAL
token_replay Token Replay Same token JTI used from multiple IP addresses CRITICAL
off_hours_activity Off-Hours Activity Agent active outside its configured operating window LOW
high_failure_rate High Failure Rate More than 30% of requests fail in a 15-minute window HIGH
concurrent_sessions Concurrent Sessions Same grant token used from 3+ distinct IPs simultaneously HIGH
delegation_depth Delegation Depth Delegation chain exceeds configured max depth MEDIUM
budget_overspend Budget Overspend Agent consumes more than 90% of budget in a single burst HIGH
geo_anomaly Geographic Anomaly Agent makes requests from unexpected geographic regions MEDIUM

From Detection to Resolution

Finding APIs record lifecycle status, timestamps, and optional resolution notes. Notification delivery and responder identity require the host application or a separate worker.

🚨
Detected
Implemented SQL check stores a finding
🔔
Delivery hook
Connect your notification worker
👍
Acknowledged
Responder takes ownership
Resolved
Issue fixed, note attached

Store notification-channel settings

The API stores Slack, generic webhook, and email settings with severity filters. It does not yet dispatch anomaly findings to these destinations automatically.

💬
Slack
Configuration storage
🚨
Generic webhook
Bring your own delivery worker
📊
Email
Configuration storage
📡
Finding API
Poll or integrate directly

Store rules for a future evaluator

Custom definitions can be created, listed, enabled, disabled, and deleted. They are configuration records today; the detector does not evaluate them automatically.

On-demand detection — TypeScript SDK
import { Grantex } from '@grantex/sdk';

const grantex = new Grantex({
  apiKey: process.env.GRANTEX_API_KEY!,
});

// Run the four implemented SQL-backed checks now
const run = await grantex.anomalies.detect();
console.log(run.total, run.anomalies);

// Review unacknowledged findings
const open = await grantex.anomalies.list({
  unacknowledged: true,
});

if (open.anomalies[0]) {
  await grantex.anomalies.acknowledge(open.anomalies[0].id);
}

Metrics, lifecycle APIs, and Prometheus

Query finding counts via the protected API, manage lifecycle status, or scrape implemented Prometheus metrics from /metrics.

📈

Metrics API

GET /v1/anomaly/metrics returns counts by status and severity for a 1h, 6h, or 24h window, with an optional agent filter.

📡

Finding Lifecycle API

List findings, acknowledge them, resolve them with a note, and query current lifecycle totals. The detector does not currently publish anomaly SSE events.

🔧

Prometheus Counters

GET /metrics exposes grantex_anomalies_detected_total and grantex_anomalies_unacknowledged alongside service metrics.

Review agent activity patterns

Run the four implemented checks on demand or use the hourly worker, then review and manage findings through the API or dashboard.