MCP
arXivarXiv
Preprint
Published: August 3, 2026
cs.AI

Real-Time Detection and Repair of LLM Agent Failures

Abstract
LLM agents fail mid-episode -- they loop, cascade tool errors, drift off goal, fabricate results, or silently absorb corrupted content -- and the standard remedy, judging every step with a second LLM, costs more than the agent itself. We ask how much detection is achievable from observable step telemetry alone, using monitors costing microseconds per step and trained only on healthy runs. On 2,823 committed agent episodes across three frameworks, three local models (qwen2.5 7b/3b, llama3.1 8b) and a commercial API (gemini-2.5-flash), a one-class echo-state-network ensemble with CUSUM alarms detects 0.71 of failures at a 5% false-alarm budget (AUROC 0.872). Its advantage over a memoryless baseline is a monotone function of post-onset horizon (+0.09 at <=3 steps, +0.40 at >=9), predicting its own failure region out of sample on AFTraj-2K. Ranking transfers with no retraining to two corpora from other groups (AFTraj-2K 0.745, ATBench 0.779). Monitors carry two burdens: a per-deployment healthy null (they do not transfer -- AUROC 0.527 cold against 0.885 recalibrated) and a residual false-alarm rate. We add a layer carrying neither: deterministic verification, which recomputes a run's stated total from the tool results it actually received and confirms every required call was made. Head-to-head it catches 60% of failures (96% with the coverage check) at 0 of 63 false positives against the monitor's 54% at 17%, transfers unchanged to llama3.1:8b (110 of 110 at 0 of 10), and trips on 0 of 1825 healthy episodes. Detection is then closed into repair: each flagged run is rolled back and re-run live, recovering 45% of failures against a 16% resampling control (p=0.0005) and lifting task success from 52% to 73% for about one extra model call per run. The system runs at ~200 microseconds per step, three orders of magnitude below a judge call. Code, traces and results are released.
0
AI overview
Reviews
Citation graph
References · 32
Structured
This preview uses generator v1; v2 is available

Overview

Addressing mid-execution runtime failures of LLM Agents and the problem that traditional step-by-step auditing with a second LLM costs more than the Agent itself, this paper presents a complete real-time failure detection and repair system with per-step processing latency below 1 millisecond.

The LLM Agent Runtime Failure Problem and Limitations of Existing Solutions

During task execution, LLM Agents exhibit several typical runtime failures, including execution logic falling into loops, cascading propagation of tool-call errors, gradual drift of behavior away from the initial goal, generation of fabricated results that do not exist, or silent absorption of tampered input content without any obvious error report.

The conventional solution for such failures is to introduce a second, independent LLM to audit and judge the Agent's results step by step; the overall running cost of this scheme can even exceed the cost of the Agent's main program, creating an obvious performance bottleneck.

Core Contributions of the Low-Overhead Real-Time Failure Detection and Repair System

The system's single-step processing pipeline can be kept within 1 millisecond in total, where the monitoring module takes about 200 microseconds to score a single step, and the telemetry adapter that feeds the monitoring module adds a median overhead of 674 microseconds—far below the cost of audit schemes that call a 7B-parameter large model for forward inference at every step.

Operating Mechanism of Failure Detection and Closed-Loop Repair

Through multi-round iterative design of the telemetry vector, the lightweight telemetry monitor gradually fills in the content blind spots of traditional schemes. The initial version contained only 43 features, covering basic runtime information such as hash embeddings, aggregated token surprise values, action one-hot encodings, latency, output length, and error flags. Later versions progressively added semantic channels for tool return embeddings and 8 new derived behavioral dimensions, finally expanding to 60 dimensions and supplementing 9 content-grounding dimensions, covering content-type features such as query-result similarity, result self-consistency, and JSON prefix validity that behavioral monitoring could not previously capture. Based on the content-gating mechanism over this telemetry channel, the detection rate for malformed-JSON failures can be raised from 0.07 under the memoryless baseline to 0.90. The design also adopts single-stream dual-budget thresholds combined with a training-maximum trigger, avoiding the problem where globally shared thresholds cause many failure samples to be missed.

The monitoring system has a clear deployment-calibration property: a monitoring model calibrated in one setting migrates across large-model backbones with failure detection performance barely above random; only after recalibration on the currently deployed backbone and task set does it reach usable detection accuracy. On short-episode datasets, the memoryless delta-Mahalanobis monitoring scheme outperforms the stateful echo state network baseline. In multi-class failure coverage in real deployment scenarios, loop-type failures have a detection-rate range of 0.48 to 1.00, tool-cascade failures range from 0.17 to 1.00, all corpora exhibiting goal-drift failures achieve stable detection of 0.66 to 0.86, and content-corruption failures, whose original detection rate was extremely low, are also specifically remedied through the newly added content-grounding telemetry channels.

The deterministic verification layer takes the suspected-failure signals output by the monitor and completes the final failure determination through hard-rule checks. From the measured results, at the generation temperature parameters commonly used in services, deterministic verification achieves a failure recall close to that of the behavioral monitor, but precision differs significantly: at temperature 0.2, deterministic verification produced no false positives at all, while the behavioral monitor's false-positive rate reached 17%; when the temperature was raised to 0.9, deterministic verification still maintained zero false positives, while the behavioral monitor's false-positive rate remained at 16%.

The rollback-and-rerun repair flow is triggered by the precise failure information output by the deterministic verification layer. Comparative experiments on different repair strategies show that a baseline performing indiscriminate rollback plus fresh resampling achieves only a 16% repair success rate. If the repair instruction explicitly states the specific check item that failed, without any additional numerical failure information, the repair success rate rises to 45%, significantly outperforming the other control strategies. Repair strategies carrying generic re-check instructions or carrying the specific numerical values of the failure also outperform the pure random resampling control group.

Performance Validation Results in Real Deployment Scenarios

On the test set of the public benchmark ATBench, the proposed ESN failure detection method reaches an AUROC of 0.779 and can identify 31.1% of unsafe run trajectories, whereas the comparison method Δ-Mahalanobis performs only at random level, dragging down the performance of all fusion strategies based on it. Detection performance varies markedly across failure modes: the system detects privilege-escalation and unverified-tool-output failures far better than inaccurate-information failures, indicating stronger capability in recognizing anomalies at the level of Agent execution actions, while blind spots in recognizing output-content-level anomalies remain to be filled by future work. You can look at the visualization that follows to directly compare the performance distributions of different detection methods on this benchmark and how they fit different failure categories.

Fig. 1: Primary monitor detection rates by failure category in real deployment scenarios, covering 9 real corpora; positions where a corpus does not contain the corresponding failure category are left blank, showing real failure coverage that simulators cannot provide

In full-scale testing covering 120 test scenarios, after deploying this closed-loop repair system, the overall task success rate rose from 52% to 73%, with 25 failures successfully repaired and no originally successful run broken. The baseline relying only on indiscriminate resampling recovered just 16% of failures. After Bonferroni multiple-comparison correction, only the repair strategy with precise failure localization shows a statistically significant performance improvement; the effects of the other generalized-repair and targeted-repair strategies are only indicative.

System Applicability Boundaries and Final Conclusions

The system's failure detection capability does not support direct cross-deployment transfer: testing requires that healthy baseline samples be collected under a service distribution fully identical to the target environment, covering all dimensions such as temperature parameters, tool sets, probing modes, and latency ranges. In a same-scale transfer across different model families, a directly reused monitor achieves a detection AUROC of only 0.527, near random guessing; only after recalibration in the target environment does the monitor's AUROC with the same configuration recover to 0.885. Even for deployment transfer within the same model family but with different parameter counts, directly reusing the monitor degrades performance to random level.

All monitoring schemes based on single-step anomalies cannot capture slowly developing goal-drift failures; only detection logic relying on trajectory self-consistency checks can cover such failure scenarios, which is a capability boundary common to all comparable schemes within the current scope of testing.

The system's failure repair coverage genuinely exists but has clear boundaries. In online testing with five failure-injection categories and five task seeds, all failures that trigger behavioral alerts automatically launch repair attempts, but only goal-drift failures can be repaired via retry. For scenarios where the tool layer itself is broken, retries only return the same erroneous result; in tool-cascade and loop failure scenarios the system cannot recover through retries, and the core value of intervention at that point is quickly terminating the abnormal session—in testing, loop traps triggered an exit 100% of the time at exactly 10 steps.

Rating
No ratings yet
Rate
Community rating
—
/ 5
No ratings yet
Rating
—
Soundness
—
Presentation
—
Contribution
—
Confidence
—
Discussion
Top
Newest
Questions
Replication
Author
No comments yet — be the first