Source-linked AI summary
Metis: Bridging Text and Code Memory for Self-Evolving Agents
Zijie Dai, Siuhin He, Hui Li, Qihui Zhou, Jiajun Li, Mingcong Song, Guoping Long, Hongjie Si, Xin Yao, Lin Zhang, James Cheng, Xiao Yan
TL;DR
Self-evolving agents typically fix how accumulated experience is represented, despite limited evidence about the trade-offs between text and code memory. Metis studies these representations and builds a hierarchical system that selectively promotes recurring textual plans into validated tools, achieving the highest task accuracy at the lowest execution cost, including a 22.8% reduction in executor tokens.
Problem
Existing self-evolving agents fix the representation of accumulated experience a priori, leaving text–code trade-offs insufficiently characterized.
Source: §5 · p. 13Method
Metis uses hierarchical dual-representation memory, retaining textual guidance while promoting recurring plans into validated callable tools after a reuse threshold.
Source: §1 · p. 3, §3.3 · p. 7Results
Metis achieves the highest task accuracy at the lowest execution cost across evaluated splits, reducing executor tokens by up to 22.8% versus the baseline.
Source: §4.2 · p. 10, §5 · p. 13Takeaways & Limitations
Text and code memory are complementary, supporting selective codification rather than exclusive reliance on either representation.
Source: §1 · p. 2, §5 · p. 13Comparisons adapt baselines to the same executor, task order, and sandbox interface while preserving their original memory forms and update logic.
Source: §4.1 · p. 9
Abstract
from arXiv · showhide
Self-evolving agents improve over time by distilling experience from past executions and reusing it in future tasks. Existing systems represent such experience either as natural-language text injected into the agent context or as code exposed as callable tools. However, the choice between these representations is typically made at design time rather than derived from the characteristics of the experience itself, leaving the trade-offs between them poorly understood. We present the first controlled study that isolates text memory and code memory over an identical set of experiences. Our results show that the two forms exhibit complementary trade-offs in construction cost, execution efficiency, and transferability, such that neither representation alone is sufficient. Guided by these findings, we propose Metis, a self-evolving agent system built on a hierarchical dual-representation memory. Metis organizes textual experience into execution plans, environment facts, and common pitfalls, and selectively crystallizes recurring plans into validated callable tools. This design combines the broad applicability of text memory with the execution efficiency of code memory while incurring tool-generation cost only when justified by repeated reuse. We evaluate Metis on AppWorld, a challenging benchmark for interactive agents. The results show that Metis improves task accuracy by up to 20.6% over ReAct while reducing execution cost by up to 22.8%. Compared with representative self-evolving agent systems, Metis consistently achieves a better balance between accuracy, execution efficiency, and memory-construction cost.
1 INTRODUCTION
The introduction identifies complementary trade-offs between text and code memory and motivates Metis, which uses structured text memory with selective promotion of recurring plans into callable tools.
Motivation
- Because current agents lose experience outside the finite context window, they repeat prior discoveries and mistakes, increasing computation and reducing task success.Self-evolving agents address this limitation by distilling experience from past executions for reuse in future tasks.Source: §1 · p. 1
Representation study
- Text memory is cheaper to construct and transfers more reliably, whereas code memory executes more efficiently but costs more to build and is brittle under task variation.Code construction requires roughly 2.5× more ReAct turns and about one million additional tokens; streaming degradation is 22.3 points for code versus 5.6 points for text.Source: §1 · p. 2
Metis
- Metis organizes text memory into plans, environment facts, and pitfalls, each retrieved according to its distinct scope and usage pattern.This structure avoids treating coarse routines, environment constraints, and localized warnings as a single flat text tip.Source: §1 · p. 3
- Metis promotes only recurring plans into callable tools while retaining facts and pitfalls as text, amortizing construction cost across repeated use.Reflection operates asynchronously on completed trajectories, so memory construction does not inflate task-serving latency.Source: §1 · p. 3
Contributions
- On the AppWorld benchmark, Metis substantially improves execution efficiency and task success rate over existing memory-based agents while keeping memory-construction cost comparable to or lower than prior self-evolving approaches.Source: §1 · p. 3
2 PRELIMINARIES
The paper models agents as LLM policies that interact with stateful environments through ReAct trajectories, and frames self-evolution as training-free execute–reflect–reuse over explicit memory artifacts. Existing systems differ primarily in whether those artifacts are natural-language text or executable code, with the representation usually fixed at the system level.
2.1 AGENTIC WORKFLOW
- Agents iteratively produce code blocks or tool calls from interaction context, receive environment observations, and terminate with a trajectory after a terminal action or step budget.The context updates as c_t+1 = c_t ⊕ (a_t, o_t), yielding τ = q, (a_1, o_1), …, (a_T, o_T).Source: §2.1 · p. 3
2.2 SELF-EVOLVING AGENT SYSTEMS
- Training-free self-evolving systems retrieve relevant memory to condition a frozen policy, reflect on each rollout, and write distilled experience back for reuse across tasks.These systems maintain memory M, forming an execute–reflect–reuse loop, while representing experience primarily as text or executable code; the representation is generally fixed a priori rather than selected per experience.Source: §2.2 · p. 4
3 THE METIS SYSTEM
Metis uses a hierarchical dual memory that combines structured text experience with selectively generated callable tools in a self-evolving execution and reflection loop. Its components jointly support reusable guidance, recurrence-based code promotion, memory selection, dependency-safe tool execution, and efficient trajectory inspection.
3.1 SYSTEM OVERVIEW
- Metis maintains hierarchical text and code memories, then updates them through task execution, recurrence-aware codification, differentiated reflection, and controlled evidence access.The workflow selects memories, executes the task, promotes sufficiently reused plans, reflects on the trajectory, and writes updated memories and tools back for future tasks.Source: §3.1 · pp. 4–5
3.2 DIFFERENTIATED TEXT REFLECTION
- Text memory separates environment facts, common pitfalls, and execution plans, with agentic reflection generalizing, validating, merging, and invalidating entries before reuse as optional natural-language guidance.Plans are conditioned on recent task queries to reduce overfitting, while failed and inefficient executions produce corrective or efficiency-oriented entries; invalidate-and-replace preserves consistency and excludes obsolete memories.Source: §3.2 · pp. 5–6
3.3 PATTERN-AWARE CODE GENERATION
- Recurrence evidence promotes only sufficiently reused execution plans into validated tools, using task queries rather than raw trajectories and linking admitted tools back to their plans.The reuse threshold amortizes construction and verification cost, while plan fields buffer recurrence evidence, retain related-task history, and register implementations; tools then influence subsequent plans.Source: §3.3 · pp. 7–8
3.4 MEMORY MANAGER
- Metis jointly retrieves and selects text entries and tool descriptions, allowing selected plans to bring in their registered implementations and selected tools to be paired with usage guidance.The Memory Manager reasons over both representations without receiving full tool implementations, and selected plans make associated tools eligible for execution.Source: §3.4 · p. 8
3.5 REFLECTION HARNESS
- The reflection harness ensures dependency-complete execution and tool admission through static closure, sandbox validation, compilation checks, and rejection after a second compilation failure.It also uses progressive disclosure: reflectors receive a compact trajectory sketch and expand selected steps, ranges, or tool implementations only when needed.Source: §3.5 · pp. 8–9
4 EXPERIMENTS
On AppWorld, Metis is evaluated against memory-based baselines under distribution-shifted and recurring-workload settings, using accuracy, execution cost, and construction cost. It achieves the strongest overall balance, while ablations show that hybrid memory and recurrence-gated promotion are both essential.
4.1 EXPERIMENTAL SETUP
- On AppWorld, Metis is tested with a fixed train-then-test memory protocol across official distribution-shifted and resampled recurring-workload splits.The benchmark contains 9 applications and 457 APIs; TGC measures state-test completion, while execution and reflection costs are reported separately.Source: §4.1 · pp. 9–10
4.2 MAIN RESULTS
- Metis leads both AppWorld splits, improving TGC over No Memory by 8.3 and 11.3 points while reducing executor tokens by 13.5% and 22.8%.It is the only method that simultaneously improves accuracy and execution efficiency while using less reflection budget than SkillX.Source: Table 1 · p. 10, §4.2 · p. 10
- On commonly solved tasks, Metis uses 59.6K tokens and 8.6 turns per task, versus 71.4K/9.7 for SkillX and 85.2K/12.2 for No Memory.Callable tools let Metis invoke recurring routines directly instead of requiring contextual reading, reasoning, or code generation.Source: Table 2 · p. 11, §4.2 · p. 11
- Metis achieves larger execution savings at lower construction cost than SkillX, while 94% of its admitted tools are invoked at least once, compared with 84.1% of SkillX’s code-bearing skills injected into context.Every Metis test task receives at least one relevant memory, whereas 20.8% of SkillX’s test tasks retrieve nothing.Source: §4.2 · p. 11
- Metis retains 8.3 points of accuracy gain under distribution shift, whereas SkillX’s gain falls from 10.7 to 3.0 points.Repeatedly selected plans are parameterized into tools, while non-promoted experiences remain textual and transfer more reliably across tasks.Source: §4.2 · p. 11
4.3 ABLATIONS
- The hybrid system exceeds Text-only and Code-only by 4.4 and 6.5 points, respectively, after those variants improve over No Memory by 6.2 and 4.1 points.Plans provide recurrence signals for codification, while tools sharpen subsequent plans; each ablation rebuilds memory end-to-end on the official train/dev protocol.Source: Table 4 · p. 12, §4.3 · p. 12
- Eager codification raises construction cost 47% to 11.6M tokens and lowers dev accuracy by 3.5 points, despite reducing execution to 49.9K tokens and 7.68 turns.Only 41% of Eager tools are invoked, compared with 56% for Metis on dev, showing that recurrence gating filters poorly transferable tools.Source: §4.3 · pp. 12–13
5 CONCLUSION
The conclusion finds that text and code memories are complementary, motivating Metis’s differentiated text foundation and selective promotion of recurring plans into validated tools. On AppWorld, Metis achieves the highest task accuracy at the lowest execution cost among compared methods, with gains attributed to hybrid representation and recurrence gating.
5 CONCLUSION
- Metis achieves the highest task accuracy at the lowest execution cost among compared methods on AppWorld, while using less reflection budget than its closest competitor.This occurs despite Metis additionally synthesizing and validating tools.Source: §5 · p. 13
- Text and code memories are complementary rather than interchangeable, motivating Metis’s differentiated text foundation and selective promotion of recurring plans into validated callable tools.The text memory serves as a low-commitment foundation, while recurring plans are promoted selectively.Source: §5 · p. 13
- Ablations attribute Metis’s gains to its hybrid representation and recurrence gate.The recurrence gate controls selective promotion of recurring plans into tools.Source: §5 · p. 13
A EXPERIMENTS · A.1 PROFILING EXPERIMENTS
The appendix details a profiling study that compares text and code experience forms over identical executions, analyzing construction cost, execution efficiency, and transfer reliability to inform self-evolving-agent design.
A.1 PROFILING EXPERIMENTS
- The profiling study isolates text and code experience forms using an identical stream of executions.It reports the full experimental protocol and per-axis analysis behind the study previewed in §1.Source: §A.1 · p. 15
- The analysis evaluates both experience forms along construction cost, execution efficiency, and transfer reliability.These three axes correspond to Figure 1.Source: §A.1 · p. 15
- The study aims to expose each representation’s underlying features and trade-offs for designing more effective and efficient self-evolving agents.Source: §A.1 · p. 15
A.1.1 EXPERIMENTAL SETUP
The study profiles Text and Code on 90 AppWorld train tasks using separate reflector and executor models under streaming and oracle protocols. It compares memory conditions, injection mechanisms, and accuracy, execution, and construction costs.
A.1.1 EXPERIMENTAL SETUP
- Streaming evaluation processes 90 AppWorld tasks in fixed order, allowing memory distilled from each task to affect only subsequent tasks.The executor is GPT-4o and the reflector is Claude-Sonnet-4.6, separating knowledge-construction cost from knowledge-use cost.Source: §A.1.1 · p. 15
- Code construction costs 1.3× the reflection tokens and 2.5× the LLM rounds of text construction because tools require sandbox testing and debugging.This comparison is reported over the streaming run.Source: Figure 3 · p. 16
- The oracle setting batch-reflects all 90 trajectories, assembles the full library, removes one broken tool, and re-runs the tasks in-sample.Because it uses the complete task set, manual auditing, and in-sample retesting, this setting is an upper bound rather than a generalization measure.Source: §A.1.1 · pp. 15–16
- Text, Code, and No Memory share the same protocol, differing only in whether experience is stored as natural-language memories, callable tools, or nothing.Text is read directly by the executor, whereas Code exposes only a tool’s docstring and signature and executes its body as a black box.Source: §A.1.1 · p. 16
- Accuracy is measured by task goal completion, while execution cost uses total tokens and ReAct steps and construction cost uses reflection tokens and LLM rounds.Execution efficiency is reported for All Tasks and the Commonly Solved subset, which compares conditions on identical solved tasks.Source: §A.1.1 · p. 16
A.1.2 PER-AXIS ANALYSIS
The per-axis analysis finds complementary trade-offs: code is more expensive to construct but far more efficient to execute, whereas text transfers more reliably and safely. Metis responds by using differentiated text memory by default and crystallizing recurring, validated patterns into tools.
Construction cost
- Building code consumes 4.3M tokens across 562 LLM rounds, versus text’s 3.3M tokens across 224 rounds, making code 2.5× more round-intensive.Interactive drafting, documentation inspection, sandbox execution, and debugging drive the heavier code-construction loop, whose cost is largely wasted when tools fail to transfer.Source: §A.1.2 · p. 16
Transfer reliability
- Under streaming transfer, code falls to 53.3%, 10.0 points below baseline, while text reaches 73.3%, 10.0 points above it.Code drops 22.3 points from its 75.6% Oracle result, whereas text drops only 5.6 points from 78.9%, because per-task tools overfit their source trajectories.Source: Figure 5 · p. 17, §A.1.2 · pp. 17–18
Execution efficiency
- Code reduces execution to 1.1M tokens and 204 steps versus text’s 1.5M and 272, while the no-memory baseline uses 2.4M and 375.Relative to baseline, code cuts tokens by 54% and steps by 46%, compared with text’s 38% and 27%, because one tool invocation replaces procedural reasoning.Source: §A.1.2 · p. 17, Figure 4 · p. 17
Transfer reliability
- Text is safer for freshly distilled experience because agents can adapt or ignore advice, whereas verbatim code tools can propagate faulty paths and suppress recovery.Code becomes safe once a pattern has been verified; streaming code lacks that verification privilege.Source: §A.1.2 · p. 18
From profiling to Metis
- Metis organizes text into environment facts, execution plans, and pitfalls, then gates validated tool generation on observed recurrence.This design reserves code’s construction cost for patterns that have already demonstrated reuse while retaining text’s adaptive transfer.Source: §A.1.2 · p. 18