arXiv(opens in a new tab)cs.LGOct 2026Cited by 2 papers on PaperVantage

Manuscript Offprint

arXiv:2610.02994

Sentry: Learning to Recover from LLM Agent Failures at Test Time

Changxiu Ji, Amy Lu, Qizheng Zhang, Kunle Olukotun

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

LLM agents often fail mid-task due to invalid tool calls, repeated actions, or poorly grounded reasoning, and learning from these failures is a path to reliability. We find that how failure knowledge reaches the agent matters as much as what it contains. Failure lessons are conditional: kept in the agent's context, they misfire when their failure is absent, and removing them from an evolving playbook improves performance. Runtime interventions, in contrast, act only when a failure occurs but do not learn from their repairs. We argue that failure knowledge is conditional knowledge and should be conditionally exposed, and instantiate this principle in Sentry, a failure-management layer that runs alongside the agent. When Sentry detects a failure, it retrieves matching lessons from an external playbook to guide recovery, verifies without access to task rewards whether the agent recovered, and stores a new lesson only if it did; the full playbook never enters the agent's context. Across multiple agentic benchmarks, Sentry outperforms the strongest runtime-intervention baseline on every benchmark, by 37% on average, and the strongest context-evolution baseline by 39% on the two benchmarks where both are evaluated; combining Sentry with context evolution yields further gains. Learned lessons transfer to held-out tasks, and controlled experiments show that exposing the full playbook to the agent lowers performance even when relevant lessons remain available on demand.

1 Introduction

Modern large language model (LLM) agents increasingly tackle interactive and multi-step tasks involving reasoning, tool use, and external environments [11, 17, 25, 26]. Success often hinges less on getting every step right than on recovering when one goes wrong: an invalid tool call [22], a repeated or stalled action, a poorly grounded decision [32], or reasoning that does not match the action [2]. As tasks grow longer, failure recovery becomes central to agent reliability.

Two lines of work let agents learn from failures, and each gets only half the problem right. Context-evolution methods distill past trajectories into reflections, workflows, or playbooks reused on future tasks [15, 18, 21, 30]. They learn across tasks but expose lessons too broadly: even retrieval-based memories [15, 31] select lessons once at task start, before any failure, and keep them in context for the whole trajectory. Runtime-intervention methods monitor the trajectory and inject guidance when a failure is detected [8, 12, 13, 28]. They act selectively but do not learn: what resolved one failure does not inform the next, and a fixed rule that rescues one task can derail another (Figure 1b).

We find that how failure knowledge reaches the agent matters as much as what it contains. Failure lessons are conditional: "if repeated searches return nothing relevant, broaden the query" helps only when that failure is occurring. Kept in context, such lessons force the agent to judge at every step whether each applies, and it often judges wrong: in Figure 1a, an agent carrying recovery rules learned by ACE [30] finds a matching product but keeps comparing alternatives and never buys it. The effect is systematic. Removing failure lessons from ACE's playbook improves held-out performance, from 0.335 to 0.391 reward on WebShop [24] and from 0.562 to 0.643 completion on Mind2Web Replay [4]. Conversely, adding a fixed playbook to persistent context lowers WebShop reward from 0.364 to 0.296, even when the same lessons remain available on demand, mirroring capability erosion in self-evolving agents [27]. Intervention shows the same pattern: intervening without checking whether it is needed drops WebShop reward below the unassisted agent's (0.136 vs. 0.170). These observations suggest a simple principle: failure knowledge is conditional knowledge and should be conditionally exposed. It should be learned across tasks, as in context evolution, but surfaced only on a matching failure, as in runtime intervention.

We instantiate this principle in Sentry, a failure-management layer that runs alongside the task agent and learns from the recoveries it verifies. Sentry watches the agent's recent steps and returns non-executable actions for a schema-conforming retry. For behavioral failures, such as loops or reasoning not grounded in observations, Sentry diagnoses the failure, retrieves at most k matching lessons from an external playbook, and uses them to guide the agent's next step. It then checks whether the agent recovers, without access to task rewards, and writes a new lesson only if it does. The full playbook never enters the agent's context: the agent sees a handful of lessons, only while failing, and only for that failure. Because the problem stems from how knowledge enters the context rather than from a particular model's weaknesses, we expect it to matter more, not less, as memories grow and agents run longer.

Across WebShop, AppWorld [19], SWE-bench Lite [7], and Mind2Web Replay, Sentry outperforms the strongest runtime-intervention baseline on every benchmark, by 37% on average (up to 77%), and ACE, the strongest context-evolution baseline, by 39%. The gains are not just action repair: without the schema-conforming retry, Sentry still beats all runtime-intervention baselines on both ablated benchmarks. Sentry also complements context evolution: ACE+Sentry performs best wherever evaluated, suggesting that task-and failure-level knowledge can evolve together. Our contributions are:

• A finding about failure knowledge. We show that failure-specific knowledge is conditional, and that exposing it unconditionally hurts: always-on failure lessons and always-on intervention both lower agent performance in controlled comparisons ( §2,§5.3§2, §5.3).

• Sentry, a method built on this finding. Sentry keeps an evolving recovery playbook outside the agent's context, retrieves from it only when a matching failure is diagnosed mid-trajectory, and admits a lesson only after verifying, without reward access, that the recovery succeeded ( §3§3).

• Evidence across four benchmarks. Beyond the main comparisons, held-out evaluation shows that learned recovery lessons transfer to unseen tasks; paired forks from 200 intervention points show that Sentry’s guidance causally improves local recovery (33.5% → 60.5%); and human annotation agrees with Sentry’s intervention and recovery judgments in 86.0% and 81.8% of cases ( §5§5).

References (30)