Skip to content
Skills Library
AI & agents · Building & coding

reflexion-pattern

/reflexion-pattern

Critic node with verbal-memory of past failures, stable rubric scoring, and bounded retry budget. Use when an agent loop fails repeatedly on the same task and naive retry gives no improvement — Reflexion turns failure into actionable verbal feedback.

Repository
jeo-skills ↗
Licence
MIT
Last repository change
13.11.2026

Assessment and security

93/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene8 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 13.11.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Critic node with verbal-memory of past failures, stable rubric scoring, and bounded retry budget. Use when an agent loop fails repeatedly on the same task and naive retry gives no improvement — Reflexion turns failure into actionable verbal feedback.

Original author description

Critic node with verbal-memory of past failures, stable rubric scoring, and bounded retry budget. Use when an agent loop fails repeatedly on the same task and naive retry gives no improvement — Reflexion turns failure into actionable verbal feedback.

How it works

  1. Overview
  2. When to use
  3. Don't use when
  4. The loop
  5. Components
  6. Stable rubric (essential)
  7. Critic prompt template
  8. Retry budget
  9. Quick start (LangGraph)
  10. Anti-patterns
Original SKILL.md headings · 120 lines, 484 words
SKILL.md preview
---
name: reflexion-pattern
description: Critic node with verbal-memory of past failures, stable rubric scoring, and bounded retry budget. Use when an agent loop fails repeatedly on the same task and naive retry gives no improvement — Reflexion turns failure into actionable verbal feedback.
---

# Reflexion Pattern

## Overview

When an agent fails, retrying with the same prompt produces the same failure. Reflexion adds a **critic** that reads the failed trajectory, writes a short verbal lesson, and stores it in episodic memory. The actor reads the lesson on next attempt. Bounded by a retry budget so it can't loop forever.

## When to use

- Same task fails 2+ times with the same prompt
- You have a clear success signal (tests, golden, judge)
- Failure modes are recognizable in the trajectory (wrong tool, wrong arg, wrong plan)

## Don't use when

- One-shot tasks with no retry capacity
- Failure signal is noisy (judge LLM disagrees with itself)
- Budget too tight for 2+ attempts

## The loop

```
Actor → Trajectory → Evaluator → success? ─── yes ──→ done
                          │
                          no
                          ↓
                       Critic ──→ verbal lesson ──→ Episodic Memory
                                                          │
                                                          ↓
                                                    next Actor attempt
```

## Components

| Component | Job | Output |
|-----------|-----|--------|
| **Actor** | Execute the task | Trajectory (actions, observations) |
| **Evaluator** | Score the trajectory | `success: bool`, `score: float`, `reasons: list` |
| **Critic** | Diagnose failure, propose fix | Short verbal lesson (≤ 200 tokens) |
| **Memory** | Hold lessons across attempts | Append-only `lessons[]` |

## Stable rubric (essential)

Reflexion fails if the evaluator is unstable. Lock the rubric:

```yaml
rubric:
  - test_suite_passes: 0.4
  - acceptance_criteria_met: 0.3
  - no_forbidden_actions: 0.2
  - efficiency: 0.1
success_threshold: 0.85
```

Same rubric, same weights, every attempt. Don't tune mid-experiment.

## Critic prompt template

```
You are a critic. The actor attempted a task and failed.

Task: {task}
Acceptance: {criteria}
Trajectory: {trajectory}
Evaluator score: {score} / 1.0
Evaluator reasons: {reasons}

Write a single short lesson (≤ 200 tokens) that the actor should read before
trying again. Focus on the specific action or decision that caused failure.
Do NOT restate the task. Do NOT speculate beyond the trajectory.
```

## Retry budget

```python
@dataclass
class ReflexionBudget:
    max_attempts: int = 4
    max_cost_usd: float = 1.0
    min_score_improvement: float = 0.05  # stop if no progress
```

Stop conditions:
1. `success == True`
2. `attempts >= max_attempts`
3. `cost >= max_cost_usd`
4. `score[-1] - score[-2] < min_score_improvement` (plateau)

## Quick start (LangGraph)

```python
def actor(state):
    lessons = state["memory"]
    prompt = f"{base_prompt}\n\nLessons from past attempts:\n" + "\n".join(lessons)
    trajectory = run_actor(prompt, state["task"])
    return {"trajectory": trajectory}

def evaluator(state):
    return {"score": grade(state["trajectory"], rubric=RUBRIC)}

def critic(state):
    lesson = critic_llm.invoke(CRITIC_PROMPT.format(**state))
    return {"memory": state["memory"] + [lesson]}

graph.add_conditional_edges("evaluator", lambda s: "done" if s["score"] > 0.85 else "critic")
```

## Anti-patterns

- Critic that just says "try harder" → constrain to actionable lessons
- Unbounded lessons list → keep last N or cluster
- Mixing rubric across attempts → freeze before run
- Critic sees only final answer, not trajectory → useless

## Further reading

- Shinn et al. — original Reflexion paper (NeurIPS 2023)
- LangGraph reflection examples
- Pair with: `multi-agent-eval-harness`

Versions

The database has no other skills named reflexion-pattern.

Database snapshot: 13.11.2026 · package version be3c1c114fb9 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100reflexion
    Use for self-correcting implementation. Implements the reflexion loop: implement, validate, self-critique, retry (max 3 iterations).
  • 100agentdb-reflexion-learning
    Learn from outcomes with AgentDB — store reflexion episodes with a self-critique, turn what worked into skills, report pattern and skill outcomes for reward-aware recall, record causal edges and RL feedback, and retrieve past failures before retrying. Use after a task succeeds…
  • 100agent-architecture-patterns
    Choose the right architecture for an LLM agent or multi-agent system. Use when the user is designing, comparing, or debugging agentic workflows and mentions ReAct, Reflexion, Plan-and-Execute, Router, Supervisor, Hierarchical, multi-agent, tool-use loop, agent graph, LangGraph,…
  • 100self-improving-systems
    Decide whether your agent actually needs persistent memory, feedback loops, or closed-loop learning, then design the smallest thing that pays for itself. Use when the user says "add memory", "give my agent context management", "make my agent learn", "self-improving /…
  • 100memory-reflexion
    Tier 2 episode extraction, the reflexion write path split out of the memory router per ADR-063. Extracts an episode from a completed session log so later sessions can replay what was tried and what it cost. Use when you say `extract episode from session`, `record what happened…
  • 100memory-reflexion
    Tier 2 episode extraction, the reflexion write path split out of the memory router per ADR-063. Extracts an episode from a completed session log so later sessions can replay what was tried and what it cost. Use when you say `extract episode from session`, `record what happened…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.