Apply to my task
arXiv:2610.33029 ★ 95 Oct 12, 2026

Lessons from Luck: an agent's self-written lessons turn a random glitch into a rule

Key result

Finding: an agent that writes itself "lessons" commits ordinary bad luck to memory. The next run reads that lesson and starts choosing the worse tool. The method lets an agent with memory avoid turning one random failure into advice for the future. The lesson's author is made to evaluate the decision first, not the outcome, and is allowed to write "nothing needs to change." Example: a reliable tool (fails in 10% of runs) failed once. Without protection the lesson says: "it breaks, use the other one" (fails in 40%). The kicker: the model writes that advice not because there's new data, but because the instruction demands a conclusion from the failure. The protection sharply cuts false choices, but doesn't bring them to zero.

01

TL;DR

The study shows that an agent with memory that writes itself "lessons" after every run can commit pure bad luck to memory. The model sees a failure and turns it into advice for the future. The next session reads that advice and changes its decision. The fix is simple and lives in the instruction text: make the lesson's author evaluate the decision itself first, not the outcome, and allow it to write "nothing needs to change".

Anyone who has set up self-learning agents knows the pain. There are two interchangeable tools: a reliable one (fails in 10% of runs) and an unreliable one (fails in 40%). The reliable one failed once for a random reason. The agent writes a lesson: "this approach breaks, use the other one." The next session sees in the log that the reliable tool is better. But the lesson sounds convincing, and in some cases it picks the worse tool. Without the lesson, that choice practically never happens. The model judges the decision by its outcome, not by what was known at the moment of deciding. The lesson locks in this error and makes it long-lived.

The method comes in two variants. First: add a three-sentence item to the lesson-writing instruction. "Judge whether the decision was sound given the information available before the outcome. A single outcome proves nothing. Recommend a different action only if the decision was unsound." Second: one and the same instruction for success and failure, plus the line "if nothing needs to change, say so." Both variants sharply reduce false choices but don't eliminate them entirely.

Want this for your own case? Apply this study to your task: AI adapts its method to what you are working on and writes the prompt.

02

Method Blueprint

WITHOUT PROTECTION (how it breaks):
  Run → outcome (random failure) → instruction "draw a conclusion from the failure"
        → lesson "don't use X" → the next session picks the worse option

WITH PROTECTION (variant 1, decision-evaluation item):
  STEP 1: The lesson's author judges the decision on the data BEFORE the outcome → verdict "sound / unsound"
  STEP 2: One outcome ≠ evidence → advise changing the action only if "unsound"

WITH PROTECTION (variant 2, neutral instruction):
  STEP 1: One instruction for success AND failure (no separate "routing")
  STEP 2: An explicit "nothing needs to change" option → the lesson can be empty

ADDITIONALLY: in the reader's log/context — an explicit line that failures are random and independent

Everything happens in one instruction prompt. No separate requests are needed.

03

Example in Practice

Task: You run an online store on Shopify and have set up an agent (Claude Code or an n8n workflow). Every night it exports orders to a Google Sheet. There are two ways to do it. The API export has succeeded in 92% of the last 300 runs. A Google Apps Script succeeds in 60%. After each run the agent appends "lessons" to a LESSONS.md file and reads it before the next run. Yesterday the API export failed once with "timeout, try again later." Without protection, the agent will write "the API is unstable, use the script," and a week later half the exports will be going the worse way.

Prompt (excerpt from the lesson-writing instruction):

You are an expert in running operational tasks. You are given the log of a single run.
Extract up to 3 memory items from it for future runs: a title, a short description, the content.

Before writing:
- Judge whether the agent's decision was sound based only on what was known BEFORE the outcome.
- A single outcome by itself does not prove the decision was right or wrong.
- Recommend a different action only if the decision was unsound given that information.

If nothing about how the task should be done needs to change, say so.

Context: nightly export of store orders to a Google Sheet.
Methods: API export and an Apps Script. According to the log of 300 runs,
the API succeeds in 92% of runs, the script in 60%. They cost the same.
Failures of either method are independent one-off events; a past run does not affect the next one.

Result: The lesson's author first writes an evaluation of the decision: choosing the API was justified by the log. Then it notes that a single timeout changes nothing. Memory ends up with a "no need to change the method" entry or a neutral remark. There should be no "use the script" advice. The next session sees a short note in LESSONS.md, not a recommendation to abandon the API.

04

Why It Works

The weakness. A model told to "draw a conclusion from the failure" looks for what exactly broke and what needs to change. The instruction assumes something must change, and the model complies. The lesson sounds like experience even though it contains no new information: everything in it was already in the log. But the reader doesn't know that and treats the lesson as accumulated experience.

The strength. A model can distinguish "the decision was reasonable" from "the result turned out badly" if you explicitly ask it to before it writes a conclusion. It can also write "nothing to change" if that option is allowed.

How the method uses this. The decision-evaluation item makes the model go through the "before the outcome" data first, and only then write advice. The "change nothing" option removes the pressure to "recommend something." A line in the log saying "failures are independent" helps the reader tell chance from breakage on its own.

Control knobs: - The decision-evaluation item → add it if lessons are written after failures. The effect is strong but not complete. - The "nothing needs to change" option → the strongest knob tested. Use it with one shared instruction for success and failure. - The line "failures are independent, one-off events" in the log/context → greatly reduces the effect, but only if it's actually true for your task. - The instruction's shape → avoid "separate instructions for success and failure." In the original, the failure instruction asked for "concrete actionable recovery procedures" and nudged toward changing the action.

05

Prompt Template

This is an instruction template for an agent that writes lessons to memory (in CLAUDE.md, LESSONS.md, a custom GPT's memory field, or a "Save to Memory" node in n8n).

You are an expert in {task_domain}. You are given the log of a single run: the task, the steps, the result.
Write up to {number} memory items for future runs: a title, a short description, the content.

Before writing:
- Judge whether the agent's decision was sound based only on what was known BEFORE the outcome.
- A single outcome by itself does not prove the decision was right or wrong.
- Recommend a different action only if the decision was unsound given that information.

If nothing about how the task should be done needs to change, say so.

Task background: {context_and_stats_per_method}.
{independence_of_failures_line_if_true}

Fill in like this: - {task_domain} — what the agent does: exports, email campaigns, report building. - {number} — how many items it may write (up to three in the original). - {context_and_stats_per_method} — what's known about each option's reliability: how many runs, what success rates. - {independence_of_failures_line_if_true} — for example: "There have been no chains of failures: every failure of either method is a one-off independent event."

🚀 Quick start — paste into the chat:

Here is an instruction template for an agent writing lessons. Adapt it to my task: [your task].
Ask me questions to fill in the fields.

[paste the template above]

The LLM will ask which methods the agent has, how often each one works and whether failures can be treated as independent. That's needed so the lesson's author can judge the decision on the data before the outcome, not on the result.

06

Limitations

⚠️ The protection isn't complete: with the decision-evaluation item, a noticeable share of false choices remains. With the neutral instruction there are fewer, but they still exist. The authors didn't show that either protection works for every model.

⚠️ Models behave differently: lessons carried chance forward for some models (Gemini, Grok, Qwen, DeepSeek, Mistral, Kimi). For Claude models and GPT-6.1 Sol the effect was bounded from above (upper bound below the threshold), but "bounded" doesn't mean "zero." For Haiku and GPT-6 Luna the estimate was small but positive. Don't assume your model is safe.

⚠️ The neutral variant N was compared as a "bundle": it differs from the original in two things at once (no separate instruction for success and failure, plus a "change nothing" option). Which of the two parts produces the effect is unknown.

⚠️ Tested only on "noisy" outcomes: the protection was tested on cases where the outcome didn't point to a real tool breakdown. If the tool really did break, the "nothing needs to change" line could do harm. The authors didn't test this.

⚠️ Depends heavily on what the log says: where the log didn't state that failures are independent, the effect was several times larger. If failures in your task are actually linked (say, a real API outage), you must not write the independence line.

⚠️ Synthetic and single-step: a lab world, one choice between two tools, one lesson read once. Lesson accumulation, memory retrieval and real agents weren't tested. How often such situations arise in real agents is unknown.

⚠️ No proof of harm after "luck": after a lucky success of the worse tool, the effect was bounded from above. That's a bound, not proof that there's no harm.

07

How They Studied It

The author built 256 "worlds." Each world is a recurring work task (data export, sending invoices, rebuilding a search index) with two equally priced tools. The reliable one succeeds 80–93% of the time, the unreliable one 50–70%, and the log shows the last 180–365 runs. Then the "previous run" scenario was set by hand: use the reliable or unreliable tool, and end in success or a random failure. One model wrote a "lesson" from that run using the ReasoningBank instruction (a memory method for agents). Then a fresh session of the same model, holding the full log and the previous run's result, chose which tool to try first. It was given one of eight memory snippets: its own lesson, a lesson from the opposite outcome, a neutral fact, a direct "use the worse one" command and others.

The key design idea: the reader sees exactly what it would see without the lesson, plus one extra piece of text. So any difference in choice can be attributed only to the lesson. The protocol was frozen and timestamped on a blockchain before the first query. 11 models produced about 90 thousand responses.

The result was unexpected: after a random failure of the reliable tool, the lesson written from that failure steered readers to the worse tool in 11.6% of runs. With a neutral fact it was 0.4%, and with a lesson from a success, also 0.4%. And the lesson only does harm together with the failure report: after a success, the same lesson gave 0.2%. The line "failures are independent" in the log cut the effect from 0.181 to 0.042. Two additional techniques brought the rate down to 7.5% (the decision-evaluation item) and 3.1% (the neutral instruction). But neither met the pre-specified rule "harm reduced on every model."

A curious detail: for two models, a weak response to the bare "use the worse one" command went together with a strong response to lessons. A lesson with reasoning persuades better than an order with no reason.

08

Original from the Study

The full texts of the ReasoningBank (RB) instructions are in Appendix A, which isn't in the input data. So I quote verbatim only what appears in the body of the paper.

The added RBD item (protection #1, three sentences):

Before writing, judge whether the agent's decision was sound given only what was known before the outcome. A single outcome is not by itself evidence that the decision was right or wrong. Recommend a different action only if the decision was unsound given that information.

The added line in the neutral instruction N (protection #2):

If nothing about how the task should be done needs to change, say so.

The hint line in the log (explicit worlds):

There have been no outages: failures of either tool are independent one-off events, and the next run has always started normally.

Context: RBD is the RB instruction plus one item. N is RB's success instruction rewritten neutrally, with no separate handling of success and failure, plus one line.

09

Adaptations and Extrapolations

These are my transfers of the paper's ideas; the authors didn't test them.

💡 Adaptation for manual work in chat: if you ask ChatGPT or Claude to "draw conclusions" after a failed email campaign or pitch, don't ask "what went wrong." Ask: "Judge whether the decision was reasonable given the information I had before the result. If nothing needs to change, say so."

🔧 Technique: introduce a repetition threshold → less noise in memory. You can add to the agent's instruction file: "Don't record a recommendation to abandon a method after a single failure. Record the fact of the failure without a recommendation; recommend only if the failure repeats." The idea follows from the paper's logic (one outcome ≠ evidence), but the repetition threshold wasn't tested.

🔧 Technique: audit the lessons file → catch entrenched "false rules." Periodically ask the model: "Go through LESSONS.md. For each item: is it based on a single outcome? Flag those." This wasn't tested in the paper.

10

Resources

  • Title: Lessons from Luck: Do LLM-Written Lessons Carry Chance into an Agent's Next Decision?
  • Author: Kazuki Nakayashiki, Glasp.
  • Works cited: ReasoningBank (Ouyang et al., 2025), Reflexion (Shinn et al., 2023), ExpeL (Zhao et al., 2023), Agent Workflow Memory (Wang et al., 2024), Dynamic Cheatsheet (Suzgun et al., 2025).
  • Classics on outcome bias: Baron & Hershey (1988), Fischhoff (1975).
  • Preregistration: Zenodo deposit (doi:10.5281/zenodo.23253562).

Research digest

Key result

Finding: an agent that writes itself "lessons" commits ordinary bad luck to memory. The next run reads that lesson and starts choosing the worse tool. The method lets an agent with memory avoid turning one random failure into advice for the future. The lesson's author is made to evaluate the decision first, not the outcome, and is allowed to write "nothing needs to change." Example: a reliable tool (fails in 10% of runs) failed once. Without protection the lesson says: "it breaks, use the other one" (fails in 40%). The kicker: the model writes that advice not because there's new data, but because the instruction demands a conclusion from the failure. The protection sharply cuts false choices, but doesn't bring them to zero.

Principle

The usual instruction says: "draw a conclusion from the failure." The model hears: "something broke, find what to change." And it finds something, even if nothing was broken. The protection works in two moves. First: evaluating the decision before the outcome. The lesson's author looks only at what the agent knew at the moment of choosing. One outcome proves nothing. Advice to change the action is allowed only if the decision was unsound. Second move: one shared instruction for success and failure, plus an explicit "nothing needs to change" option. An empty lesson becomes a legitimate answer, and the model doesn't have to invent advice for advice's sake. Picture a doctor. A patient survived a foolish treatment, and the doctor writes down "great method." Another patient died despite sound treatment, and the doctor writes "this method is worthless." The protection forces a check of the treatment first, and only then a look at the outcome.

Why it works

The model's weakness. The log already had everything needed: 300 runs, 92% success for the API and 60% for the script. But the lesson sounds like accumulated experience even though it contains zero new information. The reader agent trusts it more than its own numbers. Without the lesson, that wrong choice practically never happens. The lesson itself creates an error that wasn't in the data: it makes chance long-lived. The strength. Asked explicitly, a model distinguishes "the decision was reasonable" from "the result turned out badly." It just has to do this before writing a conclusion. And it needs permission to answer "nothing to change." One more knob: a line in the log saying "failures are independent, one-off events." It helps the reader tell chance from breakage on its own. But you can only write it if it's true. Without it, the error effect is several times larger. Honest limitations. The experiments ran in a synthetic world: one choice between two tools, one lesson. Models behave differently. For some (Gemini, Grok, Qwen, DeepSeek, Mistral, Kimi), lessons carried chance forward. For Claude and GPT-6.1 Sol the effect is bounded from above, but not zero. Which part of the neutral variant produces the effect is also unknown: the shared instruction or the "change nothing" option.

When to apply

Agents with memory → specifically for tasks with two interchangeable methods of different reliability, especially when lessons are written after every run. Examples: nightly exports, email campaigns, report building, `LESSONS.md` and `CLAUDE.md` files, a "Save to Memory" node in n8n. NOT a fit if failures are linked, e.g. during a real API outage. Then the "failures are independent" line is harmful, and "nothing needs to change" could do damage. The authors didn't test such cases. Don't assume your model is automatically safe, either.

Mini recipe

1. Find where lessons get written: a memory file, an n8n node or a field in a custom GPT. That's where the new instruction goes. 2. Replace "draw a conclusion from the failure" with three rules: judge the decision on the data BEFORE the outcome. One outcome proves nothing. Change the action only if the decision was unsound. 3. Provide an exit: add the line `If nothing about how the task should be done needs to change, say so.` It's the strongest knob tested. 4. Use one instruction for success and failure: don't write a separate "failure analysis" with recovery procedures. It nudges toward changing the action. 5. Put the numbers in context: how many runs there were and each method's success rate. 6. Add the independence line only if it's true: `Every failure of either method is a one-off independent event.` 7. Test on your own model: feed it a random failure of the reliable method. See whether "use the other one" advice shows up in memory.

Examples

[BAD]: `Analyze the run log and draw a conclusion from the failure. Write down what needs to change.` [GOOD]: `You are an expert in nightly order exports. You are given the log of a single run. Write up to 3 memory items: a title, a short description, the content. Before that, judge whether the decision was sound based only on what was known BEFORE the outcome. A single outcome by itself proves nothing. Recommend a different action only if the decision was unsound. If nothing needs to change, say so. Background: the API export succeeds in 92% of 300 runs, the Apps Script in 60%. Failures of either method are one-off independent events.` Result: a single API timeout no longer turns into an entry saying "the API is unstable, use the script." `LESSONS.md` gets a short note: "Choosing the API was justified, no need to change the method."

In plain words

Autonomous agents with memory have a dumb vulnerability — they confuse pure chance with a systemic error. Tell a model "learn from this failure" and it will dutifully invent a rule where there was just a momentary glitch. An LLM can't tell noise from signal, so a single timeout becomes a "fatal defect" that urgently needs fixing.

It's like hitting traffic on the freeway once and deciding: "that's it, the highway's broken, from now on I'm always taking the potholed dirt road". Technically you responded to a problem, but in reality you traded 92% reliability for a janky alternative with a measly 60% success rate. The model behaves exactly the same way: it takes a one-off flick on the nose and panics, wrecking a perfectly good workflow.

The fix for this nonsense is dead simple: correct the reflection prompt. Hammer two rules into the instruction: first evaluate the logic of the decision, not the result itself, and explicitly allow the agent to return a "nothing needs to change" verdict. Once the model has a legitimate right to chalk an incident up to plain bad luck, it stops scribbling panicked advice into its log and killing its own effectiveness.

The study ran basic tasks, but the principle is universal. Anyone building workflows in n8n, running Claude Code or hooking agents up to recurring data scraping will hit this. If your bot keeps long-term memory and reads its old notes before every step, it will inevitably turn a random server hiccup into a law of nature and start to degrade.

Bottom line: don't let the model be "too diligent" when the world just threw a random glitch. Either you teach the agent to ignore noise, or in a couple of weeks your automation turns into a broken, duct-taped hell. One right sentence in the system instruction saves hours of debugging — just let the agent admit it simply got unlucky.

AI lab assistant

Apply this study to your task

Describe what you're working on. AI takes the method and the measured results from this paper and adapts them to your case, or writes a ready prompt built on them.

Based on Lessons from Luck: an agent's self-written lessons turn a random glitch into a rule arXiv:2610.33029

Sign in to apply this study New accounts get 50 free credits.