AI Glossary / Agents and automation / Advanced

Reflexion

Reflexion (Agents and automation)

Definition

Reflexion is a technique in which an AI agent attempts a task, receives feedback on the result, writes a short natural-language reflection on what went wrong, and stores that note to guide its next attempt. It improves behavior by adding written lessons to the agent's memory, not by changing the model's weights. The name comes from a research paper, and practice varies in how feedback is gathered and how memory is kept.

What it means

Most AI agents repeat the same mistake if you ask them to try again with no new information. Reflexion gives the agent a way to learn within a session or across a series of attempts. After a failed try, the agent writes itself a plain-language note, such as 'I checked the wrong column, so next time I will confirm the column header first.' That note is added to the instructions for the next try.

For a business, this means an automated workflow can improve its own results over several rounds without anyone retraining a model. The cost is more model calls and more time per task. The benefit appears only when the agent can get a clear signal about whether it succeeded, such as a failed test, a rejected invoice or a reviewer's comment.

How it works

A typical Reflexion loop has three parts. An actor, usually a large language model, attempts the task. An evaluator judges the attempt. This can be an automated check, like a unit test or a rule that compares totals, or a score from a person or another model. A self-reflection step then takes the attempt and the evaluation and writes a short lesson in words.

The lesson is saved in a memory store, often just a list of text notes. On the next attempt, those notes are placed in the prompt alongside the original task. The actor reads them and tries again. The loop repeats until the evaluator reports success or a fixed limit on attempts is reached. The limit matters, because without one the loop can run up cost without improving.

The quality of the evaluator largely decides the quality of the result. If the feedback is precise, the reflection tends to be useful. If the feedback is vague or wrong, the agent may write a confident but mistaken lesson and carry it forward. Reflexion is related to chain-of-thought and ReAct prompting, which also use written reasoning, but it adds a memory of past failures across attempts.

Three practical examples

  • Finance team: An agent drafts a journal entry to reclassify expenses. An automated check finds that debits and credits do not balance. The agent writes a note that it forgot to include the tax line, stores it, and the second attempt balances.
  • Retailer: An agent writes product descriptions that must follow a style guide. A checker flags that three descriptions exceed the character limit. The reflection says to count characters before finishing, and later drafts stay within the limit.
  • Support desk: An agent drafts replies to refund requests. A supervisor rejects some for quoting the wrong policy window. The agent records that refund windows differ by product type and checks the product type before replying.

Think of it this way

Think of a new employee who keeps a notebook of corrections from their manager. Before each new task, they reread the notebook and avoid the old errors. The analogy stops working because the agent's notebook is only as good as the feedback behind it, and the agent cannot tell on its own whether a note is wrong.

Worked example

A small accounting team uses an agent to reconcile 20 vendor statements, with a checker that passes a statement only if the totals match to the cent. On the first pass, the agent gets 12 of 20 right, a success rate of 12 divided by 20, which is 60 percent. The reflection step reads the 8 failures and notes that most involved credit memos entered as positive amounts. On the second pass, with that note added, 17 of 20 pass, or 85 percent. A third note about duplicate invoice numbers lifts the result to 19 of 20, or 95 percent.

Now count cost. Each attempt on one statement costs about 4 cents in model usage, and each reflection adds 1 cent. Across three rounds, the 8 retried statements in round two cost 8 x (4 + 1) = 40 cents, and the 3 retried in round three cost 3 x (4 + 1) = 15 cents. Added to the first pass of 20 x 4 = 80 cents, the total is 80 + 40 + 15 = 135 cents, or $1.35, for 19 correct reconciliations. A person would need to judge whether that beats the time spent fixing the last mistake by hand.

Illustrative case study

Fictional case: Harbor Lane Supply, a made-up regional distributor, built an agent to match purchase orders to delivery receipts. At first the agent retried failures with no memory, and the same mismatches kept recurring. The team added a Reflexion loop with a checker that compared quantities and unit prices. Match rates rose in the first week.

Then a problem appeared. One reflection wrongly concluded that all receipts from a certain carrier used a different unit of measure, and the agent applied that rule to every carrier. Errors rose for two days before a clerk noticed. The team fixed this by limiting how many notes the agent could keep, requiring a person to approve any note that changed a business rule, and clearing the notes each week. Match rates recovered and stayed steady.

Common misconceptions and mistakes

Reflexion retrains the model. It does not change the model at all, and the learning lives only in text notes placed in the prompt, so it disappears if the notes are cleared.

More retries always mean better results. Gains usually flatten after a few attempts, and a weak evaluator can lead the agent to reinforce a wrong lesson, so set an attempt limit and check results.

The agent can judge its own work reliably. Self-assessment without an external signal is unreliable, and Reflexion works best when a test, rule or human review supplies the feedback.

Reflexion makes an agent safe to leave unattended. Written lessons can be wrong or can drift, so high-stakes steps still need human review and logged notes.

Business use

Start with a task that has a clear pass or fail check, such as a reconciliation that must balance or a document that must meet a format rule. Run the agent with a small cap on attempts, keep the reflection notes visible in logs, and compare results against a baseline without reflection. Measure success rate per attempt, the number of retries needed, cost per completed task and how often a person had to step in.

The main costs are extra model calls, added latency and the effort of building a trustworthy evaluator. The main risks are wrong lessons that persist, notes that leak sensitive data into later prompts, and loops that run longer than planned. Limit memory size, review notes that touch policy or money, and clear stored notes on a schedule. Practice varies, so test on your own data before relying on the gains.

People also ask

Is Reflexion the same as fine-tuning a model?

No. Fine-tuning changes the model's weights through additional training, while Reflexion only adds written notes to the prompt. The model itself stays the same.

Does Reflexion need a human in the loop?

Not always, since an automated test or rule can serve as the evaluator. A person is still wise for high-stakes tasks and for approving notes that change business rules.

When does Reflexion not help?

It helps little when there is no reliable feedback signal or when the task cannot be improved by retrying. In those cases it adds cost without better results.

Check your understanding

What are the three parts of a typical Reflexion loop?

Answer: An actor that attempts the task, an evaluator that judges the result, and a self-reflection step that writes a lesson saved to memory for the next try.

In the worked example, what was the success rate after the second pass?

Answer: 17 of 20 statements passed, which is 85 percent, up from 60 percent on the first pass.

What was the total model cost in the worked example?

Answer: 80 cents for the first pass, 40 cents for round two and 15 cents for round three, which adds up to 135 cents, or $1.35.

Why did Harbor Lane Supply limit and review the agent's notes?

Answer: One wrong note was applied to every carrier and raised errors. Capping memory and requiring approval for rule changes prevented a wrong lesson from spreading.

Related terms

  • ReAct
  • AI agent
  • Evaluation
  • Human-in-the-loop
  • Tool use
  • Chain-of-thought
  • Agent memory
  • Self-consistency

Learn next

Try a small loop on a task with an automatic pass or fail check, and log every reflection so you can read what the agent learned. Then read about ReAct and chain-of-thought to see how written reasoning supports agents, and about agent memory and evaluation to learn how to keep notes accurate and results measurable.

  • ReAct
  • Evaluation

More in Agents and automation

  • Rational agent - A rational agent is an agent that, given what it has perceived, chooses the action expected to achieve the best outcome according to its performance measure.
  • Reactive agent - A reactive agent is a software system that chooses each action by looking only at what it senses right now and applying fixed rules or a learned mapping...
  • Reflection - Reflection is a workflow strategy in which an AI system examines an earlier output or action result before deciding what to do next.
  • Robotic desktop automation - Robotic desktop automation, or RDA, is software that automates tasks on one person's own computer: it watches the desktop, helps with or performs repetitive...
  • Robotic process automation - Robotic process automation, or RPA, is software that performs repetitive, rule-based digital tasks by mimicking how a person uses applications: clicking...
  • Router agent - A router agent is an agent whose job is to decide where work goes: it reads an incoming request and directs it to the right specialist agent, tool, model or...

Sources

Yao et al., ReAct: Synergizing Reasoning and Acting in Language Models: https://arxiv.org/abs/2210.03629 Anthropic, Building effective agents: https://www.anthropic.com/engineering/building-effective-agents Wei et al., Chain-of-Thought Prompting Elicits Reasoning in Large Language Models: https://arxiv.org/abs/2201.11903 The sources were consulted for background on agent loops, written reasoning and practical agent design, while the examples, analogy, worked example and case are original educational illustrations. Checked 10 Nov 2026.

Previous: Reflective architecture Next: Reflexive Rule

  • Home
  • Daily AI Updates
  • Blog
  • AIFBL Academy
  • AI Glossary
  • Products and Tools
  • Store
  • Free CFO AI Prompt Pack
  • About Shihan Sheriff
  • Privacy Policy
  • Terms of Use
  • Refund Policy
  • Cookie Policy
  • Earnings Disclaimer