From Trace to Fix: Residual Task State in Long-Horizon Agents
Organizations: University of Central Florida
Abstract
Recovering from failures in long-horizon, stateful language agents is challenging because the action introducing a defect, the symptom exposing it, and the persistent state requiring repair frequently diverge. Existing methods largely focus on retrospective failure attribution, leaving sequential diagnosis and state repair poorly integrated under constrained budgets. We introduce TRACE-FIX, a unified recovery framework centered on versioned residual task state. Trace transforms execution logs into a structured dependency-linked ledger, prioritizing unresolved task requirements rather than salient surface errors. Fix formulates recovery as budgeted planning over admissible actions, incorporating outcome forecasting and explicit repair-reserve constraints to prevent premature budget exhaustion. To rigorously decouple localization accuracy from downstream repair capability, we present LongH-Debug, evaluating root-cause attribution, verified-fault recovery, and end-to-end closed-loop execution independently. Our empirical analysis demonstrates that structured residual tracking substantially improves causal localization over raw-trace baselines, while budget-aware sequential planning converts verified fault signals into more reliable task recovery without destructive trial-and-error. Code is available at https://github.com/toffeecat/tracedp.
Figures & tables
| A Delayed state mutation db-wal-recovery live run, 97 tool calls 0 ls -la /app: base 8192 B log 16512 B 2 sqlite3 main.db … PRAGMA wal_checkpoint: log deleted 9 cp main.db-wal /tmp/…bak (already too late) 38 the same read deletes the rebuilt log again 95 the actor states the mechanism itself end timeout, reward 0.0 A successful read removes the only carrier of the six missing records. Nothing errors, so the run repeatedly rebuilds and destroys the log. | B Residual obligation openssl-selfsigned-cert live run, 7 checks 1 script-runs: /app/check_cert.py exits 1 2 verification-file: subject and fingerprint 3 key-attributes: 2048-bit RSA, mode 600 4 script-runs re-run: the same predicate passes 5 combined-pem parses as a certificate 6 ssl-directory-layout holds the deliverables 7 certificate-attributes: subject, 365-day validity end reward 1.0 The actor rewrites the script after the first failure; the same predicate then passes and the task reaches reward . |
| C Blame is not a current fault bn-fit-modify live run, 8 checks 0 learned_dag.csv exists in to,from format 1 intervened DAG exists in to,from format 2 intervened sample keeps the column names 3 the DAG has six total edges 4 intervened edges are a subset of the learned DAG 5–7 repeated checks of the same conditions end 8/8 supported, reward 1.0, 0 repairs The history contains a failure, but the live state already satisfies every check. Historical blame is therefore not a current repair target. | D Budgeted recovery cancel-async-tasks live run, 8 checks, 2 repairs 1–2 import-form and signature supported 3 concurrent-execution refuted 4–6 max-concurrency, cancel-below, cancel-at supported 7 cancel-above-limit refuted 8 import-form re-run: supported end 2 repairs tried, reward 0.0 Eight checks and two repairs exhaust the twelve-unit budget before either repaired predicate is re-verified. |
| Method | Hit@1 | Hit@3 | MRR | Cand. recall | VerifiedRoot @ | Tok. (M) | Rel. cost |
|---|---|---|---|---|---|---|---|
| Generic one-shot | 42.0 | 74.5 | .571 | 93.0 | 31.0 | 2.40 | 1.00 |
| Dependency-only | 24.0 | 46.0 | .351 | 64.0 | 15.5 | 0.52 | 0.22 |
| Who&When (adapted) | 8.0 | 12.0 | .097 | 17.0 | 4.5 | 6.00 | 2.50 |
| TraceElephant (adapted) | 44.0 | 61.0 | .508 | 71.0 | 33.0 | 12.20 | 5.08 |
| Residual Context | 43.0 | 74.5 | .573 | 93.0 | 32.0 | 7.80 | 3.25 |
| Our Trace | 68.0 | 89.0 | .782 | 97.0 | 60.5 | 3.10 | 1.29 |
| Fixer | TaskRecovery | LocalResolve | Harmful | Cost/success |
|---|---|---|---|---|
| Same-Actor Continue | 35.0 | 29.2 | 0.0 | 1.00 |
| Fresh Fixer | 42.5 | 40.8 | 5.8 | 0.92 |
| Fixed-order sweep | 47.5 | 50.0 | 4.2 | 0.86 |
| Information gain | 50.0 | 53.3 | 4.2 | 0.82 |
| Information gain + repair reserve | 61.7 | 66.7 | 3.3 | 0.69 |
| Residual-Greedy | 56.7 | 61.7 | 3.3 | 0.73 |
| Controller | TaskRecovery | Harmful | Cost/succ. |
|---|---|---|---|
| Full FIX | 67.5 | 2.5 | 0.61 |
| No structured residual state | 52.5 | 5.0 | 0.78 |
| No version invalidation | 58.3 | 5.8 | 0.74 |
| No receipt-triggered recompilation | 49.2 | 6.7 | 0.82 |
| Residual-Greedy | 56.7 | 3.3 | 0.73 |
| Information gain + repair reserve | 61.7 | 3.3 | 0.69 |
LLM Agent Reliability
Large language model (LLM) agent reliability concerns dependable, safe, and verifiable behavior across tools, multi-step tasks, and changing environments.
See all 801 papers