← Back to Research
Framework · May 2026

Agent Behavior Analytics through the Residual Stream

A unifying picture for Agent Behavior Analytics, and a sharper way to think about anomaly detection across event, intent, and residual-stream space.

01

Why Agent Behavior Analytics

Classical anomaly detection (UEBA, EDR, network traffic) was built for the outside world: log lines, packets, downstream events.

Agent traffic moves the problem inside. The adversary shapes the inputs your detector sees. The mechanism lives in the agent's internal state, not in any log line.

ABA is anomaly detection on a unified substrate (inputs, internal state, outputs), not just the boundary.


02

A Unified View

The substrate has structure at two scales: inside one agent, then lifted across agents.

Three token positions sharing a residual stream, with attention reading across positions and MLP transforming each in place

The Residual Stream

Every token position carries one vector, updated layer by layer. Each layer reads from the stream, writes a delta, and the next layer reads the sum.

Attention moves information across positions. MLP processes it locally, in place.

Residual streams lifted across agents on a shared-memory bus

All the Way Up

One agent's decoded output becomes another's input. Tool calls, queues, and databases form a shared-memory bus: a residual stream one level up.

Indirect ≈ attention
Tool call mutates shared state. A later agent reads it via the bus.
Direct ≈ MLP
Response fed verbatim to the next agent. No shared state.

Both go through decoding. What differs is what the output does next.


03

Three Surfaces, Three Analyses

Each surface demands a different analysis. Bringing the wrong one is what makes naive prompt anomaly detection fail.

Event surface — bell curve with outlier, statistical analysis

Event surface

statistical analysis

API calls, file writes, scheduler entries, database mutations. The generative process is stable, the vocabulary is finite. Density estimation does most of the work. Classical UEBA.

The new wrinkle is provenance: every flagged event traces back to a specific decode by a specific agent.

Intent surface — reachable output sets under different control budgets, control-theoretic analysis

Intent surface

control-theoretic analysis

Prompts aren't data. They're control inputs. The model is the plant. Outputs are the system's response. The question isn't "is this prompt unusual" but "what region of output space did this input drive us into, and at what control cost?"

  • Jailbreaks: control inputs that drive the system into unsafe outputs
  • Prompt injections: adversarial controls hidden inside a legitimate reference signal
  • Adaptive attacks: closed-loop control that adapts to detector feedback
  • Distribution shift: inputs outside the model's calibrated operating envelope

Anomaly is contested on this surface. A rare philosophical question can look like an attack; a low-effort prompt can land in an unsafe region. What density estimation misses, reachability captures: how much control effort is needed to land here from a benign start?

The right tools come from control theory: reachable sets, controllability, energy of control. See Bhargava et al., What's the Magic Word? A Control Theory of LLM Prompting.

Residual-stream surface — subspace geometry with principal direction

Residual-stream surface

geometric analysis

The other two surfaces only see the boundary: what came in, what went out. The mechanism of prompt injection lives inside the residual stream, and across the bus when agents share memory.

Detection here is about the geometry of the substrate: belief-state manifolds, feature directions, subspace projections, write-stream spectra. The residual stream is the model, and its geometry is the signal.

The right tools come from mechanistic interpretability: representation geometry, sparse features, activation baselines. See Shai et al., Transformers Represent Belief State Geometry in their Residual Stream.

References

Classical security monitors the boundary. ABA monitors the substrate.

Statistics, control, geometry.