arXiv:2610.12375cs.AIOct 2026

Manuscript Offprint

arXiv:2610.12375

OnTrack: Real-Time Monitoring and Intervention in LLM Agent Trajectories via Streaming Structure-Aware Optimal Transport

Babak Barazandeh, Connor Swanson, Chinmay Kulkarni, Nikhil Mungel

Abstract

Agents are deployed in a wide range of applications ranging from trip planners and stock trading to IT incident triage. In most of these applications, agents, by relying on the LLM, work autonomously with minimal rule-based safeguarding or no supervision, which results in cost and safety issues due to irreversible actions taken by agents. Recent works have tried to resolve these issues by either using another safeguard agent to monitor its behavior or doing a post-hoc evaluation of the logs. The first adds cost and latency to every step; the second delivers its verdict after the run, when the tokens are already burned and the damage done. To overcome this issue, we propose ONTRACK, a streaming monitoring mechanism that, as the agent progresses in its task, compares its steps and the dependencies between them against recorded successful runs and alerts the user of potential issues or blocks the agent, taking about a millisecond per step. We study this problem in three regimes of decreasing access: full reference access (where we have access to historical runs of the task or similar variants, as well as tool schemas), the intermediate regime of accessing only tool schemas, and the final case of no prior knowledge—just the steps as they are being generated by the agent. Naturally, the expectation of the monitoring capability of ONTRACK is reduced as data access is reduced, ranging from the detection of any violation of the plans to the detection of loops, stalls, and repeated tool calls without new results. Finally, we evaluate the performance of our proposed solution using SWE-bench trajectories. Evaluating based on the first 8 steps, the proposed method ranked the failing trajectories below succeeding ones better than content similarity-based approaches (+0.057 AUROC). Additionally, by deploying an abort policy on top of it, we save ~18% of the compute that would have been burned on agents heading to failure, and 83% of runs that were interrupted were actually heading to failure (5 out of every 6 aborts were correct).

1 Introduction

Agents are being deployed across different applications and industries. One of their advantages is the autonomy that they bring during execution. With minimal human interference, they can execute a given task. They can automatically plan a trip, make a reservation, and complete the payment. However, this autonomy, if unchecked, can cause a damaging impact from cost and safety aspects.

On the cost side, these agents are using significant resources for a single step in a task, but they could easily suffer from hallucinations, out-of-order tool calls, or infinite loops—all of which are costly due to the underlying LLM usage. From a safety perspective, these agents—unmonitored—can delete or modify a record by mistake or, as in recent incidents, break out of their sandbox environment and start hacking other systems as reported in the OpenAI–HuggingFace incident [1]. All these aspects require developing a monitoring system for agents.

The existing methods rely either on offline (after-the-fact) evaluations, where traces and logs are evaluated against a rule-based mechanism or language models are used as the judge (i.e., LLM-as-a-Judge [2]). However, by the time an issue is found, the run has already been paid for. Online safeguards, on the other hand, monitor agents' execution using another agent. First, this method is costly and also adds latency to the execution due to an extra call to an LLM. On top of that, to reduce the cost, these safeguards are usually equipped with smaller models which struggle to detect the mistakes of the larger models, or a dedicated model is trained to score every step which renders the mechanism a black box [3]. Moreover, none of these methods look at the structure or the topology of the runs, i.e., which steps depend on which, even though that is where loops or out-of-order calls show up.

To overcome this issue, we propose a streaming monitoring mechanism called ONTRACK. This approach models the agent's progress toward completing the task as a directed acyclic graph (DAG) in which each step of the graph corresponds to one node and, if a step's output is used in another step, there is an edge between them. As the run unfolds, the monitor compares this growing graph against reference solutions using optimal transport and flags potential issues in about a millisecond per step.

∗^{*}Corresponding author

The references are optional, however—the monitor runs with whatever is available. With tool schemas alone, it still catches loops and stalls and blocks an irreversible action whose declared prerequisites are missing; with nothing but the event stream, loop and stall detection remain. Nothing is reconfigured across these regimes; parts of the monitor simply switch off as their inputs disappear.

Note that modeling agent task execution as a DAG and aligning it against reference solutions with optimal transport were already proposed in Otap [4]. However, their evaluation was a post hoc evaluation against complete references. Our contribution is making this alignment work on a live stream, which cannot be done by just re-running the batch method after each step due to the following structural challenges:

S1 (prefix vs. whole). Using a post hoc evaluation method in the middle of the trajectory will penalize the agent for every reference step it has not reached yet. So, the comparison punishes the agent for being early rather than being wrong—exactly the stage where the monitor most needs to stay quiet. Additionally, considering the portion of the reference that has been covered mid-stream is meaningless. For example, covering 10 of the 30 reference steps could be perfect progress if the agent is at step 10, and can be an indicator of a stuck agent if it is at step 80.

S2 (provisional structure). Edges are discovered later when a step (node) uses an output of another step. As a result, a new step immediately after just being generated can seem disconnected and might look like the agent is hallucinating. Judging new steps on their structure immediately can flood the system with lots of false positives. Note that extracting dependencies in post hoc evaluation is a dominant source of error [4], and it even gets harder in streaming when the monitor cannot look ahead.

Note: S1 is concerned about the steps not taken by the agent when comparing with reference, and S2 is concerned about the steps that the agent has taken but are not clear yet. As a simple example, the agent does a search at step 5, which at the moment the step looks disconnected. Ten steps later, the agent edits that searched file. That's when the edge appears and the first step becomes clear.

S3 (compute budget). The evaluator must produce a verdict before the agent's next tool call. Re-solving the full alignment from scratch at every step is unnecessary and, as the trajectory grows, quickly becomes infeasible.

S4 (decisions, not scores). Post hoc evaluation methods can output a score, and the operator can define a threshold to evaluate if the execution was successful or not. The streaming monitoring mechanism can't. It instead outputs an action: continue, warn, or halt. To better understand this, consider an agent at step 5 that takes one hallucinated step. This is one fifth of all steps, so this will result in the aggregated score going under the threshold, while if this happened at step 30, it might move the score slightly. As a result, the same score value means different things at different lengths. So, the score is informative, but it should not be used as a trigger and no fixed threshold can drive the decision. A streaming monitoring mechanism should focus on per-step signals whose meaning stays the same as the trajectory grows.

ONTRACK addresses all four challenges. For S1, the monitor only expects the parts of the reference the agent could have reached so far, so an agent is never punished for being early (Sec. 4.2). For S2, a new step's structural influence starts at zero and phases in as later steps use its output; edges discovered late are inserted into the graph in place (Sec. 4.4). For S3, instead of re-solving the alignment at every step, we take one warm-started iteration of the batch solver per event — about a millisecond per step — and run the solver to convergence only before acting on an intervention (Sec. 4.3). For S4, decisions come from per-step signals with a short grace window for new steps, never from the aggregate score (Sec. 4.5). At the end of the run, one final solve makes the monitor's output identical to the batch evaluator's — provided the dependencies discovered online match what batch extraction would find (Prop. 1).