Causal Episodic Memory for Feedback-Driven Agent Repair

AuthorsKhang Nhat Hoang Vo, Tam Minh Chu, Anh Trac Duc Dinh et al.

arXiv 20262026

TL;DR

MERIT uses causal dual-polarity, error-typed episodic memory to guide Text-to-SQL repair, raising Spider execution accuracy from 66.34% to 69.79% without training.

SharePost on XLinkedIn

Read our summary here, or open the publisher PDF on the next tab.

THE PROBLEM

Cross-query repairs are forgotten despite 66.34% execution accuracy ceiling

LLM agents that repair failures often discard successful corrections, forcing later episodes to rediscover similar solutions from scratch.

In Text-to-SQL, this means recurring schema linking and aggregation errors persist, limiting reliability even when execution-guided repair raises accuracy only from 58.90% initial to 66.34% with Iterative repair.

HOW IT WORKS

MERIT — Causal episodic memory with error-typed hybrid retrieval

MERIT’s core mechanism links a Deterministic Error Classifier, Online Dual-Polarity Memory, Error-Typed Hybrid Retriever, and Type-Reliability-Aware Retrieval Variant around a frozen Qwen2.5-7B-Instruct parser.

You can think of MERIT like a programmer’s notebook: it files past fixes by error type and success polarity, then pulls the most relevant pages when a similar bug reappears.

This structured episodic memory lets MERIT reuse verified repair transformations across queries, something a plain context window with stateless Iterative repair cannot achieve.

DIAGRAM

Causal online repair loop for a single Text-to-SQL query

This diagram shows how MERIT iteratively classifies failures, retrieves typed memories, and generates repairs under a causal memory constraint within one episode.

DIAGRAM

Evaluation pipeline and ablation design for MERIT

This diagram shows how MERIT is evaluated across Spider and BIRD with shared initial predictions, multiple stream orders, and ablation variants.

PROCESS

How MERIT Handles a Causal Online Repair Episode

  1. 01

    Causal Online Repair Formulation

    MERIT defines each initially incorrect query as an episode with history H(k)_t and a repair budget K = 7, under oracle-assisted benchmark feedback.

  2. 02

    MERIT: Correction and Experience Accumulation

    MERIT uses the Deterministic Error Classifier to label failures, then consults the Online Dual-Polarity Memory and Error-Typed Hybrid Retriever before each new repair generation.

  3. 03

    Causal Type Conditioned Retrieval

    MERIT constructs same-polarity candidate pools, filters by failure type when |Tt,p| ≥ 3, and ranks with a hybrid lexical–dense score r(x,u) = 0.75 bd + 0.25 bb.

  4. 04

    Type-Reliability-Aware Retrieval Variant

    MERIT optionally applies the Type-Reliability-Aware Retrieval Variant, using h(τ) to relax type filtering and add a 0.10 bonus for same-type matches on lower-reliability categories.

KEY CONTRIBUTIONS

Key Contributions

  • 01

    Causal episodic memory for Text-to-SQL correction

    MERIT formulates Text-to-SQL correction as causal episodic memory, where the Online Dual-Polarity Memory only exposes finalized episodes and improves Spider execution accuracy by +3.45 points over Iterative repair.

  • 02

    Error-guided hybrid retrieval with polarity and type

    MERIT’s Error-Typed Hybrid Retriever organizes experience by outcome polarity and failure type, then ranks precedents using a 0.75 dense and 0.25 BM25 hybrid score.

  • 03

    Controlled evaluation across streams and memory designs

    MERIT is evaluated over three stream orders on Spider and BIRD, comparing against Iterative, Dynamic RAG, and Reflexion-style memory while matching initial predictions and a repair budget K = 7.

RESULTS

By the Numbers

Exec. accuracy Spider

69.79%

+3.45 over Iterative

Exec. accuracy BIRD

48.44%

+1.09 over Iterative

Repaired failures Spider

112.7

+35.7 repaired vs Iterative

Tokens Spider

5.274M

about 2.745M more than Iterative

On Spider and BIRD development sets, which test cross-domain and large-schema Text-to-SQL, MERIT shows that causal cross-query memory can improve repair without parameter updates. The +3.45 point Spider gain over Iterative repair demonstrates that structured episodic memory meaningfully increases execution accuracy under identical initial predictions.

BENCHMARK

By the Numbers

On Spider and BIRD development sets, which test cross-domain and large-schema Text-to-SQL, MERIT shows that causal cross-query memory can improve repair without parameter updates. The +3.45 point Spider gain over Iterative repair demonstrates that structured episodic memory meaningfully increases execution accuracy under identical initial predictions.

BENCHMARK

Execution accuracy over three stream orders on Spider

Exec. accuracy on Spider development set with Qwen2.5-7B-Instruct and K = 7 repair budget.

BENCHMARK

Execution accuracy over three stream orders on BIRD

Exec. accuracy on BIRD development set with Qwen2.5-7B-Instruct and K = 7 repair budget.

KEY INSIGHT

The Counterintuitive Finding

MERIT is not reliably separated from Dynamic RAG on either benchmark, tying at 69.79% on Spider and differing by only +0.28 points on BIRD.

This is surprising because MERIT’s carefully structured polarity and error-type organization might be expected to clearly beat untyped retrieval, but the results show simpler memory designs can be nearly as effective.

WHY IT MATTERS

What this unlocks for the field

MERIT shows that training-free, causal episodic memory can systematically reuse execution-verified SQL corrections across queries to improve repair accuracy.

Builders can now design Text-to-SQL agents that learn from prior failures online, tuning memory polarity, error typing, and schema-local retrieval without touching backbone parameters.

~14 min read← Back to papers

Related papers

BenchmarkAgent Memory

Active Context Compression: Autonomous Memory Management in LLM Agents

Nikhil Verma

· 2026

Focus Agent adds start_focus, complete_focus, a persistent Knowledge block, and an optimized Persistent Bash plus String-Replace Editor scaffold to actively compress context during long software-engineering tasks. On five hard SWE-bench Lite instances against a Baseline ReAct agent, Focus Agent achieves 22.7% token reduction (14.9M → 11.5M) while matching 3/5 = 60% task success.

Questions about this paper?

Paper: Causal Episodic Memory for Feedback-Driven Agent Repair

Answers use this explainer on Memory Papers.

Checking…