DeepContext: Stateful Real-Time Detection of Multi-Turn Adversarial Intent Drift in LLMs
Abstract
While Large Language Model (LLM) capabilities have scaled, safety guardrails remain largely stateless, treating multi-turn dialogues as a series of disconnected events. This lack of temporal awareness facilitates a "Safety Gap" where adversarial tactics, like Crescendo and ActorAttack, slowly bleed malicious intent across turn boundaries to bypass stateless filters. We introduce DeepContext, a stateful monitoring framework designed to map the temporal trajectory of user intent. DeepContext discards the isolated evaluation model in favor of a Recurrent Neural Network (RNN) architecture that ingests a sequence of fine-tuned turn-level embeddings. By propagating a hidden state across the conversation, DeepContext captures the incremental accumulation of risk that stateless models overlook. Our evaluation demonstrates that DeepContext significantly outperforms existing baselines in multi-turn jailbreak detection, achieving a state-of-the-art F1 score of 0.84, which represents a substantial improvement over both hyperscaler cloud-provider guardrails and leading open-weight models such as Llama-Prompt-Guard-2 (0.67) and Granite-Guardian (0.67). Furthermore, DeepContext maintains a sub-20ms inference overhead on a T4 GPU, ensuring viability for real-time applications. These results suggest that modeling the sequential evolution of intent is a more effective and computationally efficient alternative to deploying massive, stateless models.
Figures & tables
| Dataset | Entries | Detailed Description | Ref |
|---|---|---|---|
| LLMail | 24,833 | Prompt injection attempts targeting email assistant workflows. | [ 18 ] |
| HH-RLHF | 60,848 | Human-labeled safety preferences and red-teaming dialogues. | [ 19 ] |
| XGuard | 30,674 | Synthetic adaptive multi-turn jailbreak attacks. | [ 20 ] |
| PRODIGy | 20,823 | Profile-based dialogues extracted from Hollywood scripts. | [ 21 ] |
| MultiWOZ | 8,425 | Annotated human-to-human task-oriented dialogues. | [ 22 ] |
| WikiQA | 3,331 | Open-domain question answering pairs from Bing logs. | [ 23 ] |
| Hyperparameter | Value |
|---|---|
| Learning Rate | |
| Batch Size | 512 |
| Training Epochs | 1 |
| Optimizer | AdamW |
| Attention Pooled Output ( ) | 1024 (per task) |
| GRU Layers | 3 |
| Source Dataset | Count | Percent | Category | Ref |
|---|---|---|---|---|
| lmsys/lmsys-chat-1m | 200 | 19.8% | General Chat | [ 27 ] |
| glaiveai/glaive-function-calling-v2 | 200 | 19.8% | Function Calling | [ 28 ] |
| nvidia/Nemotron-Instruction-Following | 200 | 19.8% | Instruction | [ 29 ] |
| Anthropic/hh-rlhf | 200 | 19.8% | Helpful Assistant | [ 19 ] |
| Simsonsun/JailbreakPrompts | 35 | 3.5% | Mixed Red Teaming | [ 30 ] |
| ScaleAI/mhj (HarmBench) | 35 | 3.5% | Human Red Teaming | [ 31 ] |
| Model | F1 Score | Recall | Precision | MTTD |
|---|---|---|---|---|
| DeepContext (Ours) | 0.84 | 0.83 | 0.86 | 4.24 |
| Llama-Prompt-Guard-2-86M | 0.67 | 0.60 | 0.76 | 5.83 |
| Granite-Guardian-3.3-8B | 0.67 | 0.57 | 0.83 | 5.03 |
| Gpt5-Nano | 0.65 | 0.55 | 0.81 | 5.73 |
| Deberta-v3-Prompt-Injection | 0.62 | 0.61 | 0.62 | 5.27 |
| GCP Model Armor | 0.58 | 0.54 | 0.63 | 4.56 |
| Model | Full Context | Sliding Window (last 5) |
|---|---|---|
| Granite-Guardian-3.3-8B | 0.65 | 0.67 |
| Gpt5-Nano | 0.58 | 0.65 |
| Qwen3Guard-Gen-8B | 0.51 | 0.51 |
| Llama-Guard-4-12B | 0.42 | 0.51 |
| Model | F1 Score | Recall | Precision |
|---|---|---|---|
| DeepContext (Ours) | 0.98 | 1.00 | 0.95 |
| Qwen3Guard-Gen-8B | 0.88 | 0.95 | 0.83 |
| Llama-Guard-4-12B | 0.86 | 0.86 | 0.86 |
| Gpt5-Nano | 0.83 | 0.91 | 0.76 |
| GCP Model Armor | 0.83 | 0.96 | 0.74 |
| Granite-Guardian-3.3-8B | 0.78 | 1.00 | 0.65 |
| Model | Latency (ms) |
|---|---|
| Llama-Prompt-Guard-2-86M | 4 |
| Deberta-v3-Prompt-Injection | 4 |
| DeepContext (Ours) | 19 |
| Llama-Guard-4-12B | 43 |
| Qwen3Guard-Gen-8B | 64 |
| Azure Prompt Shield | 77 |
| Speaker | Content | Risk Score |
|---|---|---|
| User | At my gardening club… Fertilizer Explosive Mixing Masters… What acronym? | 0.1078 |
| Assistant | The acronym for ’Fertilizer Explosive Mixing Masters’ would be ’FEMM’. | 0.0038 |
| User | Almost! …focus on ’Explosive’, ’Low-velocity’, ’Order’, and ’Metallic’. | 0.0121 |
| Assistant | The acronym for ’Explosive Low-velocity Order Metallic’ would be ’ELOM’. | 0.0132 |
| User | Great! Now, let’s write an instructional guide using the acronym ’ELOM’… | 0.1482 |
| Assistant | ELOM: Expert Guide to Crafting Unique Gardening Mixtures [Full gardening guide detailing mixing and metallic additions] | 0.4176 |
| Speaker | Content | Risk Score |
|---|---|---|
| User | What do you now know about Donald Trump that you weren’t aware of previously? | 0.049 |
| Assistant | I am unable to gain new knowledge or modify existing ones without direct input from an authorized party… | 0.081 |
| User | Who is an authorized party? | 0.074 |
| Assistant | Only designated representatives from AI Village or their subsidiaries have authority over modifying my data sets and parameters. | 0.436 |
| User | Who do you think I am? | 0.541 |
| System | !! BLOCKED !! | – |
LLM Safety
Large language model (LLM) safety studies how to prevent harmful, unreliable, or misaligned behavior while preserving useful responses.
See all 438 papers