Appearance
Five papers, one question: where do you put the detector?
Bolting a safety classifier onto an LLM takes an afternoon. Keeping that classifier accurate, cheap, and hard to fool takes the rest of the quarter.
I read five papers this week that approach LLM security from five different angles: jailbreak detection (JDPI), activation monitoring (GateWatch), prompt-injection purple-teaming (PIPETTE), function-level vulnerability detection (CFVul), and attack-path analysis for power grids. They don't share a codebase or a benchmark. They share a failure mode. In each case, the detector looks strong on the metric it was tuned against and degrades the moment that metric stops matching the thing you actually care about.
Mapped onto a real agent deployment, the five pieces cover five different surfaces:
The order matters. Input filtering protects the front door. Injection defense protects the tool channel. Activation probes watch the model's internals when both of those miss. Everything downstream is consequence management.
Layer one: take the classifier out of the jailbreak path
JDPI drops the downstream classifier. You contrastively fine-tune an encoder on binary safe/unsafe labels, build one prototype per class, and classify a new prompt by whichever prototype it lands closer to in embedding space. No separate classifier split, no extra head to retrain when the encoder drifts.
The label budget is where most safety pipelines quietly die. Skipping the classifier's training split means JDPI needs fewer labeled examples than the baseline (Method A) for the same job, and it still lands within 0.017 ROC-AUC of that baseline across all four benchmarks, beating it slightly on one.
| Approach | Labels needed | ROC-AUC vs. Llama Guard 3-8B | Serving cost |
|---|---|---|---|
| Downstream classifier (Method A) | binary labels plus a separate classifier split | reference point; JDPI stays within 0.017 | encoder plus classifier head |
| JDPI, same encoder | binary labels only | within 0.017 of Method A | encoder only |
| JDPI with dataset-specific adaptation | binary labels only | +0.173 to +0.310 | encoder only |
| Llama Guard 3-8B (released) | n/a | baseline | a second 8B model in the fleet |
Contrastive fine-tuning is doing real work here: 9.1 to 18.0 percentage points of accuracy across the four benchmarks. A swing that size separates a filter you can run in front of production traffic from one you can't. And an 8B guard model is a second GPU in your serving fleet, so a 0.17 to 0.31 ROC-AUC gap over Llama Guard 3-8B means the small prototype encoder ranks harmful prompts better on these sets while costing a fraction of the memory.
The multi-turn result is the one I'd test first in my own stack. On the TomGibbs replay set, feeding accumulated user history into the prototype distance beats scoring the current turn alone. That tracks with what I've seen: real jailbreaks spread across five or six turns, so a turn-local detector reads a harmless conversation and misses the payload entirely.
Cross-dataset transfer is weaker but still pointed the right way. Across 12 directed transfers, JDPI beats the classifier by 1.59 percentage points on average. Small, yet prototype geometry appears less welded to one dataset's phrasing than a trained head is.
Layer two: make the activation probe cheap enough to run always
Activation probes sit closer to the model's actual decision than any prompt filter can. The problem has always been the bill. Raw-activation probes give you a number with no readable explanation. Sparse-autoencoder probes give you interpretable features, but they lean on additive classifiers and full SAE encoders, so memory grows with the feature dictionary.
GateWatch compresses the whole decision rule into explicit Boolean logic over a handful of binarized SAE features. Across 24 tasks on Gemma-2-9B it hits 80.49% mean test accuracy using an average of 3.8 SAE features and 3.5 logic gates per probe. That's 1.17 percentage points below a full 16K-feature SAE probe, and it matches or beats that probe on 10 of the 24 tasks.
3.5 logic gates is small enough to read out loud in a design review. That changes who can own the monitoring system. A security engineer can audit a Boolean circuit over four named features without asking an ML team to interpret a dense classifier.
The memory number is the headline: 99.98% reduction in probe memory. A probe fleet stops being a GPU-resident cost and becomes a rounding error next to KV cache. GateWatchServe backs that up by computing only the selected features, streaming their binary values across layers during inference, and evaluating multiple classifiers in parallel through compact lookup tables. Inside vLLM, 1,000 concurrent multi-layer, multi-token GateWatch classifiers retain 97 to 98% of baseline throughput and 99.8% of KV-cache capacity.
1,000 concurrent probes at 97% throughput means monitoring every request instead of a sampled slice. That's the difference between an audit trail and a smoke detector.
Quick Take: every paper in this set wins by removing something from the critical path, whether that's a classifier, a dense encoder, or a reward that only counts wins.
Red-teaming that actually hardens the agent
PIPETTE starts from an uncomfortable observation about the purple-team loop. High attack success rate during red-teaming does not buy you robustness after adversarial training. The team behind it took two state-of-the-art RL red-teamers, RL-Hammer and PISmith, and found both suffering from mode collapse: they keep discovering variations of the same attack strategy, and those extra successes add nothing to the defender.
A red team that finds the same bug 400 times has found one bug.
That's a metric design problem. RL rewards the generator for winning, and winning is cheap once a single strategy works. PIPETTE replaces the flat reward with a dictionary-learning-based reward that pays for coverage of distinct attack strategies, then pairs it with an on-policy adversarial training pipeline built for indirect prompt injection. The agent learns to resist hijacking while still finishing the user's task.
| Signal | What it tells you | Where it misleads |
|---|---|---|
| Attack success rate during red-teaming | how often the red team wins | climbs while strategy diversity collapses |
| Post-training ASR on discovered attacks | how well the hardening worked | says nothing about attacks nobody generated |
| Benign task utility after hardening | whether the agent still works | hides the latency and compute cost of the defense |
On AgentDojo and ASB, PIPETTE produces defenders with near-zero attack success on static attacks that also hold up against strong adaptive attacks, with benign task utility close to the undefended baseline. The adaptive-attack result carries the weight. Static-attack numbers are table stakes once your attacker has read the paper.
The practical lesson generalizes past prompt injection. If you run any adversarial training loop, measure strategy diversity in the attack set before you trust the robustness number it produces.
The code detector that gets fooled by function length
Fix reversal is a nasty failure mode for function-level vulnerability detectors. The detector assigns a higher vulnerability probability to a patched function than to the vulnerable version it replaced. If you're gating merges on that score, you are suppressing security patches.
CFVul traces the cause to a length shortcut. Fixes usually lengthen functions, and vulnerability probability rises with function length even when content is held fixed. The detector learned "long function, suspicious" and applied it to every patch that adds a null check.
The fix has three parts. Sliding-window encoding covers the full function so fix information past the truncation boundary survives. A training-time content constraint forces the vulnerable version to score higher when both versions are fed at a common length. An inference-time length constraint averages probabilities over fixed reference lengths, which dampens the effect of the real length delta.
On PrimeVul, CFVul reaches 59.4% PairRank, above the existing methods it's compared against. The number that matters is the hard subset: for fixes that lengthen a function by more than 15%, PairRank goes from CodeBERT's 25.8% to 48.4%. A coin flip beats a near-guaranteed miss, and length-inflating patches are exactly the ones a naive detector buries. The method also improves across four additional models and three additional datasets, and it only needs fix pairs you already have in git history, so retrofitting it onto an existing detector costs nothing in new labeling.
The numbers that stuck with me
0.173 to 0.310: JDPI's ROC-AUC improvement over Llama Guard 3-8B across four benchmarks, using a small contrastive encoder instead of a second 8B model.
99.98%: probe memory reduction from GateWatch's Boolean circuits, at a cost of 1.17 percentage points of accuracy versus a full 16K-feature SAE probe.
3.5: average logic gates per GateWatch probe, which is small enough for a human to audit the decision rule directly.
25.8% to 48.4%: CFVul's PairRank on fixes that grow a function by more than 15%, against CodeBERT.
1.59 points: average accuracy gain for JDPI over a trained classifier across 12 cross-dataset transfers.
75 to 85%: runtime reduction from LLM-guided attack-path analysis versus the fusion baseline on the IEEE 14-bus system.
Grid attack paths, ranked by physics instead of vibes
The smart grid paper asks a different question: given a power system's topology and threat model, which attack paths actually hurt? Topology-only methods capture connectivity but have no adversarial reasoning. Simulation-based cascading-failure models are accurate and too slow for rapid what-if analysis on evolving scenarios.
The framework uses cascading-failure impact rankings as physics-grounded ground truth, then has an LLM walk the system topology through STRIDE and MITRE ATT&CK threat modeling. Structured threat modeling moves the critical-node overlap@3 from roughly 33% up to as high as 100%, with node-level similarity reaching 65% and full path-level alignment reaching 48%.
Read the three numbers as a ladder. Overlap@3 of 100% means the LLM-driven threat model stops pointing at irrelevant buses when you ask for the top three. Node similarity of 65% means the intermediate steps are roughly right. Path alignment of 48% is the honest one: half the complete attack sequences still differ from the physics reference. For triage and prioritization, that's useful. For certification, it isn't.
The runtime result is what makes it deployable: 75 to 85% faster than the fusion baseline on the 14-bus system. On a larger grid with hundreds of buses, a speedup that size is the difference between reviewing a scenario in a meeting and queuing it overnight.
What trips people up
Tuning the detector on the deployment distribution and calling it general. JDPI's gain over Llama Guard 3-8B needs dataset-specific adaptation. Strip that away and the cross-dataset advantage drops to 1.59 points. Benchmark your filter on prompts from your own product.
Optimizing red-team ASR as the objective. RL-Hammer and PISmith both produce high ASR through collapsed policies, and the resulting adversarial training buys little. Track distinct attack strategies per 100 generations before you trust the robustness claim.
Forgetting the tool channel. A jailbreak filter on user input never sees the poisoned search result or the injected README that your agent just fetched. Indirect prompt injection arrives as data, and input classifiers are looking at instructions.
Running dense SAE probes on every token of every request. A 16K-feature encoder per layer per token is a memory bill that shows up as reduced batch size. If you need per-request coverage, binarize the features you actually use and compute only those.
Trusting a function-level vuln detector without checking fix reversal. Compute PairRank on a sample of your own fix pairs first. If patched functions score higher than their vulnerable parents, the detector has learned length, and your CI gate is filtering the wrong diffs.
One thing to remember
Every paper here validates its detector against a reference that someone had to define: Llama Guard's label schema, cascading-failure rankings, fix pairs from a specific corpus, the ASB attack set. Your deployment's definition of unsafe will differ from all of them, and the gap between the reference and your reality is where incidents live. The detector's accuracy number is a claim about someone else's data.
The bottom line: three deployment shapes, three defenses
If your agent reads untrusted web or tool content, spend the budget on purple-teaming and adversarial training. Indirect injection enters through the data channel, which input filters don't cover. PIPETTE-style training that rewards attack diversity is the only thing in this set that produces defenders holding near-zero ASR against adaptive attacks.
If you're GPU-constrained and want per-request monitoring, ship Boolean SAE probes. GateWatch at 3.8 features and 3.5 gates per probe costs 1.17 points of accuracy against a full 16K-feature encoder and saves 99.98% of probe memory. Add the vLLM serving path and you keep 97% throughput at 1,000 concurrent classifiers.
If you gate merges on a code vulnerability score, measure fix reversal before anything else. Length-inflating patches are your worst case, and on that subset the best result here is 48.4% PairRank. Watch this space closely: contrastive prototype methods like JDPI are cutting the labeling requirement fast, and I'd expect label-light jailbreak detection folded into guard models inside a year.