TL;DR
Metis introduces a hierarchical dual-representation memory system that bridges the gap between text and code memory for self-evolving LLM agents. By using text memory as a flexible staging layer and selectively crystallizing recurring plans into validated code tools, Metis achieves superior task accuracy and execution efficiency while significantly lowering memory-construction costs.
What Problem Does This Paper Address?
Large Language Model (LLM) agents are inherently stateless. When deployed in open-ended environments, they accumulate valuable experience during execution, but this knowledge is lost once the finite context window shifts. As a result, agents frequently rediscover solutions or repeat past mistakes, degrading success rates and inflating computational costs.
To enable continual adaptation, "self-evolving" agents store past experiences in memory. Existing systems typically represent this memory in one of two ways: text memory (natural-language tips injected into the prompt context) or code memory (routines compiled into callable tools). However, prior architectures chose between text and code arbitrarily at design time. This paper addresses the lack of systematic understanding regarding the trade-offs between these two formats and proposes a unified framework to leverage the strengths of both.
Methods
The authors first conduct a controlled study isolating text and code memory over an identical set of experiences. Guided by the complementary trade-offs discovered, they propose Metis, a self-evolving agent system built on a hierarchical dual-representation memory framework.
Metis operates via a four-part execute-reflect-reuse loop:
- Differentiated Text Reflection: Instead of treating text memory as a flat playbook, Metis categorizes textual experience into environment facts (task-independent constraints), common pitfalls (structured failure patterns), and execution plans (reusable templates for sub-routines).
- Pattern-Aware Code Generation: Text memory serves as a low-cost staging layer. When an execution plan is repeatedly reused and passes a specific recurrence threshold, a codifier compiles the plan into a parameterized, reusable tool.
- Memory Manager: A lightweight LLM-based manager jointly retrieves and selects the most relevant text memories and tools for a given task query.
- Reflection Harness: To keep reflection efficient, the harness uses progressive disclosure to compress long execution traces. It also enforces strict validation gates (compilation and dependency checks) before admitting new tools into the library.
Datasets
The system was evaluated on AppWorld, a highly challenging benchmark for interactive coding agents. AppWorld simulates a stateful sandbox environment containing 9 applications and 457 APIs. The authors evaluated Metis using two distinct configurations:
- Official Split: Features a noticeable distribution shift between training and testing tasks to evaluate generalization across unseen task compositions.
- Resampled Split: Pools and redistributes tasks to simulate a recurring deployment workload where variants of the same scenario appear in both training and testing phases.
Key Insights and Ideas
- The Text vs. Code Trade-off: The controlled profiling study revealed that text memory is cheap to construct and generalizes robustly to unseen tasks, but forces the agent to re-reason step-by-step at runtime. Conversely, code memory drastically improves execution efficiency by collapsing multi-step reasoning into a single tool call, but it is expensive to build (requiring interactive debugging) and highly brittle under task variation.
- Selective Promotion (The Staging Strategy): The core innovation of Metis is treating text memory as an incubator. Code generation shouldn't happen indiscriminately after every task; it should only be triggered when a behavioral pattern proves stable and frequent enough to amortize its high construction cost.
- Trajectory Exclusion in Codification: When compiling a plan into code, Metis deliberately excludes raw execution trajectories. Trajectories contain incidental variables and exploratory failures; relying instead on abstract execution plans and varied historical queries yields far more robust, generalized tools.
Key Results
- Higher Accuracy: On the AppWorld benchmark, Metis improved Task Goal Completion (TGC) over the baseline ReAct agent by 8.3 percentage points on the Official split and 11.3 percentage points on the Resampled split.
- Greater Efficiency: Metis achieved these accuracy gains while reducing execution token costs by up to 22.8% relative to the baseline.
- Lower Overhead: Compared to SkillX (a state-of-the-art skill-based baseline), Metis achieved superior accuracy and runtime efficiency while reducing total offline memory-construction costs by up to 33.7% (11.8M vs 17.8M tokens on the Resampled split).
Limitations and Future Work
The authors note that out-of-domain generalization remains a fundamental hurdle for experience-based agents. For instance, on tasks introducing entirely new applications absent from the training data, self-evolving mechanisms cannot accumulate relevant memory beforehand.
Future work includes exploring dynamic, complexity-based thresholds for code promotion rather than a fixed reuse count, as well as extending the dual-memory paradigm to multi-agent collaborative environments.
Summary updated