Agent Memory Distillation

Empowering Small LLM Agents with Hierarchical Teacher Memory

Taeil Kim1*  ·  Kangsan Kim1*  ·  Sung Ju Hwang1,2
1KAIST    2DeepAuto.ai
*Equal contribution
Paper Code BibTeX
Teacher GPT-5-mini successful trajectories distill HIERARCHICAL MEMORY Workflow Task-level strategy & plan Subtask Concrete behavioral examples Function Per-function call guides & pitfalls proactive on error Student 4B to 8B ↑ teacher-level accuracy
Teacher trajectories → Workflow · Subtask · Function memory, injected proactively before execution and reactively on error.
AppWorld · Qwen3-4B
+34.5%p

Largest accuracy jump. Closes 99% of the gap to its teacher.

Zero-shot
14.88
AMD
49.40
Teacher
50.00
BFCL V3 · Qwen3-4B
+23.0%p

The student surpasses its teacher without a single gradient update.

Zero-shot
15.50
Teacher
36.50
AMD
38.50
Parity, training free
49.4vs. 50.0

A 4B model reaches teacher-level accuracy on AppWorld. Zero fine-tuning, memory only.

Teacher
50.00
AMD (4B)
49.40
TL;DR

Small agents can't learn from their own failures. Give them the teacher's memory instead.

Small agents rarely succeed enough to build useful memory, and naive teacher-memory transfer fails on the capability gap. AMD closes it, training-free, with memory at three granularities: Workflow plans, Subtask examples, and Function call guides.

(A) STUDENT MEMORY

Too few successes

Memory banks dominated by failed trajectories. Self-evolution stalls.

(B) NAIVE TRANSFER

Advice it can't execute

"Log in first" is useless if the student doesn't know how to log in.

(C) AMD

Knowledge at every level

Plans + worked examples + call guides bridge the capability gap.

Method

Three memories, two injection modes

Built only from successful teacher trajectories. Planning knowledge arrives before execution; corrective knowledge arrives at the moment of failure.

Task level

Workflow

Verbalized strategy with typed placeholders (<ID>, <EMAIL>).

⚡ Proactive · system prompt
Subtask level

Subtask

Coherent segments with the teacher's executable code + observations.

⚡ Proactive · per subtask
Function level

Function

Per-call records: masked args, returns, and the teacher's reasoning.

🔁 Reactive · on error
Results

Students approach and even surpass their teacher

AMD beats every memory baseline on every model × benchmark, while baselines often fall below zero-shot. It also cuts interaction turns toward the teacher's efficiency.

Table 1 · Main results on three agentic benchmarks Accuracy (%) · higher ↑
Teacher AMD (ours) Δ gain vs. zero-shot Bars show 0 to 100
Method AppWorld BFCL V3 ToolSandbox
Teacher Agent
GPT-5-mini 50.00 36.50 28.68
Student · Qwen3-4B
Zero-shot 14.88 15.50 16.28
ReasoningBank 10.71 24.25 16.28
MemP 16.67 28.25 14.73
SASM 15.48 15.25 18.22
AMD (ours) 49.40 38.50 20.16
Δ vs. zero-shot +34.5 +23.0 +3.9
Student · Gemma4-E4B
Zero-shot 24.40 37.25 18.22
ReasoningBank 30.36 40.25 15.12
MemP 20.83 35.25 15.89
SASM 22.02 36.75 12.40
AMD (ours) 54.17 46.00 21.71
Δ vs. zero-shot +29.8 +8.8 +3.5
Student · Qwen3-8B
Zero-shot 25.60 38.00 20.16
AMD (ours) 51.79 45.50 25.58
Δ vs. zero-shot +26.2 +7.5 +5.4
Student · Llama3.1-8B
Zero-shot 8.93 9.00 5.43
AMD (ours) 27.38 14.50 6.20
Δ vs. zero-shot +18.5 +5.5 +0.8
How to read: Numeric bars scale 0 to 100. Blue rows are AMD (best in group, marked ). Green Δ pills are gain over zero-shot: darker green means larger jump. AMD is the only method that consistently beats zero-shot across every benchmark and model.
Analysis

What makes distillation work

Five ablations answer: which memory matters most, which teacher is best, which student sizes benefit most, how many memories to retrieve, and how to represent them.

Table 2 · Which memory levels matter? Accuracy (%) · higher ↑
Method AppWorld BFCL V3
Qwen3-4BQwen3-8B Qwen3-4BQwen3-8B
Zero-shot 14.88 25.60 15.50 38.00
WF 22.02 30.36 35.50 40.00
WF + FN 24.11 33.93 35.50 41.50
WF + ST 47.02 51.19 37.50 45.50
WF + ST + FN (AMD) 49.40 51.79 38.50 45.50
Student Memory 16.07 29.76 27.00 43.00
Takeaway: Subtask memory carries the biggest jump. Adding ST on top of WF is worth +25.0 %p on AppWorld (Qwen3-4B). Student-collected memory alone barely moves the needle.
Table 3 · Which teacher works best? AppWorld · higher ↑
Teacher Teacher Acc Qwen3-4B Qwen3-8B
Zero-shot n/a 14.88 25.60
GPT-5.5 91.08 47.02 58.93
DeepSeek V4 Pro 81.55 38.10 57.14
GPT-5-mini 50.00 49.40 51.79
Qwen3-32B 34.42 29.76 39.29
Takeaway: Stronger ≠ better teacher for 4B students. GPT-5-mini (50 %) beats DeepSeek V4 Pro (82 %) as a teacher for Qwen3-4B. Accessible knowledge matters more than raw accuracy. = best per column, underline = 2nd.
Table 4 · Prose or code, per level? Qwen3-4B · AppWorld
Workflow Subtask Function Accuracy
CodeCodeCode44.05
TextCodeCode49.40
TextTextCode23.21
TextCodeText47.62
TextTextText26.19
Takeaway: Prose for plans, code for execution. All-prose collapses to 26.2 %. Replacing execution-level memory with prose kills accuracy. AMD's default (Text/Code/Code) is best.
FIGURE 4 · MODEL SIZE

4B students benefit most

Absolute gain peaks at +34.5 %p for Qwen3-4B; larger models close the gap without help.

FIGURE 5 · RETRIEVAL COUNT

Retrieve one, not many

k = 1 is near-optimal. Subtask accuracy collapses 49.4 to 33.3 as k grows to 5. Quality beats quantity.

ROBUSTNESS · Appendix B.3

Gains survive disjoint evaluation

Under cross-split (7:3) and self-excluded retrieval, hierarchical memory still gives monotonic gains: evidence of genuine transfer, not task overlap.

Case Study

Each memory fixes a distinct failure

One Venmo task, three cascading failures. Workflow fixes the month-scope filter, Subtask escapes a date-parsing loop, Function fixes a dict-key crash. All three were necessary: ✓ solved in 7 steps.

Citation

BibTeX

@misc{kim2026agentmemorydistillationempowering,
      title={Agent Memory Distillation: Empowering Small LLM Agents with Hierarchical Teacher Memory},
      author={Taeil Kim and Kangsan Kim and Sung Ju Hwang},
      year={2026},
      eprint={2608.07169},
      archivePrefix={arXiv},
      primaryClass={cs.AI},
      url={https://arxiv.org/abs/2608.07169},
}