# Agent-Reflex: Teaching Language Agents to Act Reflectively

> Agent-Reflex trains LLM agents to reflect and recover from real-world tool failures via mined meta-skills, beating stronger baselines on noisy long-horizon benchmarks.

- **Source:** [arXiv](https://arxiv.org/abs/2610.17953)
- **Published:** 2026-10-15
- **Permalink:** https://picx.dev/p/h9SfbB
- **Whiteboard:** https://picx.dev/p/h9SfbB/image

## Summary

# 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:

$$
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}
$$

2. **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 $\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 ($\mathcal{D}_{\text{correct}}$) and error ($\mathcal{D}_{\text{error}}$) sets, pairing them by task

**Meta-Skill Extraction**:
- For each environment $m$, a skill card stores $\zeta_m = (d_m, \bar{T}_m, B_m, \bar{K}_m)$ where $d_m$ describes the environment, $T_m$ its tools, $B_m$ bad patterns, and $\kappa_m$ extracted reflection skills
- The offline library is $\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:
$$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:
$$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:
$$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: $\hat{A}_{q,i} = \frac{R_{q,i} - \mu_q}{\sigma_q + \epsilon}$
- The clipped Agent RL objective combines policy gradient with KL regularization:
$$\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: $\tilde{h}_{q,i,t} = H(h_{q,i,t}, \kappa_{q,i})$
- The skill-induced shift and confidence weight are:
$$\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**:
$$\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)

| Method | VitaBench Avg. | τ²-Bench Avg. | BFCL V4 Avg. | ACEBench Avg. | ToolSandbox | **Overall** |
|---|---|---|---|---|---|---|
| GPT-5.2 | 37.7 | 80.0 | 70.4 | 62.9 | 68.0 | 64.4 |
| Claude-4.5-Sonnet | 38.0 | 84.7 | 81.1 | 73.2 | 82.0 | 72.6 |
| Reflexion-8B | 6.8 | 34.5 | 42.7 | 64.0 | 75.4 | 44.7 |
| Agent-World-8B* | 14.5 | 54.6 | 51.4 | 72.0 | 75.6 | 53.6 |
| EnvScaler-8B | 15.8 | 37.9 | 47.6 | 72.5 | 80.5 | 50.9 |
| **Agent-Reflex-8B (ours)** | **17.5** | **62.1** | **52.9** | **78.0** | **82.5** | **58.6** |

### Results on AgentNoiseBench (Table 2 excerpt)

| Method | ANB-τ² Avg. | ANB-Vita Avg. | **Overall** |
|---|---|---|---|
| GPT-5.2 | 66.5 | 45.0 | 55.8 |
| Claude-4.5-Sonnet | 61.0 | 41.0 | 51.0 |
| NoisyAgent-8B | 37.6 | 14.2 | 25.9 |
| EnvScaler-8B | 27.1 | 9.3 | 18.2 |
| **Agent-Reflex-8B (ours)** | **45.9** | **12.3** | **29.1** |

### Ablation Study (Table 3)

| Variant | ANB-τ² | ANB-Vita |
|---|---|---|
| Agent-Reflex (full) | **45.9** | **12.3** |
| w/o SR | 41.3 | 8.9 |
| w/o KR | 42.4 | 10.2 |
| w/o UR | 43.0 | 10.9 |
| w/o OPD | 43.7 | 9.5 |
| w/o weight | 44.5 | 10.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: $o_{t+1}^{\text{train}} = J(o_{t+1})$ with probability $p_{\text{inj}}$ (Eq. 1)
- Confidence-weighted OPD: $\gamma_{q,i,t,k} = \text{sigmoid}(\beta_{\text{opd}}\Delta_{q,i,t,k})$ (Eq. 10)
- Joint ORPO objective: $\mathcal{L}_{\text{ORPO}} = \mathcal{L}_{\text{RL}} + \lambda_{\text{opd}}\mathcal{L}_{\text{OPD}}$ (Eq. 12)

---

_Markdown view of https://picx.dev/p/h9SfbB, served by PicX — AI-generated visual whiteboard summaries of research papers._
