Vanguard Sprint: SLM anomaly triage wired into mesh scoring

2026-03-17

anomaly-enginemodel-routercaf

What We Built

Replaced the placeholder SLM assessment in the mesh anomaly engine with a real lightweight model call. When the composite anomaly score is borderline (0.4-0.6), the engine fires a cheap model assessment via auto:floor to determine if the agent is compromised, misconfigured, or normal. The result is cached for 5 minutes and integrated on the next scoring cycle.

The implementation is fully non-blocking (fire-and-forget), rate-limited (10 assessments per tenant per minute), and protected by a circuit breaker (3 consecutive failures disable SLM for 5 minutes).

Why It Matters

Borderline anomaly scores are the hardest to classify — heuristics and statistics alone can't distinguish between a legitimate but unusual workload and an actual compromise. By routing borderline cases through a lightweight model, BrainstormRouter gets a third opinion at minimal cost, reducing false positives and false negatives in the autonomous governance layer.

How It Works

The AnomalyEngine accepts an optional slmAssessmentFn callback injected at gateway boot. When a borderline score is detected, the engine calls this function asynchronously with the scoring context. The callback routes to auto:floor (cheapest available model) with max_tokens: 150, temperature: 0.

The raw model output is parsed by parseSlmResponse() into a structured SlmVerdict with verdict, confidence, and reasoning. The verdict maps to a numeric score (compromised=1.0, misconfigured=0.7, normal=0.1) cached with a 5-minute TTL.

The Numbers

  • Hot path overhead: <1ms (fire-and-forget, synchronous path unaffected)
  • SLM call cost: ~$0.0001 per assessment (auto:floor, 150 tokens)
  • Rate limit: 10 assessments/tenant/minute
  • Circuit breaker: 3 failures → 5-minute cooldown

Competitive Edge

No other AI gateway combines real-time anomaly detection with live model-based triage. Portkey, OpenRouter, and Letta offer static rule-based monitoring at best. BrainstormRouter's anomaly engine uses the very models it routes to assess agent behavior — a recursive intelligence loop unique to this platform.

Lockstep Checklist

  • [x] API Routes: No API changes (internal engine only).
  • [x] TS SDK: No SDK changes (no API contract change).
  • [x] Python SDK: No SDK changes (no API contract change).
  • [x] MCP Schemas: No MCP changes (not agent-facing).
  • [x] Master Record: Internal engine improvement, no capability record change needed.