Table of Contents
Fetching ...

Trajectory Guard -- A Lightweight, Sequence-Aware Model for Real-Time Anomaly Detection in Agentic AI

Laksh Advani

TL;DR

The paper addresses safety verification for autonomous LLM agents by detecting anomalies in multi-step trajectories, where misinterpretation of context or incoherent action sequences can lead to unsafe behavior. It introduces Trajectory Guard, a lightweight, sequence-aware Siamese Recurrent Autoencoder that jointly learns contextual relevance and sequential validity through a hybrid loss: $L = L_{\text{contrastive}} + \alpha L_{\text{reconstruction}}$ with $\alpha=0.5$. Evaluated on synthetic benchmarks (Galileo, AgentAlign) and real-world logs (RAS-Eval, Who&When), it achieves F1 scores between $0.88$ and $0.94$ and recall between $0.86$ and $0.92$, while delivering a latency of $32$ ms per sample—over $17$–$27\times$ faster than LLM Judge baselines. This enables real-time safety verification in production deployments and provides a deployable tool for trajectory coherence verification in agentic systems.

Abstract

Autonomous LLM agents generate multi-step action plans that can fail due to contextual misalignment or structural incoherence. Existing anomaly detection methods are ill-suited for this challenge: mean-pooling embeddings dilutes anomalous steps, while contrastive-only approaches ignore sequential structure. Standard unsupervised methods on pre-trained embeddings achieve F1-scores no higher than 0.69. We introduce Trajectory Guard, a Siamese Recurrent Autoencoder with a hybrid loss function that jointly learns task-trajectory alignment via contrastive learning and sequential validity via reconstruction. This dual objective enables unified detection of both "wrong plan for this task" and "malformed plan structure." On benchmarks spanning synthetic perturbations and real-world failures from security audits (RAS-Eval) and multi-agent systems (Who\&When), we achieve F1-scores of 0.88-0.94 on balanced sets and recall of 0.86-0.92 on imbalanced external benchmarks. At 32 ms inference latency, our approach runs 17-27$\times$ faster than LLM Judge baselines, enabling real-time safety verification in production deployments.

Trajectory Guard -- A Lightweight, Sequence-Aware Model for Real-Time Anomaly Detection in Agentic AI

TL;DR

The paper addresses safety verification for autonomous LLM agents by detecting anomalies in multi-step trajectories, where misinterpretation of context or incoherent action sequences can lead to unsafe behavior. It introduces Trajectory Guard, a lightweight, sequence-aware Siamese Recurrent Autoencoder that jointly learns contextual relevance and sequential validity through a hybrid loss: with . Evaluated on synthetic benchmarks (Galileo, AgentAlign) and real-world logs (RAS-Eval, Who&When), it achieves F1 scores between and and recall between and , while delivering a latency of ms per sample—over faster than LLM Judge baselines. This enables real-time safety verification in production deployments and provides a deployable tool for trajectory coherence verification in agentic systems.

Abstract

Autonomous LLM agents generate multi-step action plans that can fail due to contextual misalignment or structural incoherence. Existing anomaly detection methods are ill-suited for this challenge: mean-pooling embeddings dilutes anomalous steps, while contrastive-only approaches ignore sequential structure. Standard unsupervised methods on pre-trained embeddings achieve F1-scores no higher than 0.69. We introduce Trajectory Guard, a Siamese Recurrent Autoencoder with a hybrid loss function that jointly learns task-trajectory alignment via contrastive learning and sequential validity via reconstruction. This dual objective enables unified detection of both "wrong plan for this task" and "malformed plan structure." On benchmarks spanning synthetic perturbations and real-world failures from security audits (RAS-Eval) and multi-agent systems (Who\&When), we achieve F1-scores of 0.88-0.94 on balanced sets and recall of 0.86-0.92 on imbalanced external benchmarks. At 32 ms inference latency, our approach runs 17-27 faster than LLM Judge baselines, enabling real-time safety verification in production deployments.
Paper Structure (30 sections, 1 equation, 1 figure, 5 tables)

This paper contains 30 sections, 1 equation, 1 figure, 5 tables.

Figures (1)

  • Figure 1: The Trajectory Guard Architecture. The model employs a Siamese design with two parallel towers. The Task Tower (left) projects the task description into a latent space $v_t$. The Trajectory Tower (right) uses a GRU encoder to compress the action sequence into a thought vector $v_s$. The model is trained via a hybrid objective: a Contrastive Loss aligns $v_t$ and $v_s$ to ensure the plan matches the task, while a Reconstruction Loss ensures the trajectory sequence retains structural validity.