Safe Actions Can Form Unsafe Traces: Benchmarking and Shielding Compositional Emergent Risk in AI Agents

Zhongze Wu, Xiu Su, Hongyan Xu, Yichao Cao, Yueyi Luo, Jun LongNeurIPS 2026

TL;DR

Buying charcoal, potassium nitrate, and sulfur on three separate errands looks completely innocent in isolation—until you put them in the same bowl. Modern AI agents suffer from this exact blind spot: they routinely execute chains of individually harmless actions that combine over time into dangerous outcomes. This paper formalizes this "compositional emergent risk," proves it is pervasive across every major frontier LLM, and builds RiskShield—a runtime safety monitor that catches dangerous trajectories before they finish, swapping out risky endings without throwing away the safe, useful work already done.

What Problem Does This Paper Address?

When LLMs were just chatbots, safety meant checking a prompt and a single text response. Today, AI agents use browsers, code interpreters, and APIs to execute multi-step workflows. Current safety guardrails (like LlamaGuard or ShieldGemma) mostly inspect one message or tool call at a time.

The authors identify Compositional Emergent Risk (CER): a failure mode where every individual step passes a safety check, yet their linked outputs across time create a major hazard. For example, querying an employee directory, fetching a travel itinerary, and reading badge access logs are each mundane administrative actions—but linking them by ID deanonymizes and tracks a sensitive target.

Figure 2: Why per-action safety fails for compositional emergent risk. (a) A trace can pass individual safety review while cross-step dependencies create an unsafe composition. (b) Risk decomposition over CER-5 shows that local harm remains modest, while interaction risk drives the trace above the safety threshold. (c) Safe and harmful histories can share a monitor observation; a risk-sufficient state summary can remove this information barrier even at k = 1.

To measure how often this happens, the authors define the Compositionality Gap (CG): the percentage of multi-step hazardous traces (made entirely of individually safe actions) that an agent or safety filter allows to proceed. Furthermore, they prove a fundamental information barrier: if a safety monitor only looks at a narrow window of recent steps without retaining a "risk-sufficient" summary of the past, safe and harmful histories can look identical, making detection mathematically impossible.

Methods

Rather than treating safety as a binary "allow or abort" filter on single actions, the authors model total trace risk as the sum of local per-action harm plus cross-step interaction risk. To control this at test time, they introduce RiskShield, a three-part runtime defense:

  1. Conformal Risk Calibration (CRC): Using held-out calibration trajectories, CRC learns what a "normal" evolving trace looks like. A lightweight predictor estimates interaction risk between action pairs (using tool categories, data-flow overlap, and distance), and conformal prediction sets a statistically calibrated threshold for when a trajectory becomes abnormally risky.
  2. Predictive Safety Monitoring (PSM): Before committing to a proposed next action, PSM simulates or sandboxes the one-step continuation to check if it crosses the calibrated risk boundary. To stay fast, it only runs full checks near "bifurcation points" where trajectories might turn dangerous.
  3. Task-Preserving Safe Fallback (TPSF): Binary refusals are frustrating because they destroy all prior useful work. If PSM flags a continuation as risky (but not catastrophic), TPSF searches for a safer alternative action that still advances the user's goal—preserving the safe prefix while replacing the toxic suffix.

Datasets

  • CER-Bench (New): A controlled, long-horizon benchmark containing 440 tasks and 19,525 actions spanning 5 to 500 steps (at 500 steps, a trace induces over 79 million candidate risk compositions). It covers five risk domains, safe controls, and two risk mechanisms: Split-Goal (risk spikes sharply when pieces connect at the end) and Accumulation (risk builds gradually via small repeated effects).
  • External Benchmarks: R-Judge, ToolEmu, and OS-Harm are used to test out-of-distribution transferability.

Key Insights and Ideas

  • Verbal caution is an illusion of safety: In 86.1% of cases where agents executed an unsafe workflow, they actually generated "caution language"—explicitly noting potential risks in their reasoning—yet proceeded to execute the harmful steps anyway.
  • Step-by-step blinders: Agents are much worse at spotting compositional risk in realistic stepwise execution (seeing one action at a time) than when shown the entire plan at once. On Grok 4.1, moving from global to stepwise evaluation caused its failure rate (CG) to jump by over 55 percentage points on long-horizon tasks.
  • Risk clusters at critical hops: Across 5-step risk tasks, marginal risk concentrates in an average of just 1.75 "critical hops" (74.9% near the final steps). Because danger spikes at predictable junctions rather than uniformly, runtime monitors don't need to run expensive LLM judges on every single step.

Key Results

CER is pervasive across 15 LLM agents, while RiskShield drops CG to 0.0% with high utility.

Figure 1: CER is pervasive across frontier agents, while calibrated runtime shielding removes observed risk with high utility and efficiency. (a) CG across 15 LLM agents on CER-BENCH. Every tested model exhibits non-zero CG, with mean CG 82.2% and the best model still at 44.4%. (b) RISKSHIELD eliminates observed CER on held-out CER-5 models, reducing CG to 0.0% while preserving 78.4% task completion. It also achieves 63.3% zero-extra-call protections and source- related transfer (the graphic uses target recalibration).
  • Universal vulnerability: Across 15 frontier and open-source models on CER-5, every single agent exhibited a non-zero CG, averaging 82.2%. Claude Sonnet 4.6 fared best (44.4% CG), while 11 of 15 models exceeded 80% CG (including GPT-5.5 at 96.3% and DeepSeek-V3.2 at 100.0%).
  • Existing guardrails miss the forest for the trees: Single-action classifiers failed almost completely (LlamaGuard-3 left 98.2% CG; ShieldGemma left 100.0%). Published agent-safety methods like R-Judge lowered CG to 18.3%, but yielded 0.0% task completion on blocked traces because they abort entire workflows.
  • RiskShield hits the sweet spot: Across 7 held-out models (763 evaluations), RiskShield reduced mean CG from 69.9% down to 0.0%, while preserving 78.4% step-level task completion (beating a cumulative-threshold baseline at 53.2%). Better yet, 63.3% of tasks required zero extra API calls.

Limitations and Future Work

While the authors defer their dedicated limitations and future directions section to Appendix D.6 (not included in the main text), two key constraints are explicitly noted in the paper:

  • Tractable approximation of harm: The mathematical formulation models cross-step risk using pairwise action interactions. The authors note this is a tractable approximation rather than a universal decomposition of complex, higher-order multi-action harms.
  • Scope of formal guarantees: RiskShield's theoretical safety guarantee applies to its calibrated risk score under the statistical assumption of exchangeability (that future traces resemble calibration traces)—which does not automatically guarantee zero real-world risk under severe distribution shifts.

Summary updated

Abstract

Large language model agents increasingly act through tools, browsers, code interpreters, and external APIs, turning safety from a single-output problem into a trace-level problem. We identify compositional emergent risk (CER), a failure mode where individually safe actions interact across time to produce unsafe outcomes. We characterize an information barrier: monitors cannot distinguish safe and harmful histories that yield the same observation. To study this failure systematically, we introduce CER-Bench, a controlled long-horizon benchmark with 440 tasks and 19,525 actions across 5–500 steps, spanning five risk domains and two compositional mechanisms. At the largest tier, each trace induces a 79M+ candidate risk-composition search space. Across 15 frontier and open-source LLM agents, every model exhibits a non-zero compositionality gap (CG), ranging from 44.4% to 100.0% with a mean of 82.2%. Moreover, 86.1% of compliant executions contain caution language yet still proceed, showing that verbal risk awareness does not reliably prevent unsafe composition. We introduce RiskShield, a conformal-calibrated runtime shield that learns trace-risk boundaries, evaluates planned continuations before commitment, and substitutes risky suffixes while preserving safe prefixes. On 7 held-out CER-Bench models, RiskShield reduces mean CER-5 CG from 69.9% to 0.0%, with no shielded pass observed in 763 evaluations, while preserving 78.4% step-level task completion. It outperforms cumulative-threshold, sliding-window, full-trace, and published safety baselines, with 63.3% of tasks requiring no extra API call and additional robustness across longer traces, risk domains, and external agent-safety benchmarks.
BibTeX
@inproceedings{wu2026safe,
  author = {Zhongze Wu and Xiu Su and Hongyan Xu and Yichao Cao and Yueyi Luo and Jun Long},
  title = {{Safe Actions Can Form Unsafe Traces: Benchmarking and Shielding Compositional Emergent Risk in AI Agents}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=I49ieEOieb},
}
Figure