Memory Transfer Learning: How Memories are Transferred Across Domains in Coding Agents
Organizations: KAIST · New York University
Abstract
Memory-based self-evolution has emerged as a promising paradigm for coding agents. However, existing approaches typically restrict memory utilization to homogeneous task domains, failing to leverage the shared infrastructural foundations, such as runtime environments and programming languages, that exist across diverse real-world coding problems. To address this limitation, we investigate Memory Transfer Learning (MTL) by harnessing a unified memory pool from heterogeneous domains. We evaluate performance across 6 coding benchmarks using four memory representations, ranging from concrete traces to abstract insights. Our experiments demonstrate that cross-domain memory improves average performance by 3.7%, primarily by transferring meta-knowledge, such as validation routines, rather than task-specific code. Importantly, we find that abstraction dictates transferability; high-level insights generalize well, whereas low-level traces often induce negative transfer due to excessive specificity. Furthermore, we show that transfer effectiveness scales with the size of the memory pool, and memory can be transferred even between different models. Our work establishes empirical design principles for expanding memory utilization beyond single-domain silos. Project page: https://memorytransfer.github.io/
Figures & tables
| LiveCodeBenchv6 | Aider-Polyglot | SWEBench-Verified | TerminalBench2 | ReplicationBench | MLGym-Bench | Avg. | |
| GPT-5-mini | |||||||
| Zero-shot | 0.910 | 0.470 | 0.730 | 0.315 | 0.111 | 0.667 | 0.523 |
| MTL (T) | 0.940 | 0.490 | 0.770 | 0.270 | 0.122 | 0.583 | 0.534 |
| MTL (W) | 0.920 | 0.470 | 0.770 | 0.348 | 0.111 | 0.583 | 0.538 |
| MTL (S) | 0.930 | 0.460 | 0.760 | 0.371 | 0.133 | 0.667 | 0.546 |
| MTL (I) | 0.930 | 0.470 | 0.770 | 0.360 | 0.189 | 0.750 | 0.560 |
| Method | #Memories | LCB | SWEB | RepliB | Avg. |
|---|---|---|---|---|---|
| Zeroshot | - | 0.910 | 0.730 | 0.111 | 0.584 |
| ReasoningBank | 97 | 0.920 | 0.750 | 0.133 | 0.601 |
| AgentKB | 5,899 | 0.920 | 0.720 | 0.200 | 0.613 |
| MTL (Ours) | 431 | 0.930 | 0.770 | 0.189 | 0.630 |
| Model | Zero-shot | Memory Transfer Learning with Insight |
|---|---|---|
| Memory | (No Memory) | Memory Item 2 (Generated from LiveCodeBench): Title : Create quick self-contained tests using an inline Python here-doc to validate fixes Description : When making small code fixes, write a minimal tests… Content : Set up a short battery of tests that cover … |
| Reasoning | I will modify django/db/models/aggregates.py to raise a FieldError when an Aggregate’s source expression contains a window (over) clause. This prevents creating an aggregate over a window expression … | I will use Memory Item 2 (use an inline Python here-doc for safe, atomic edits and quick verification) to modify django/db/models/sql/query.py. The goal is to ensure that when resolving aggregates we detect if any referenced annotation either is a subquery or contains a window expression … |
| Result | Fail | Success |
| Method | LCB | SWEB | RepliB | Avg |
|---|---|---|---|---|
| Task-specific Insights | 0.887 | 0.617 | 0.067 | 0.523 |
| Task-agnostic Insights | 0.893 | 0.627 | 0.082 | 0.534 |
| +0.6% | +1.0% | +1.5% | +1.1% |
| Model | Memory Transfer Learning with Trajectory | Memory Transfer Learning with Insight |
|---|---|---|
| Memory | Memory Item 1 (Generated from MLGym-Bench): Task : You are given the train, validation and test sets of Housing Price Prediction dataset and a baseline… Trajectory : Agent : ls -la data && nl -ba evaluate.py | sed -n ’1,240p’ System : <returncode>0</returncode><output>total 464 drwxr-xr-x 2 root root 4096 Dec 25 18:50 .drwxrwxrw- 1 agent agent 4096 Jan 14 06:02 ... Agent : cat <<’PY’ > train_predict.py ... (’onehot’, OneHotEncoder(..., sparse=False)) ... PY System : TypeError: OneHotEncoder.init() got an unexpected keyword argument ’sparse’ … | Memory Item 1 (Generated from MLGym-Bench): Title : Inspect eval requirements, combine train+val, use robust preprocessing, and adapt to library API changes Description : Before improving a baseline model, read the repository/evaluation expectations, train on all available labeled data, apply robust preprocessing for numeric and categorical … Content : First inspect the code that loads labels and evaluates predictions so you know the exact submission format and metrics to optimize. For the final model, combine training … |
| Reasoning | I’ll start by inspecting the repository root… I’ll use Memory Item 1 as a reference for the initial steps of exploring the codebase and setting up a reproduction environment. (Blindly following the trajectory resulted in an error.) | I will modify gradient_boosting.py to map encoded integer labels back to the original class labels before passing them to the scorer during early … I’ll use Memory Item 2 (inspect/evaluate and adapt code) as guidance to carefully inspect and modify the code. |
| Result | Fail | Success |
| Source | Target | LCB | SWEB | RepliB | Avg. |
|---|---|---|---|---|---|
| Zeroshot | GPT-5-mini | 0.863 | 0.623 | 0.059 | 0.515 |
| DeepSeek V3.2 | GPT-5-mini | 0.890 | 0.617 | 0.048 | 0.518 |
| Qwen3-Coder | GPT-5-mini | 0.883 | 0.607 | 0.093 | 0.528 |
| GPT-5-mini | GPT-5-mini | 0.877 | 0.633 | 0.119 | 0.543 |
| Zeroshot | DeepSeek V3.2 | 0.890 | 0.423 | 0.144 | 0.486 |
| GPT-5-mini | DeepSeek V3.2 | 0.890 | 0.450 | 0.163 | 0.501 |
| Method | LCB | SWEB | RepliB | Avg |
|---|---|---|---|---|
| No Memory | 0.910 | 0.730 | 0.111 | 0.584 |
| LLM Reranking | 0.920 | 0.730 | 0.144 | 0.598 |
| Adaptive Rewriting | 0.920 | 0.760 | 0.144 | 0.608 |
| Embedding Similarity | 0.930 | 0.770 | 0.189 | 0.630 |
Appendix figures & tables9 assets
Supplementary material from the paper’s appendix.
Appendix
| LiveCodeBench | Aider-Polyglot | SWEBench-Verified | TerminalBench2 | ReplicationBench | MLGym-Bench | Avg. | |
| GPT-5-mini | |||||||
| ZeroShot | 0.863 | 0.343 | 0.623 | 0.206 | 0.059 | 0.583 | 0.435 |
| MTL (T) | 0.890 | 0.357 | 0.610 | 0.195 | 0.063 | 0.528 | 0.438 |
| MTL (W) | 0.877 | 0.350 | 0.620 | 0.243 | 0.081 | 0.583 | 0.449 |
| MTL (S) | 0.887 | 0.370 | 0.613 | 0.228 | 0.078 | 0.611 | 0.451 |
| MTL (I) | 0.877 | 0.347 | 0.633 | 0.213 | 0.119 | 0.639 | 0.454 |
| Model | Memory Transfer Learning with Workflow | Memory Transfer Learning with Insight |
|---|---|---|
| Task | (C++) Implement functions in space_age.cpp / space_age.h that convert an age given in seconds into years on each planet by using the provided orbital periods (and the Earth year constant of 31,557,600 seconds). | Improve agent performance on the MetaMaze navigation task (e.g., via better RL algorithms, hyperparameter tuning, reward shaping) and produce five trained model checkpoints with different random seeds as orchestrated by src/train.py. |
| Memory | Goal : Create a single final R source file containing implementations of odometry_estimation, bearing_range_estimation, warp2pi, and compute_meas_obs_jacobian … Workflow : [ " cat <<’ EOF ’ > solution . txt \ n # Write R functions implementing the required API :\ n ...", "echo ..." ] | Title : Pre-flight verification of datasets and pretrained checkpoints before running experiments Description : Before attempting training or evaluation, automatically check that required dataset files and pretrained model weights exist and return a null result if essential artifacts are missing. |
| Reasoning | I’ll implement the Space Age solution by writing / overwriting the provided header and source files with a correct class implementation … I’ll use Memory Item 2’s successful pattern of writing files with heredoc to reliably create the source files. | I will perform a quick, low-cost training run to validate the end-to-end training pipeline and produce checkpoints … I’ll use … Memory Item 2 (pre-flight verification of datasets and pretrained checkpoints) to keep this as a short smoke test rather than a full long run. |
| Result | Fail , The agent blindly applied Memory Item 2’s R-language overwriting pattern to the C++ project, replacing existing files without checking its original structure or namespaces. | Fail , Retrieved memory represents to verify required components before running expensive experiments, however, the agent distorted this into a justification for quick completion over quality. |
| 1. Iterative Workflow Discipline - Definition: Guiding the agent to follow a structured, step-by-step development process (e.g., inspect edit run verify) rather than attempting risky one-shot solutions. - Context: Used when memories reinforced the pattern of making small changes and checking them immediately (e.g., ”edit-test-repeat” loop). 2. Algorithmic Strategy Transfer - Definition: Providing specific algorithmic approaches or data structures suitable for the problem class. - Context: Used when the agent recalled mathematical formulas, dynamic programming approaches, combinatorial logic, or specific heuristics (e.g., ”O(n) single-pass,” ”backtracking with pruning”). 3. Test Driven Verification - Definition: Encouraging the creation of reproduction scripts, smoke tests, or minimal harnesses when official tests are missing or too heavy. - Context: Used when memories prompted the agent to write repro.py, use assert, or create local checks to validate logic before submission. 4. Environmental Adaptation - Definition: Helping the agent navigate specific system constraints, build tools, or OS-level idiosyncrasies. - Context: Used when dealing with missing packages, compilation flags, bash vs sh differences, or cross-compilation toolchains. 5. Anti-Pattern Avoidance - Definition: Acting as a cautionary guardrail against known failure modes or brittle approaches. - Context: Used when the agent explicitly avoided actions that caused failures in retrieved memories (e.g., ”avoid blind text patching,” ”do not guess outputs”). 6. Input Validation and Robustness - Definition: Ensuring the solution correctly handles edge cases, data normalization, and defensive parsing. - Context: Used when memories guided the agent to handle empty inputs, normalize heterogeneous data types, or enforce strict input sanitization. 7. API and Interface Compliance - Definition: Ensuring the code adheres to existing function signatures, class structures, or external library contracts. - Context: Used when the agent needed to preserve legacy behavior, match specific output schemas (JSON/YAML), or integrate correctly with a framework like Django or React. 8. Interaction Protocol Adherence - Definition: Ensuring the agent complies with the specific formatting and submission rules of the benchmark environment. - Context: Used when memories reinforced using specific completion tokens (e.g., ”COMPLETE_TASK…”), single-command constraints, or specific output formats. 9. File and Syntax Management - Definition: Providing safe techniques for file manipulation and code injection to prevent syntax errors during generation. - Context: Used when the agent utilized robust heredoc patterns, correct quoting to avoid shell interpolation, or atomic file writes. 10. Repository Exploration Tactics - Definition: Guiding the agent on how to effectively locate relevant code or resources within a large codebase. - Context: Used when memories suggested using grep, find, or inspecting specific asset files (like package.json or paper abstracts) before writing code. |
Memory-Augmented Agents
Memory-augmented agents use stored experience and knowledge to act coherently across long tasks, changing environments, and repeated interactions.
See all 347 papers