Language models that solve problems step by step often fail the same way, and at the same point, on problem after problem. They drop a domain restriction after squaring both sides. They confuse a maternal relative with a paternal one on the fourth hop of a family tree. Each wrong step becomes part of the text the model conditions on, so the error carries through to the final answer. Current memory systems for reasoning agents store lessons like "check the domain after squaring," but they choose which lessons to show by how similar the problem looks to past problems, and they show them once, before any work starts. The step where the lesson matters is often invisible from the problem statement alone.
We propose an external memory whose entries are error labels. Each entry is a short natural-language description of a failure type, paired with a fix. Every intermediate step the model writes is checked against these descriptions, the same way a zero-shot text classifier checks an input against class descriptions. When a step matches an error label, the paired fix is inserted before the model commits to that step. Two ideas from label-embedding work shape the design. The first is that describing classes in language lets a model recognize instances it has never seen phrased that way. The second is that such classifiers need a calibrated prior and a way to say "none of the above." Here the classes are the model's own recurring mistakes, and the memory grows and rewrites those descriptions as new failures appear.
Core Claim
Reasoning repair works better when a memory of lessons is triggered by the step being written than when it is retrieved by the problem being solved. Step-level triggering is only reliable if it is treated as a calibrated classification problem. That means verbalized error-label descriptions, a class prior estimated from memory statistics, and an explicit no-error class. The central test is a controlled ablation. We hold the memory contents fixed and change only when and how entries are surfaced.
Relation to Prior Work
Two recent systems motivate this proposal by showing that structured error knowledge helps. Textual Stochastic Gradient Descent treats an agent's memory as free-form heuristic strings that are edited through Add, Edit and Delete operations proposed and validated by LLM agents. It lifts Grok-4.1 to 68.0% on MATH Level 5. Its entries are retrieved at the problem level and have no defined matching semantics. We keep its capacity-bounded, validated editing loop but change the unit of memory and the moment it is used. DiagEvo builds a hierarchical memory of error causes that closely resembles our error labels, but uses it only offline to generate practice problems. At test time its solver has no memory. We use the same kind of content online, during inference.
Two step-level methods supply the inference loop and constrain the design. Step Guided Reasoning alternates between generating a hint and generating a step, and raises Qwen2-7B-Instruct from 37.1% to 58.6% on MATH Level 5. Its hints come only from the model's own weights, so it cannot recall a mistake it has made before. Evaluating Step-by-Step Reasoning through Symbolic Verification (LMLP) shows the value of checking each step against an external store. It maps each step to a knowledge-base predicate with Sentence-BERT and beats chain-of-thought by over 25% on long relational chains. That store is a fixed, closed-world set of facts. Ours is an open, growing set of described failure types, and it can be used where no symbolic knowledge base exists.
The classification machinery comes from label-embedding work. Gen-Z scores the likelihood of an input given a label description rather than the reverse. This reduces sensitivity to prompt wording and matches 8- and 16-shot in-context learning, but it assumes a uniform label prior. Label Verbalization and Entailment reaches 63% F1 zero-shot on TACRED (a relation-extraction benchmark) from verbalized templates, and names the no-relation class as the hard case. Our setting has both problems in extreme form. "This step is fine" is by far the most common outcome, and error types are long-tailed.
Label Organized Memory Augmented Neural Network supplies the memory policy. It indexes memory by class label, writes only when the base model's margin is low, and uses per-label replacement so frequent classes cannot overwrite rare ones. It explicitly leaves continuous, semantic label representations as future work, and our verbalized error labels are one answer to that open question.
Mechanism
The memory holds up to $B$ entries. Each entry $k$ has a description $d_k$, a fix $r_k$, a few example steps, and counts of how often it fired and how often firing was confirmed useful. At each reasoning step, a cheap dense-embedding filter picks the top $m$ candidate labels. Each candidate is then scored in the noisy-channel style of Gen-Z:
$$s_k = \log P(\text{step} \mid d_k, c) - \log P(\text{step} \mid c) + \log \pi_k ,$$
Here $c$ is the problem plus the steps written so far, and $\pi_k$ is the label's prior, estimated from its confirmed-hit count in memory. The first two terms measure how much the error description raises the likelihood of the step. The third term corrects Gen-Z's uniform-prior assumption. The no-error class is handled by a threshold $\tau$ tuned on held-out data. Only if the best-scoring label clears $\tau$ is its fix $r_k$ inserted, and the step regenerated.
The memory is built on a training split with checkable answers. When a trajectory fails, a diagnostician model finds the first wrong step. It then either attaches that step to an existing label or writes a new label. A new label is written only if no existing label explains the step with margin, following LMN's margin-gated writes. Descriptions are also edited. If a label fires on steps from trajectories that turned out correct, the diagnostician makes its description more specific. An edit is kept only if held-out accuracy does not drop, which is TSGD's global validation adapted to our setting. Eviction uses a utility score, but a minimum number of slots is reserved for rare labels.
Research Program
The work has three parts. The first builds the memory and the step-triggered decoder on two regimes. CLUTRR (CLUTRR) is a kinship benchmark with known gold proof chains, so every step's correctness can be checked automatically. MATH Level 5 is the realistic setting where errors are messy.
The second part measures error detection directly. On CLUTRR we report precision and recall of firing against steps known to be wrong, broken down by label frequency. This shows whether the prior and the no-error threshold actually handle the long tail and the dominant no-error class.
The third part tests transfer. We freeze the memory built on MATH and evaluate out of distribution on AIME 2024/2025. We also check whether CLUTRR labels learned from short chains fire correctly on 10-hop chains, the length-generalization regime where Evaluating Step-by-Step Reasoning through Symbolic Verification reports chain-of-thought collapsing.
The main model is Qwen2-7B-Instruct, chosen so that published SGR numbers apply directly. Qwen3-8B is a secondary model, which connects to DiagEvo's setting.
Baselines
The naive reference point is plain chain-of-thought on the same model. On MATH Level 5 the reported figure is 37.1% for Qwen2-7B-Instruct (Step Guided Reasoning). We rerun it under our own prompt and decoding settings.
The strongest parameter-free step-level competitor is SGR on the same model, reported at 58.6% on MATH Level 5. We rerun it with its 200–500 character step limits and duplicate detection. Our method runs inside the same guidance loop, so any gain can be attributed to the memory and not to the loop.
The strongest memory competitor is TSGD. It reports 68.0% on MATH Level 5 and 55.0% versus 41.46% on AIME, but on Grok-4.1. We found no reported TSGD result for Qwen2-7B on Lacuna, so we reimplement it on the same model, with the same training split, the same capacity $B$, and the same number of diagnostician and validator calls used to build our memory.
On CLUTRR the reference is LMLP, which reports over 25% higher accuracy than chain-of-thought on long chains. We found no reported per-length absolute numbers on Lacuna, so we rerun LMLP with its symbolic knowledge base as an upper reference. Note that it gets gold predicates, which our method does not.
Self-consistency is run at a matched total token budget, including our scoring passes.
Four ablations isolate the key ingredient. The first, and most important, keeps the memory contents fixed but retrieves entries once, by problem similarity, and prepends them. This is TSGD-style use of our memory. The second replaces generative scoring with dense cosine matching, as in LMLP's Sentence-BERT step. The third sets $\pi_k$ uniform. The fourth freezes descriptions after they are first written.
Beating the baselines means two things. Our method must exceed reimplemented TSGD and SGR on MATH Level 5 by more than seed variance, at no more tokens than self-consistency. It must also beat the problem-retrieval ablation.
Why not just…?
Why not just prepend retrieved lessons, as TSGD does? This is the real threat. If a model can apply a lesson it has read at the start of the problem at the right moment, step triggering adds only cost. TSGD's gains show that prepended lessons do help. Our bet is that they are diluted over long derivations, because the error step comes late and cannot be predicted from the problem text. The fixed-memory retrieval ablation settles this directly. If problem-level retrieval matches step triggering, we would report that the value lies in the error-label content, and drop the per-step classifier.
Why not just have the model check each step itself, with no memory? Per-step self-checking is essentially what SGR's guidance stage does, and it stays strong at 58.6%. DiagEvo reports, however, that models share systematic biases and confidently agree on wrong chains. A checker drawn from the same weights cannot flag a mistake it does not know it makes. Comparing against SGR, and against SGR plus an unguided "is this step correct?" query of matched cost, tests whether the written-down record of past failures adds anything.
Why not just sample more and vote? SGR reports that Best-of-32 costs far more tokens yet scores lower on MATH Level 5 than step guidance. Voting also fails exactly when errors are systematic. We still run self-consistency at matched tokens, because our scoring passes are not free.
Why not just fine-tune on the diagnosed failures, as DiagEvo does offline? Fine-tuning is a legitimate alternative, and DiagEvo's 72.3% five-benchmark mean on Qwen3-8B shows it works. The fixes cannot be edited or audited afterward, however, and they cannot absorb a new failure type without retraining. We compare against a DiagEvo-style fine-tune on Qwen3-8B as a secondary check, and also test whether our memory adds gains on top of that fine-tuned model.
Decisive Checks
The idea stands or falls on three results. The first is that step-triggered use beats problem-level retrieval of the identical memory on MATH Level 5 and AIME. The second is that on CLUTRR, detection precision on rare labels holds up only when the memory-based prior and the no-error threshold are present. That would show that label-embedding calibration, not retrieval alone, makes step-level triggering workable. The third is that labels learned on short CLUTRR chains keep firing correctly on 10-hop chains, where chain-of-thought is known to collapse. If the first check fails, the proposal reduces to a better way of writing TSGD's memory, and we would report it as that.
References
- Textual Stochastic Gradient Descent: Discrete Optimization of External Memory for Reasoning Language Agents
- DiagEvo: Diagnosis-Guided Self-Evolution via Hierarchical Error Memory
- Step Guided Reasoning: Improving Mathematical Reasoning using Guidance Generation and Step Reasoning
- Evaluating Step-by-Step Reasoning through Symbolic Verification
- Gen-Z: Generative Zero-Shot Text Classification with Contextualized Label Descriptions
- Label Verbalization and Entailment for Effective Zero and Few-Shot Relation Extraction
- Label Organized Memory Augmented Neural Network
- CLUTRR: A Diagnostic Benchmark for Inductive Reasoning from Text