TraceGuard: Defending Multi-Turn Jailbreak Attacks via Prompt-Response Risk Signal Tracking

Hongyi Li, Yufei Wang, Chengxuan Zhou, Qinlin Xie, Yanting Chen, Jiawei Ye, Wu JieNeurIPS 2026

TL;DR

Jailbreaking a Large Language Model (LLM) doesn’t have to happen in one dramatic, obviously malicious prompt; attackers now play the long game, slowly steering benign-looking multi-turn conversations into dangerous territory. Because you can't tweak the internal weights of a closed-source API to stop this, the authors introduce TraceGuard, an external watchdog that maps conversations into geometric "intent directions" and tracks how risk accumulates turn by turn. It catches stealthy, unfolding attacks in under a second per turn without shutting down innocent chats.

What Problem Does This Paper Address?

Imagine a security guard who suffers from amnesia every 30 seconds. If someone walks past carrying a fuse, then later walks past carrying gunpowder, and finally walks past with a match, an amnesiac guard sees three harmless items. That is essentially how standard LLM safety filters operate on black-box APIs: they inspect single prompts and responses in isolation.

Attackers exploit this via multi-turn jailbreaks—using role-play, hypothetical scenarios, or subtle context-steering to spread harmful intent across an entire dialogue. Defending against this in a black-box setting (where you only see text going in and out, not the target LLM's internal parameters) hits three walls:

  1. Weak single-turn clues: Early turns genuinely look innocent (e.g., asking a historical question about a microbiologist before pivoting to bioweapon preparation).
  2. Cross-turn dependency: You have to connect the dots over time, and simply pasting the whole chat history together hits context limits and dilutes the signal.
  3. Shifting strategies: Attackers constantly invent new conversational arcs, breaking detectors trained on static patterns.

Methods

Instead of reading raw text with another giant guardrail LLM, TraceGuard uses a separate, frozen open-weight "auxiliary" LLM (like Llama3-8B) as a geometric sensor.

Figure 2: Overview of TraceGuard Framework.

Here is how the pipeline works:

  • Cross-View Risk Representation (The Sensor): Drawing on the Linear Representation Hypothesis—the idea that neural networks encode high-level concepts as linear directions in their hidden layers—the authors pre-calculate specific "intent directions" using reference data. For user prompts, they extract 15 harm directions (like theft or privacy violation). For model responses, they extract 3 behavioral directions (harmful compliance, safe refusal, and benign helpfulness). Every turn, the prompt and response are passed through the auxiliary encoder, and their cosine similarity to these directions yields compact 15D and 3D "risk vectors."
  • Risk Trajectory Modeling (TraceGuard-S): Two lightweight Gated Recurrent Units (GRUs)—standard sequence-modeling networks—ingest these prompt and response vectors turn by turn, maintaining a running memory of the conversation's trajectory. Crucially, the authors introduce a prefix-level trajectory regularization loss during training that penalizes risk spikes in benign chats while weighting later turns more heavily in jailbreaks, teaching the model how escalating danger feels.
  • Few-Shot Adaptation (TraceGuard-A): When a brand-new attack style emerges, TraceGuard-S freezes its weights. Using just 5 to 20 examples of the new attack, TraceGuard-A builds hierarchical "prototypes" (clusters of benign vs. harmful trajectory states) and trains a tiny linear fusion layer with a benign-aware margin so it adapts to the new threat without suddenly flagging normal users.

Datasets

The authors do not introduce a new dataset, instead assembling a comprehensive suite of 12 existing benchmarks (300 test interactions each), split into "seen" (used for training) and "unseen" (held out to test generalization):

  • Multi-Turn Jailbreaks: Seen: RedQueen, XTeam, SafeDialBench. Unseen: CoSafe, ActorAttack, Crescendo. (Plus AdvBench and XStest for initial single-turn analysis).
  • Multi-Turn Benign Dialogues: Seen: UltraChat, DailyDialog, Persona-Chat. Unseen: LMSYS-Chat, MTBench101, Glaive Function Calling (GFC).

Key Insights and Ideas

Before building TraceGuard, the authors mapped existing multi-turn attacks into their concept space and uncovered three neat geometric realities:

Characteristics of risk signals across single-turn and multi-turn interactions
  • Single turns overlap, trajectories diverge: In single-turn benchmarks, benign and harmful prompts sit in totally different neighborhoods. In multi-turn chats, individual turns overlap heavily—looking at one turn is a coin toss. However, if you plot the cumulative fluctuation (root mean square of risk changes) over five turns, jailbreaks steadily pull away from benign chats.
  • You need both sides of the conversation: Looking only at user prompts misses half the story; looking only at model responses is noisy because polite refusals and helpful answers get tangled up. Fusing both views creates the cleanest separation.
  • There is no single "jailbreak shape": Different attack algorithms leave completely different temporal fingerprints—XTeam's risk climbs steadily, while RedQueen's spikes early and ducks back down. A defense must be able to adapt to new trajectory shapes on the fly.

Key Results

Tested across open-weight target models (Llama3-8B, Qwen3-8B, Phi-4) and closed-source APIs (GPT-4o-mini, DeepSeek-V3.2, Gemini-2.5-Flash), TraceGuard dominates existing prompt detectors and dedicated guard models (like Llama-Guard-4-12B and Qwen3-Guard):

  • Accuracy: TraceGuard-S achieves ~90.6%–90.9% overall accuracy, beating the strongest baseline by 9.7%. Its harmful detection accuracy (H-ACC) jumps by 44.9% over single-turn baselines and 20.0% over multi-turn baseline NBF, while keeping benign accuracy (B-ACC) comfortably high at 96.4%.
  • Fast Adaptation: Feeding TraceGuard-A just 5 to 20 examples of unseen attacks boosts unseen H-ACC by 1.6%–6.2%, while benign accuracy drops by at most 1.2%.
  • Speed: Per-turn latency is 0.77 seconds—comparable to heavy guard models—but because it catches attacks early in the conversation, TraceGuard-A cuts total interaction-level latency down to 1.99 seconds (versus 6.29s for Qwen3-Guard).
  • Adaptive Attackers: Even when an attacker inserts 3 innocent turns to throw off the tracker, TraceGuard still catches 90%–100% of jailbreaks. When attackers actively query TraceGuard's scores to stay under the radar, their actual Attack Success Rate against the LLM plummets from 56.7% to 0%–10%.

Limitations and Future Work

The authors note three practical constraints:

  • Seed overlap: While the six jailbreak benchmarks use very different strategies, some draw from similar underlying harmful seed questions; broader sources would test generalization even harder.
  • Fixed concept vocabulary: TraceGuard relies on the auxiliary LLM's internal representations and 15 predefined harm categories. Subtle domain-specific, cross-lingual, or brand-new harm types might slip between those predefined axes.
  • Clean labels required: TraceGuard-A assumes the few-shot examples used for adaptation are cleanly and reliably labeled.

Future directions include extending trajectory tracking to multimodal jailbreaks (images/audio + text) and learning adaptive intent concepts automatically rather than relying on fixed harm categories.

Summary updated

Abstract

Large Language Models (LLMs) have made remarkable progress and are increasingly deployed as black-box API services. However, they remain vulnerable to jailbreak attacks that bypass safeguards and elicit harmful content, especially in multi-turn settings where harmful intent is gradually constructed over the interaction. Existing defenses primarily target single-turn scenarios or require access to model internals, making them insufficient against black-box multi-turn jailbreak attacks with weak single-turn discriminability, cross-turn dependency, and dynamic attack patterns. To bridge this gap, we first analyze harmful intent in multi-turn jailbreak interactions through representation-space risk signals inspired by the Linear Representation Hypothesis. Our analysis reveals that these signals are fragmented across prompts, responses, and turns, progressively evolve over the interaction, and exhibit attack-dependent temporal patterns. Motivated by this, we propose TraceGuard, an online black-box defense framework that detects multi-turn jailbreak attacks by tracking prompt and response risk signals as the interaction unfolds. Specifically, TraceGuard operates in two modes: TraceGuard-S captures cross-view risk representations and their cross-turn evolution, while TraceGuard-A further enables distribution-aware few-shot adaptation to dynamic attack patterns. Extensive experiments across multiple benchmarks and target LLMs demonstrate that TraceGuard achieves superior multi-turn jailbreak detection while preserving utility, maintaining efficiency, and generalizing to unseen attacks.
BibTeX
@inproceedings{li2026traceguard,
  author = {Hongyi Li and Yufei Wang and Chengxuan Zhou and Qinlin Xie and Yanting Chen and Jiawei Ye and Wu Jie},
  title = {{TraceGuard: Defending Multi-Turn Jailbreak Attacks via Prompt-Response Risk Signal Tracking}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=Fa3tAbEDkR},
}
Figure