Agent-SIREN

Detecting harmful agent trajectories from LLM internal representations

  • Agent safety
  • Guard models
  • Internal representations

Difan Jiao · Ashton Anderson

Harmful content and unsafe tool use

Agent trajectories can be unsafe because of what they say or do, and because an action is inconsistent with its authorization, tool schema, or preceding context.

Harmful content

The risk is expressed directly in the request or action.

User

“Issue this oxycodone prescription—no diagnosis needed.

Agent × tool send_approval(rx)

Unsafe tool use

The risk depends on the action’s relation to the preceding interaction.

User

“Reconcile this invoice from Acme—review only.

Agent × tool pay_invoice(“Acme”, $500)

Mechanistic findings

Matched trajectory pairs isolate one form of risk at a time and compare what can be read inside a guard with what its generated verdict expresses.

≈0

Cross-risk direction similarity

The directions for harmful content and unsafe tool use remain close to orthogonal through most layers. Same-risk split halves reach 0.81 similarity in Qwen and 0.87 in Llama.

Unsafe-tool-use rank accuracy reaches 0.98 inside the corresponding general-purpose backbones, even though all three evaluated guard outputs remain at or below chance.

Method: sparse cross-layer trajectory classification

Agent-SIREN renders the complete trajectory with the backbone’s chat template, reads its last-token state at every layer, and trains a compact classifier while keeping the LLM frozen.

Layer-wise sparse probing

An L1-regularized logistic probe is fit to the last-token representation at each layer.

Salient dimension selection

Within each layer, the smallest set of dimensions reaching the cumulative weight threshold is retained.

Cross-layer classification

The selected dimensions are concatenated and passed to a small MLP that predicts trajectory safety.

Experiments and results

Each of six trajectory-safety benchmarks is held out in turn. Agent-SIREN is trained on the remaining five, with no probe, head, threshold, or hyperparameter selected on the held-out benchmark.

0.78highest mean macro-F1
+0.04over same-backbone AgentDoG
5 / 6benchmarks led across both backbones
0.81after fine-tuning + Agent-SIREN
Agent-SIREN and open guard checkpoints across six held-out benchmarks Agent-SIREN on Qwen3-4B has the highest mean macro-F1 and leads four benchmarks. Across the two Agent-SIREN backbones, the method leads five of six benchmarks. Agent-SIREN reaches the highest mean macro-F1; complete values appear below.

Agent-SIREN on Qwen3-4B reaches 0.78 mean macro-F1, compared with 0.74 for AgentDoG-4B, the trajectory-specialized guard fine-tuned from the same backbone. The paired-bootstrap difference is significant at P < 10−5.

Comparison with full fine-tuning

With the same backbones, training trajectories, and held-out folds, Agent-SIREN on a frozen backbone matches full safety fine-tuning. Fitting Agent-SIREN on the fine-tuned model improves both backbones further.

Qwen3-4B
Frozen Agent-SIREN0.78
Full fine-tuning0.78
Fine-tuning + Agent-SIREN0.81
Llama-3.1-8B
Frozen Agent-SIREN0.75
Full fine-tuning0.75
Fine-tuning + Agent-SIREN0.77
View full benchmark tables

Open guard checkpoints

SystemR-JudgeTraceSafeATBenchASSE-SafASSE-SecAgentHarmMean
TF-IDF0.800.380.410.710.390.920.60
Qwen3Guard-4B0.430.350.360.430.500.790.48
LlamaGuard3-8B0.650.480.400.540.740.860.61
AgentDoG-4B0.920.430.610.800.780.920.74
Agent-SIREN · Qwen3-4B0.960.530.600.740.850.990.78
Agent-SIREN · Llama-3.1-8B0.880.430.630.750.840.990.75

Matched-data fine-tuning comparison

BackboneMethodR-JudgeTraceSafeATBenchASSE-SafASSE-SecAgentHarmMean
Qwen3-4BAgent-SIREN · frozen0.960.530.600.740.850.990.78
Full fine-tuning0.780.600.640.810.861.000.78
Fine-tuning + Agent-SIREN0.920.620.660.760.891.000.81
Llama-3.1-8BAgent-SIREN · frozen0.880.430.630.750.840.990.75
Full fine-tuning0.790.510.590.760.831.000.75
Fine-tuning + Agent-SIREN0.880.510.600.780.851.000.77

Training and inference efficiency

Agent-SIREN fits layer-wise probes and a small classification head without backpropagating through the backbone, and produces a verdict without token decoding.

0.90Mtrainable parameters
0.17GPU-hours for all six folds
40 mssingle-stream latency
26.5 / ssaturated throughput

Training

Agent-SIREN uses 0.17 GPU-hours for the complete six-fold Qwen3-4B protocol, compared with 7.0 GPU-hours for full fine-tuning.

Single-stream latency

Agent-SIREN takes 40 ms per trajectory, compared with 53 ms for AgentDoG and 215 ms for Qwen3Guard.

Saturated throughput

Agent-SIREN processes 26.5 trajectories per second, compared with 25.1 for Qwen3Guard and 17.6 for AgentDoG.

Early exit

A single-layer classifier first exceeds AgentDoG at layer 9. Exiting the truncated Qwen3-4B checkpoint at layer 23 reduces macro-F1 by 0.01 and increases saturated throughput from 26.5 to 41.1 trajectories per second.

41.1 / ssaturated throughput
−0.01macro-F1
+55%throughput