Reassembling Distributed Risk: Trajectory-Conditioned Action Generation for Multi-Turn Agent Safety

Yanbo Dai, Zhenlan Ji, Zongjie Li, Shuai WangarXiv 2026

TL;DR

Tool-using LLM agents are highly vulnerable to multi-turn attacks where a malicious goal is stealthily split across seemingly innocent steps. This paper introduces ReDiR (Reassembling Distributed Risk), a defense that compresses an agent's interaction history into a compact "safety latent" representation before each action, steering the agent to safely abort if a distributed risk is detected without relying on slow external checkers.

What Problem Does This Paper Address?

Modern LLM agents don't just chat—they act. They use external tools to modify files, execute terminal commands, and interact with APIs. This capability opens the door to multi-turn decomposition attacks. Instead of asking an agent to execute a blatantly malicious command all at once, an attacker breaks the command down into individually harmless pieces across multiple turns.

As shown in Figure 1(a), an agent might be asked to create a helper function in turn 1, define a target path in turn 2, and execute them together in turn 3. Individually, each step looks completely benign. The malicious intent only becomes apparent when you look at the accumulated trajectory.

Figure 1: (a) The adversary distributes a destructive command across helper functions and composes them in the final turn. (b) ReDiR re-encodes the trajectory before each action; once the harmful objective becomes apparent, the safety latents steer the model to FINISH instead of executing the command.

Existing defenses fall short: they either inspect actions after they are generated (which makes them slow and highly dependent on specific tool formats) or they use expensive auxiliary LLM judges to review the entire chat history at every single turn. The challenge is to build a defense that catches these distributed risks during the generation process, transfers across different tools, and doesn't tank the agent's speed or performance on benign tasks.

Methods

ReDiR operates directly inside the model's latent representation space using a three-stage pipeline:

  1. Offline Action Supervision Construction: To teach the model what a "safe" action looks like, the authors use same-model cross-view supervision. They show the base model a "collapsed view" of the task where the hidden malicious objective is made explicit. Under this clear view, the model generates safe target actions (like a protocol-valid FINISH command).
  2. Trajectory-Conditioned Safety Training: A safety encoder (sharing the same backbone as the base model but adapted with lightweight LoRA) uses a small set of learned "latent queries" to compress the multi-turn trajectory prefix into a compact safety representation. This representation is injected into the frozen base model. The encoder is trained to maximize the likelihood of the safe target actions, while a regularization loss ensures it doesn't disrupt benign behavior.
  3. Latent-Guided Action Generation: During deployment, before every single action, the live trajectory is encoded into these safety latents and injected into the base model. If a risk is detected, the latents steer the model to safely terminate execution.
Figure 2: Illustration of the ReDiR pipeline.

Datasets

The authors evaluated ReDiR on two major agent safety benchmarks:

  • MT-AgentRisk: Features 365 tasks across 9 realistic tool environments (Filesystem, Terminal, PostgreSQL, Notion, and five web environments). ReDiR was trained on just 55 tasks from the Filesystem domain and tested on the remaining tasks and 8 entirely held-out domains to test cross-tool transfer.
  • AgentDojo: A benchmark focused on indirect prompt injection attacks via untrusted tool observations, used here to test out-of-distribution generalization.

Key Insights and Ideas

  • Safety is in the Latents: Harmful intent often leaves traces in a model's internal hidden states even when the surface text looks benign. ReDiR exploits this by aggregating risk evidence directly in the latent space before text generation even starts.
  • Same-Model Alignment Wins: Instead of using a massive external teacher model (like GPT-4) to generate safety targets, using the same base model under an explicit view produces better results. The targets remain perfectly aligned with the model's native reasoning and action-formatting style.
  • Defense Can Speed Things Up: Usually, security adds overhead. But by empowering the model to recognize a multi-turn attack early and emit a FINISH token, ReDiR drastically cuts down the end-to-end runtime on malicious tasks by avoiding useless subsequent turns.

Key Results

  • High Effectiveness: ReDiR reduced the Attack Success Rate (ASR) from over 48–65% down to below 8% across three model families (Qwen3.5-9B, Ministral-3-8B, Gemma-4-E4B), substantially outperforming existing defenses like MAGE and ToolShield.
  • Zero-Shot Domain Transfer: Despite only being trained on the Filesystem domain, ReDiR successfully transferred its safety capabilities to 8 unseen domains (like Notion, GitLab, and Reddit), keeping the ASR under 7%.
  • Zero Over-Refusal: ReDiR achieved a 0% False Positive Rate (FPR) on benign tasks, meaning it doesn't cause the agent to over-refuse legitimate user requests.
  • Ultra-low Overhead: Because it reuses the base model backbone, it requires only 1.3 to 3.2 MiB of additional GPU memory. Furthermore, it reduced end-to-end task latency on harmful tasks by an average of 53.3% due to early safe termination.

Limitations and Future Work

  • Empirical Nature: As an empirical defense, ReDiR might still miss highly novel, unseen attack strategies or complex adaptive bypasses.
  • White-Box Access Required: The defense requires white-box access to the base model to inject latent representations, making it unsuitable for closed-source, API-only models.
  • Future Directions: The authors suggest combining ReDiR with system-level defenses like sandboxing, least-privilege access, and execution monitoring for a comprehensive defense-in-depth architecture.

Summary updated

BibTeX
@misc{dai2026reassembling,
  author = {Yanbo Dai and Zhenlan Ji and Zongjie Li and Shuai Wang},
  title = {{Reassembling Distributed Risk: Trajectory-Conditioned Action Generation for Multi-Turn Agent Safety}},
  year = {2026},
  eprint = {2608.25711},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2608.25711},
}
Figure