Summary of "Agent-Reflex: Teaching Language Agents to Act Reflectively"

Summary (Overview)

  • Core Contribution: Agent-Reflex is a three-stage training framework that teaches LLM-based agents to proactively reflect and recover from failures in noisy, real-world tool-use environments—a gap left open by prior methods that assume clean, idealized interactions.
  • Key Innovation 1: The framework's first stage (RSD) mines 1,170 reusable reflection meta-skills from matched success/failure trajectory pairs across 557 database-backed executable environments, with tool-return failures injected based on 24,510 real error returns categorized into 8 families.
  • Key Innovation 2: The second stage (ReSFT) converts each skill into three complementary supervision types—Self-Reflection (SR), Skill Recovery (KR), and User-Centric Reflection (UR)—for local repair, global recovery, and user-guided correction, respectively.
  • Key Innovation 3: The third stage (ORPO) combines Noisy Agent RL with reflection-guided on-policy distillation (OPD), providing token-level supervision that complements trajectory-level outcome signals.
  • Empirical Results: Agent-Reflex-8B achieves 58.6 overall on five long-horizon tool-use benchmarks and 29.1 on AgentNoiseBench, outperforming strong environment-scaling baselines (EnvScaler-8B: 50.9, Agent-World-8B: 53.6) and reflection methods (Reflexion-8B: 44.7, Agent-R-8B: 40.1) at the same 7B–8B parameter scale.

Introduction and Theoretical Foundation

Background

Large language models (LLMs) have evolved into interactive agents capable of long-horizon reasoning. Training these agents requires diverse, stateful environments that model real-world interaction logic. Two existing families of environment-scaling approaches include:

  1. Implicit world models (Simia, GenEnv)—LLM-generated feedback through tool specifications and interaction history
  2. Executable environments (Agent-World, EnvScaler)—synthesized tools and databases with verifiable tasks

The Two Gaps

The paper identifies two critical failures of existing training paradigms:

  1. Lack of noisy feedback: Real tool services return timeouts, service errors, authentication failures, and other perturbations. The failure error injection is formalized as:
ot+1train={J(ot+1),bt+1inj=1,ot+1,bt+1inj=0,bt+1inj∼Bernoulli(pinj),(1)o_{t+1}^{\text{train}} = \begin{cases} J(o_{t+1}), & b_{t+1}^{\text{inj}} = 1, \\ o_{t+1}, & b_{t+1}^{\text{inj}} = 0, \end{cases} \quad b_{t+1}^{\text{inj}} \sim \text{Bernoulli}(p_{\text{inj}}),\tag{1}
  1. Lack of user-guided correction: Real users intervene mid-execution to correct agent behavior, but existing simulators rely on template-based corrections with limited diversity.

Research Question

How can we elicit proactive reflective capability in agents from execution failures in real-world environments?

The paper argues that reflection should be modeled as a learnable meta-skill—not merely an inference-time mechanism—that maps bad patterns to corrective actions and transfers across tasks within an environment.

Methodology

Stage 1: Environment Reflection Skill Discovery (RSD)

Noise-Grounded Environment Scaling:

  • 557 high-usage MCP server specifications are used to construct executable environments with populated databases
  • 177,700 tool returns (24,510 errors) are collected from nine public benchmarks and grouped into 8 failure families: service/gateway unavailable, auth/permission failure, request timeout, resource not found, parameter/validation failure, execution exception, rate limit, and network connection failure

Capability-Diverse Trajectory Sampling:

  • Trajectories are sampled from a pool Πpool\Pi_{\text{pool}} of 9 LLMs (4B–284B parameters) to avoid model-specific reasoning concentration
  • An analyzer and environment verifier jointly label rollouts into correct (Dcorrect\mathcal{D}_{\text{correct}}) and error (Derror\mathcal{D}_{\text{error}}) sets, pairing them by task

Meta-Skill Extraction:

  • For each environment mm, a skill card stores ζm=(dm,Tˉm,Bm,Kˉm)\zeta_m = (d_m, \bar{T}_m, B_m, \bar{K}_m) where dmd_m describes the environment, TmT_m its tools, BmB_m bad patterns, and κm\kappa_m extracted reflection skills
  • The offline library is K=⋃m∈MKm\mathcal{K} = \bigcup_{m \in \mathcal{M}} \mathcal{K}_m, linking each sample with its environment-specific skill

Stage 2: Reflective Supervised Fine-Tuning (ReSFT)

ReSFT constructs three forms of reflective supervision:

Self-Reflection (SR)—trains local repair after error detection:

ySR∼π0(⋅∣ht∗⊕κ),DSR={(ht∗,ySR):Verst∗(ht∗,ySR)=1}(2)y^{\text{SR}} \sim \pi_0(\cdot \mid h_{t^*} \oplus \kappa), \qquad \mathcal{D}_{\text{SR}} = \{(h_{t^*}, y^{\text{SR}}): \text{Ver}_{s_{t^*}}(h_{t^*}, y^{\text{SR}}) = 1\}\tag{2}

Skill Recovery (KR)—trains global replanning from scratch after an initial plan fails:

yKR∼π0(⋅∣q⊕κ),DKR={(q,yKR):Vers0(q,yKR)=1}(3)y^{\text{KR}} \sim \pi_0(\cdot | q \oplus \kappa), \qquad \mathcal{D}_{\text{KR}} = \{(q, y^{\text{KR}}): \text{Ver}_{s_0}(q, y^{\text{KR}}) = 1\}\tag{3}

User-Centric Reflection (UR)—trains recovery from user interventions:

yUR∼π0(⋅∣ht⋆⊕uκ),DUR={(ht⋆⊕uκ,yUR):Verst⋆(ht⋆⊕uκ,yUR)=1}(4)y^{\text{UR}} \sim \pi_0(\cdot | h_{t^\star} \oplus u_\kappa), \qquad \mathcal{D}_{\text{UR}} = \{(h_{t^\star} \oplus u_\kappa, y^{\text{UR}}): \text{Ver}_{s_{t^\star}}(h_{t^\star} \oplus u_\kappa, y^{\text{UR}}) = 1\}\tag{4}

Skills are removed from stored inputs (except user corrections) so the policy learns recovery without explicit skill priors.

Stage 3: On-Policy Reflective Policy Optimization (ORPO)

Noisy Agentic RL:

  • A task pool from EnvScaler RL is used; each task yields G trajectories with fraction ν under noisy environments and the rest clean
  • Returns are group-normalized: A^q,i=Rq,i−μqσq+ϵ\hat{A}_{q,i} = \frac{R_{q,i} - \mu_q}{\sigma_q + \epsilon}
  • The clipped Agent RL objective combines policy gradient with KL regularization:
LRL(θ)=−Eq,i,t,k[χq,i,t,kmin⁡(ρq,i,t,kA^q,i,clip(ρq,i,t,k,1−ϵc,1+ϵc)A^q,i)]+βKLEh∼Gq[DKL(πθ(⋅∣h)∥πref(⋅∣h))](8)\mathcal{L}_{\text{RL}}(\theta) = -\mathbb{E}_{q,i,t,k}\left[\chi_{q,i,t,k}\min\left(\rho_{q,i,t,k}\hat{A}_{q,i}, \text{clip}(\rho_{q,i,t,k}, 1-\epsilon_c, 1+\epsilon_c)\hat{A}_{q,i}\right)\right] + \beta_{\text{KL}}\mathbb{E}_{h \sim \mathcal{G}_q}\left[D_{\text{KL}}(\pi_\theta(\cdot|h)\|\pi_{\text{ref}}(\cdot|h))\right]\tag{8}

Reflection On-Policy Distillation (OPD):

  • The same policy with skill context re-scores action tokens sampled without skills: h~q,i,t=H(hq,i,t,κq,i)\tilde{h}_{q,i,t} = H(h_{q,i,t}, \kappa_{q,i})
  • The skill-induced shift and confidence weight are:
Δq,i,t,k=sg[ℓq,i,t,kskill−ℓq,i,t,kθ],γq,i,t,k=sigmoid(βopdΔq,i,t,k)(10)\Delta_{q,i,t,k} = \text{sg}\left[\ell_{q,i,t,k}^{\text{skill}} - \ell_{q,i,t,k}^{\theta}\right], \quad \gamma_{q,i,t,k} = \text{sigmoid}\left(\beta_{\text{opd}}\Delta_{q,i,t,k}\right)\tag{10}
  • Optimized with: \mathcal{L}_{\text{OPD}}(\theta) = \mathbb{E}_{q,i,t,k}\left[\chi_{q,i,t,k}\gamma_{q,i,t,k}\left(\text{sg}[\ell_{q,i,t,k}^{\text{skill}}] - \ell_{q,i,t,k}^{\theta}\right)\right]\tag{11}

Joint Objective:

LORPO=LRL+λopdLOPD(12)\mathcal{L}_{\text{ORPO}} = \mathcal{L}_{\text{RL}} + \lambda_{\text{opd}}\mathcal{L}_{\text{OPD}}\tag{12}

Empirical Validation / Results

Main Results on Long-Horizon Tool Use (Table 1 excerpt)

MethodVitaBench Avg.τ²-Bench Avg.BFCL V4 Avg.ACEBench Avg.ToolSandboxOverall
GPT-5.237.780.070.462.968.064.4
Claude-4.5-Sonnet38.084.781.173.282.072.6
Reflexion-8B6.834.542.764.075.444.7
Agent-World-8B*14.554.651.472.075.653.6
EnvScaler-8B15.837.947.672.580.550.9
Agent-Reflex-8B (ours)17.562.152.978.082.558.6

Results on AgentNoiseBench (Table 2 excerpt)

MethodANB-τ² Avg.ANB-Vita Avg.Overall
GPT-5.266.545.055.8
Claude-4.5-Sonnet61.041.051.0
NoisyAgent-8B37.614.225.9
EnvScaler-8B27.19.318.2
Agent-Reflex-8B (ours)45.912.329.1

Ablation Study (Table 3)

VariantANB-τ²ANB-Vita
Agent-Reflex (full)45.912.3
w/o SR41.38.9
w/o KR42.410.2
w/o UR43.010.9
w/o OPD43.79.5
w/o weight44.510.4

Key findings from ablation: (1) All components contribute; (2) SR is most load-bearing, followed by KR and UR; (3) The skill library alone is insufficient—OPD is essential.

Training Dynamics

ORPO separates from GRPO, DAPO, REINFORCE++, and SEED early in training and keeps rising after baselines flatten (Figure 4), showing stable training over 100 RL steps.

Theoretical and Practical Implications

  1. Reflection as a learnable meta-skill: The paper shifts reflection from an inference-time mechanism to a trainable capability, demonstrating that internalizing environment-level recovery rules outperforms episodic correction.

  2. Noise awareness as a foundation: Agents trained with tool-feedback perturbations (e.g., 8 families of real failures) become more robust, suggesting that training distributions should model deployment noise.

  3. Token-level dense supervision: The OPD objective demonstrates that token-level, skill-guided signals stabilize RL training and provide better gradient signal than trajectory-level rewards alone.

  4. Scalability: The approach separates environment construction from skill mining—the skill library is indexed by environment, requiring no retrieval at runtime, which supports large-scale training.

Conclusion

Agent-Reflex provides a complete pipeline from environment construction through skill mining to policy training. The three stages (RSD, ReSFT, ORPO) jointly convert environment failures into reusable reflection capabilitiesтно. Across six challenging benchmarks, it outperforms strong baselines in long-horizon tool use, noisy interaction robustness, and training stability. Key future directions include extending the framework to more diverse noise typesags and user interaction patterns, and scaling to larger foundation models.

Key formulas to remember:

  • Noise injection: ot+1train=J(ot+1)o_{t+1}^{\text{train}} = J(o_{t+1}) with probability pinjp_{\text{inj}} (Eq. 1)
  • Confidence-weighted OPD: γq,i,t,k=sigmoid(βopdΔq,i,t,k)\gamma_{q,i,t,k} = \text{sigmoid}(\beta_{\text{opd}}\Delta_{q,i,t,k}) (Eq. 10)
  • Joint ORPO objective: LORPO=LRL+λopdLOPD\mathcal{L}_{\text{ORPO}} = \mathcal{L}_{\text{RL}} + \lambda_{\text{opd}}\mathcal{L}_{\text{OPD}} (Eq. 12)

Related papers