Memento-Skills: Let Agents Design Agents
Paper: arXiv:2603.18743 Code: Memento-Teams/Memento-Skills Code reference:
main@07b530ed(2026-04-24)
1. Motivation (研究动机)
这篇论文要解决的问题不是“再给 agent 加几个工具”,而是:当底座 LLM 参数 冻结、线上任务持续变化、真实失败样本又很少时,agent 如何从部署经验中持续学习,并把学到的能力变成下次可复用的执行策略。

Figure 2 解读:论文把 LLM 适应分成三类:pre-training 和 fine-tuning 都是在更新模型权重 ,前者依赖海量语料,后者依赖任务数据与梯度训练;Memento-Skills 走第三条路,即 deployment-time learning,保持 冻结,把每次真实交互的反馈写入外部 skill memory oldsymbol{M}。关键差别在于“学习发生在哪里”:不是权重、也不是一次性 prompt,而是可检索、可执行、可修改的技能库。
现有 agent 的瓶颈主要有三层。第一,冻结 LLM 在新任务上只能依赖参数内知识和上下文窗口,无法天然记住“上次这个工具/流程为什么失败”。第二,直接 fine-tuning 对线上 agent 并不现实:论文开场用约 200 个失败 tickets 的例子说明,样本太少时很容易过拟合,且每次更新都要成本、评估和部署。第三,传统工具库或 prompt 库通常是静态的:它能被检索,但不会因为执行失败而自动重写自己的 prompts、helper scripts 或使用边界。
论文的具体目标是把 Memento 2 中的 Stateful Reflective Decision Process (SRDP) 落到可运行系统里:把“memory”从被动的历史轨迹升级成 skill folders。每个 skill 不是一句经验,而是一组结构化 artefacts,包括 SKILL.md、prompts、helper scripts、依赖与允许工具;因此 Write 操作不只是追加日志,而是会修改未来要执行的策略载体。
这个问题值得研究,是因为它把 agent 学习从“昂贵参数更新”迁移到“廉价外部记忆演化”。一旦成立,系统就能在真实任务流中逐步扩展能力:失败可被归因到具体 skill;低效 skill 可被优化;缺失能力可触发 skill discovery;同一领域的新任务可以复用已有 skill,而不需要重新训练底座模型。
2. Idea (核心思想)
核心洞察:把可执行 skill 当成外部记忆的基本单位。传统 episodic memory 记的是过去状态、动作、奖励;Memento-Skills 记的是未来可直接调用和可修改的程序化能力。这样 Read 操作相当于选择当前要执行的策略片段,Write 操作相当于根据反馈更新该策略片段。

Figure 3 解读:给定状态 ,系统先从 skill memory oldsymbol{M}_t 中读出 skill ;冻结 LLM 根据 和 产生动作 ;环境返回反馈 后,Write 操作把执行结果反映到下一轮 memory oldsymbol{M}_{t+1} \\leftarrow \\mathrm{Write}(\\boldsymbol{M}_t,s_t,a_t,r_t)。图里的重点是策略会变,但变化来自 memory,而不是 LLM 参数。
相对 GEPA、prompt evolution 或一般 skill-learning 方案,这篇论文的根本差异有两点。第一,它不是只优化文本提示,而是把 code、prompt、declarative spec 一起作为 skill artefact 更新。第二,它不是只靠语义相似度召回 skill,而是提出 behaviour-aligned routing:检索目标不是“文本像不像”,而是“执行这个 skill 后成功概率高不高”。
论文最终把系统拆成两个互相咬合的创新:一条 Read–Execute–Reflect–Write 的 self-evolving loop,负责把失败转成 skill 更新;一个经过 multi-positive InfoNCE 训练的 router,负责在大规模 skill library 中选择行为上最合适的 skill。
3. Method (方法)
3.1 从 SRDP 到 skill memory
论文从 SRDP 形式化开始。给定记忆 oldsymbol{M}_t,冻结 LLM 的诱导策略写成: 这里 是底座 LLM 的决策核, 是从 memory 里取出的 case/skill, 是 retrieval policy。Memento-Skills 的变化在于: 不是原始 episode,而是一个 reusable skill artefact,包含 specification、prompts 和 executable code。于是系统可以把状态扩展为 ,把“会随时间变的 skill library”纳入 Markov state。
Reflected MDP 的转移核为: 直觉上,Read 选择“下次用哪个能力”,Act 让冻结 LLM 执行,Write 把结果写回能力本身。若失败来自 skill 的边界条件不完整,Write 就补 guardrails;若失败来自策略方向完全错误,Write 可能创建新 skill。论文引用 Memento 2 的结论:在 bounded rewards 和 下,KL-regularised soft policy iteration over Reflected MDP 收敛到最优 retrieval policy 。
3.2 整体框架:Self-Evolving Agent
Figure 5 解读:这是论文的核心架构图。用户任务进入 Memento Agent 后,Skill Router 从 Skill Library 读出已有 skill;如果没有命中且允许 create-on-miss,就生成新 skill。LLM 执行后,系统进入 Reflection:成功时更新 skill utility,失败时触发 skill optimisation 或 skill discovery。图中最重要的闭环是 Read Execution Reflection Write,所有能力增长都发生在 skill library 中。
Figure 6 解读:这张图把 Figure 5 的概念环落到工程模块:MementoSAgent 协调 LLM client、context manager、built-in tools 与 skills system;skills system 管理内置 skill、用户生成 skill、skill execution、retrieval 与 market;evolution engine 根据反馈改善 skill store。它说明论文不是只提出抽象算法,而是把 agent runtime、tool sandbox、GUI/CLI/API 和 skill registry 都接到同一条演化链路上。
released code 对应的主干在 core/memento_s/agent.py。MementoSAgent.reply_stream() 会初始化 SkillGateway 与 SkillDispatcher,加载会话历史,识别 intent,生成 plan,然后调用 run_plan_execution() 执行计划;计划执行过程中,LLM 可以通过 SkillDispatcher.execute() 调用 search_skill、execute_skill、download_skill、create_skill 或 recall_context。执行结束后,core/memento_s/phases/reflection.py 解析上一步结果并决定 continue / replan / ask_user / finish,最后 _trigger_evolution() 通知 profile evolver 在 session 结束后运行。
3.3 Read–Write Reflective Learning 算法
论文把每次交互分成五步:Observe、Read、Act、Feedback、Write。
def read_write_reflective_learning(task_stream, base_skills, router, llm, judge,
utility_threshold, min_samples, max_feedback_rounds):
skill_library = set(base_skills)
tip_memory = []
utility = {skill.name: 0.5 for skill in skill_library}
for task in task_stream:
x_t = {"question": task.question, "tips": tip_memory}
# Read: choose or create a skill.
skill = router.select(x_t, skill_library)
if skill is None and task.create_on_miss:
skill = create_skill(x_t)
skill_library.add(skill)
# Act: execute a multi-step workflow through the frozen LLM.
answer, trace = llm.execute_with_skill(x_t, skill)
reward, rationale = judge(task.question, answer, task.gold_answer)
# Write: update utility and repair memory artefacts.
utility[skill.name] = update_empirical_success_rate(skill, reward)
if reward == "correct":
continue
tip_memory.append(make_generic_tip(task.question, answer, rationale))
target_skill = attribute_failure(trace, rationale, skill_library)
if utility[target_skill.name] < utility_threshold and target_skill.n >= min_samples:
new_skill = discover_skill(target_skill, x_t, trace)
candidate_library = skill_library | {new_skill}
else:
patched_skill = optimise_skill(target_skill, x_t, trace)
candidate_library = replace(skill_library, target_skill, patched_skill)
if unit_test_gate(candidate_library, target_skill):
skill_library = candidate_library
for _ in range(max_feedback_rounds):
retry_answer, retry_trace = llm.execute_with_skill(x_t, target_skill)
retry_reward, retry_reason = judge(task.question, retry_answer, task.gold_answer)
if retry_reward == "correct":
break
tip_memory.append(make_generic_tip(task.question, retry_answer, retry_reason))Write 为什么不是普通日志追加
Write 有三种粒度。第一,utility update:维护每个 skill 的经验成功率 ,成功时只更新统计。第二,failure attribution:失败时根据 execution trace 与 judge rationale 识别最该负责的 skill,避免盲目改整个系统。第三,skill evolution:utility 低且样本数足够时触发 discovery,否则对现有 skill 做 in-place patch;补丁进入 skill folder 后还要过 synthetic unit-test gate,防止修复一个 case 却破坏其他 case。
这也是论文与“把失败案例塞进 RAG memory”的差别:RAG memory 只在下次 prompt 中增加证据,Memento-Skills 则把失败转化为未来会被执行的程序化约束。它的学习单元是 skill,而不是 token、embedding 或单条经验。
3.4 Self-Evolution Engine

Figure 7 解读:Self-Evolution Engine 把“任务失败”变成“系统增长”。Orchestrator 读取 execution logs,定位失败 skill,生成或优化 skill,执行验证,再把通过验证的 artefact 写入全局 skill catalog。图中闭环对应论文算法的 Write 阶段,也是 skill library 从 5 个 atomic skills 扩展到几十或几百个 learned skills 的机制来源。
released code 中,真正可见的演化逻辑分两层。在线任务执行层在 core/memento_s/phases/reflection.py 与 core/memento_s/phases/execution/runner.py 中完成 step-level reflection/replan;会话级 profile 演化在 daemon/agent_profile/orchestrator.py、daemon/agent_profile/soul_evolver.py、daemon/agent_profile/user_evolver.py 中完成,用 session signal 更新用户/agent profile。论文描述的“failure attribution + file-level skill rewriting + unit-test gate”在 repo 中有 execution hooks、policy gates、skill-creator builtin skill 与 profile evolver 的工程支撑,但没有看到与论文实验完全对应的 GAIA/HLE evolution launch script。
async def execute_plan_with_reflection(state, llm, dispatcher, tool_schemas, max_iter):
while state.has_remaining_steps() and state.iteration < max_iter:
step = state.current_step()
messages = build_step_prompt(state, step)
# ReAct-style execution: LLM may call search_skill/execute_skill/create_skill.
result = await llm.run_with_tools(messages, tool_schemas, dispatcher.execute)
state.record_step_result(step, result)
# Reflection decides whether the current step is done or needs replanning.
reflection = await reflect(state=state, step_result=result, current_step=step, llm=llm)
if reflection.decision == "CONTINUE":
state.advance_plan_step()
elif reflection.decision == "REPLAN":
state.plan = await regenerate_plan(state, failure_reason=reflection.reason)
elif reflection.decision == "ASK_USER":
return ask_user_for_missing_information(reflection.reason)
elif reflection.decision == "FINISH":
return state.final_answer()
return state.final_answer_or_error()3.5 Behaviour-aligned router:把检索看成 one-step offline RL
论文指出,BM25 或普通 embedding router 只能捕捉 lexical/semantic similarity,不能保证“执行这个 skill 会成功”。例如两个 skill 都涉及退款,但一个用于退款政策解释,另一个用于支付系统排障,语义相近但行为效用不同。为此,作者把 routing 写成 horizon-1 MDP:state 是 query ,action 是 skill document ,reward 表示该 skill 是否适合执行。
Router 先从约 8k skills 的本地数据库中采样约 3k seed skills,使用只含 skill name/description/keywords 的 prompt 生成 synthetic routing goals,再用能读取完整 skill file 的 LLM judge 过滤,形成 positives 与 hard negatives。embedding model 记作 \\mathrm{enc}_\\theta: e(d)=\\mathrm{enc}_\\theta(d),\\quad u(q)=\\mathrm{enc}_\\theta(q),\\quad s(d,q)=e(d)^\\top u(q). 对一个 minibatch 的 个 skills,每个 有 positives 与 hard negatives ,把 batch 内所有 queries 合并为 multi-positive InfoNCE loss 为: 将 score 解释为 soft Q-function Q_\\theta(q,d)\\propto s(d,q) 后,Boltzmann routing policy 为: \\pi_\\theta(d\\mid q)=\\frac{\\exp(Q_\\theta(q,d)/\\tau)}{\\sum_{d'}\\exp(Q_\\theta(q,d')/\\tau)}. 该 policy 等价于 uniform prior 下 KL-regularised objective 的最大化解: \\pi^*(\\cdot\\mid q)=\\arg\\max_\\pi\\left\{\\mathbb{E}_{d\\sim\\pi}[Q_\\theta(q,d)]-\\tau\\,\\mathrm{KL}(\\pi\\|\\pi_0)\\right\}.
def train_behaviour_aligned_router(encoder, batch_skills, positives, hard_negatives, tau=0.05):
# batch_skills: list[SkillDoc]
# positives[d]: user goals where d should be selected
# hard_negatives[d]: similar-looking goals where d should not be selected
skill_emb = encoder.encode_documents([skill.text for skill in batch_skills])
all_queries = []
owner = []
is_positive = []
for i, skill in enumerate(batch_skills):
for q in positives[skill.id]:
all_queries.append(q); owner.append(i); is_positive.append(True)
for q in hard_negatives[skill.id]:
all_queries.append(q); owner.append(i); is_positive.append(False)
query_emb = encoder.encode_queries(all_queries)
scores = skill_emb @ query_emb.T
losses = []
for i in range(len(batch_skills)):
pos_cols = [j for j, own in enumerate(owner) if own == i and is_positive[j]]
numerator = torch.exp(scores[i, pos_cols] / tau).sum()
denominator = torch.exp(scores[i, :] / tau).sum()
losses.append(-torch.log(numerator / denominator))
return torch.stack(losses).mean()**论文公式与 released code 实现差异:**论文写了 Qwen3-Embedding-0.6B + multi-positive InfoNCE + BM25/dense fusion + optional cross-encoder reranker;但 main@07b530ed 的公开 repo 中,core/skill/retrieval/local_recall.py 的 LocalRecall 明确是“无 embedding,无向量搜索”的关键词召回,按 name/keywords/description/tags 子串匹配打分;仓库 grep 未发现 InfoNCE、BM25Okapi 或 GAIA/HLE router training script。因此本笔记把 InfoNCE 部分视为论文实验/算法描述,把 released code 映射到当前开源 runtime 的 local recall/skill dispatch 实现,而不把代码强行说成已实现论文训练公式。
3.6 Retrieval pipeline 与 released code 映射

Figure 8 解读:论文中的 retrieval pipeline 先收集 sparse BM25 和 dense embedding 候选,再用 score-aware reciprocal rank fusion 合并,最后可选 cross-encoder reranker 得到 top-k skills。这个图强调“router 是行为策略”,不是普通文档搜索;但如上所述,当前 released code 的 local path 主要还是 keyword recall。
released code 的实际 search/execute 路径更接近下面的伪代码:
async def released_skill_dispatch(tool_name, args, gateway):
if tool_name == "search_skill":
return await gateway.search(args["query"], limit=args.get("limit", 5))
if tool_name == "execute_skill":
skill_name = normalize_skill_request(args.get("request", ""))
return await gateway.execute(skill_name=skill_name, params=args)
if tool_name == "download_skill":
return await download_skill(args)
if tool_name == "create_skill":
return await create_skill(args)
if tool_name == "recall_context":
return await recall_context(args)
return await hallucination_guard_convert_to_execute_skill(tool_name, args)
def released_local_recall(query, registry_entries):
candidates = []
for skill in registry_entries:
score = 0.0
for token in tokenize(query):
if token == skill.name:
score += 1.0
if token in skill.keywords:
score += 0.9
if token in skill.name:
score += 0.7
if token in skill.tags:
score += 0.6
if token in skill.description:
score += 0.5
if query.lower() in (skill.name + " " + skill.description).lower():
score += 0.3
if score > 0:
candidates.append((score, skill))
return sorted(candidates, reverse=True)[:5]Code reference:
main@07b530ed(2026-04-24) — pseudocode and mapping based on this commit
| Paper Concept | Source File | Key Class/Function |
|---|---|---|
| Self-evolving agent orchestrator | core/memento_s/agent.py | MementoSAgent.reply_stream, _trigger_evolution |
| Plan-generation before execution | core/memento_s/phases/planning.py | generate_plan, TaskPlan, PlanStep |
| ReAct-style step execution | core/memento_s/phases/execution/runner.py | run_plan_execution |
| Reflection and replan decision | core/memento_s/phases/reflection.py | reflect, ReflectionDecision, ReflectionResult |
| Skill tool dispatch | core/memento_s/skill_dispatch/dispatcher.py | SkillDispatcher.execute |
| Skill execution/create/download handling | core/memento_s/skill_dispatch/execution.py | SkillExecutionHandler |
| Skill gateway | core/skill/gateway.py | SkillGateway.search, SkillGateway.execute |
| Local keyword recall | core/skill/retrieval/local_recall.py | LocalRecall._match_score, LocalRecall.search |
| Multi-source recall wrapper | core/skill/retrieval/multi_recall.py | MultiRecall |
| Skill runtime | core/skill/execution/agent.py | SkillAgent.run |
| Session/profile evolution | daemon/agent_profile/orchestrator.py | AgentProfileEvolver |
| Long-term memory/consolidation | infra/memory/consolidation/engine.py | ConsolidationEngine |
3.7 GUI 与部署面

Figure 4 解读:GUI 不是方法核心,但说明 Memento-Skills 不是离线 benchmark 脚本,而是面向真实 agent runtime 的系统。released repo 也对应这一点:pyproject.toml 暴露 memento CLI 与 memento-gui,README 给出 memento doctor、memento agent、memento-gui 三个入口;GUI、CLI、server、IM bridge 都共享后端的 MementoSAgent 与 SkillGateway。
4. Experimental Setup (实验设置)
4.1 Benchmarks 与数据规模
- GAIA (General AI Assistants):论文使用 GAIA validation set 中 165 个问题,切分为 100 个 training examples 和 65 个 test examples。GAIA 问题需要多步推理、多模态处理、web browsing、文件处理和工具调用,适合检验 skill 是否能覆盖真实 assistant 任务。
- HLE (Humanity’s Last Exam):原 benchmark 有 2,500 个跨 8 个学科的 expert-level questions。论文采样得到 788 个 training examples 和 342 个 test examples,按学科均衡分布,用来检验 domain-aligned skill transfer。
- Router synthetic evaluation:router 用约 8k 个 public GitHub skill entries 构建 skill universe,随机采样约 3k skills 生成 synthetic routing goals;offline recall 评估使用 140 个 synthetic routing queries。
4.2 Baselines、指标与模型配置
- Baselines:主要系统 baseline 是 Read-Write ablation:保留 skill retrieval、LLM execution 和 feedback collection,但关闭 failure attribution、skill rewriting、skill discovery。Router baseline 包括 BM25 与 Qwen3-Embedding-0.6B semantic embedding router。
- Metrics:GAIA/HLE 使用 accuracy / success rate;router 使用 Recall@K、route hit rate、judge success rate;skill library growth 使用 learned skill 数量与 t-SNE embedding cluster 可视化。
- Underlying LLM:论文写明所有实验使用 Gemini-3.1-Flash 作为底座 LLM;GAIA 实验最多 3 次 reflective retries per question。
- Router model:router evaluation 使用 Qwen3-Embedding-0.6B;论文未详细说明 InfoNCE 训练的 learning rate、batch size、GPU 类型/数量或训练步数。released repo
main@07b530ed也未包含可复现实验的 GAIA/HLE launch config,因此这些训练超参数不在笔记中伪造。
4.3 主结果图
Figure 1 解读:总览图把两件事放在一起:HLE 和 GAIA 的 task performance 随 reflective learning rounds 提升;同时 skill memory 从少量 atomic skills 变成结构化 learned skills。作者想说明提升不是来自底座模型改变,而是来自外部 skill library 的 densification 与 refinement。
Figure 9 解读:左图是 140 个 synthetic routing queries 上的 Recall@K,右图是真实执行轨迹上的 route hit rate 与 judge success rate。Memento-Qwen 在 Recall@1 上从 BM25 的 0.32、Qwen3 的 0.54 提到 0.60;在真实轨迹上,route hit rate 从 0.29/0.53 提到 0.58,judge success rate 从 0.50/0.79 提到 0.80。这说明行为对齐训练主要提升“选到能执行成功的 skill”,而不仅是语义相似。
5. Experimental Results (实验结果)
5.1 GAIA:训练集持续上升,但 test transfer 受任务异质性限制
Figure 10 解读:GAIA training set accuracy 随最多 3 轮 retry 提升:总体从 First Try 的 65.1% 到 Round 1 的 84.3%、Round 2 的 89.2%、Round 3 的 91.6%。分难度看,Level 1 从 58.6% 到 96.6%,Level 2 从 74.4% 到 93.0%,Level 3 从 45.5% 到 72.7%。test set 上,Memento-Skills 总体 66.0%,Read-Write baseline 为 52.3%,提升 13.7 percentage points;Level 3 的提升最大,从 30.0% 到 71.4%。
论文对 GAIA 的解释很关键:训练集提升很大,但 test-set transfer 不如 HLE,因为 GAIA 问题高度异质,许多训练时优化出来的 skills 在测试时没有被触发。换言之,self-evolving skill library 不是万能记忆;它依赖测试任务是否落在已覆盖的 task neighbourhood 里。
5.2 HLE:domain-aligned taxonomy 带来更强迁移
Figure 11 解读:HLE training accuracy 从 R0 的 30.8% 稳定升到 R3 的 54.5%,且 8 个学科都提升。论文文本中特别指出 Humanities 到 66.7%、Biology 到 60.7%,Engineering 较早在 42.1% 附近饱和,说明某些领域仍难以用 skill-level abstraction 覆盖。test set 上 Memento-Skills 达到 38.7%,Read-Write baseline 为 17.9%,提升 20.8 percentage points,几乎超过两倍。
HLE 的结果支持论文最重要的假设:当 benchmark 自带稳定 domain structure 时,一个在 Biology training question 上修复过的 skill 更可能被 unseen Biology test question 复用。因此 self-evolving skill memory 的收益不只来自“训练题多做几遍”,而来自 learned skills 与任务分布结构对齐。
5.3 Skill library growth 与收敛解释
Figure 12 解读:两个 benchmark 都从 5 个 atomic seed skills 出发。GAIA 学习后形成 41 个 learned skills,cluster 较紧凑;HLE 学习后扩展到 235 个 learned skills,覆盖 8 个 academic domains,并在 t-SNE 空间中形成语义上连贯的簇。图中的 red stars 是 seed skills,blue dots 是 reflective self-evolution 学到的新技能。
论文用 Memento 2 的 bound 解释 diminishing returns: 随着 skill library 增长,memory coverage radius 缩小,LLM 需要泛化的邻域变小,retrieval error 也下降;早期 round 因 library 稀疏而收益大,后期因为邻域已被覆盖而收益递减。
5.4 Ablation、limitations 与结论
主要 ablation 是关闭 skill-level optimisation 的 Read-Write baseline。GAIA 上 full system 66.0% vs 52.3%,HLE 上 38.7% vs 17.9%;因此 13.7 pp 与 20.8 pp 的差距直接归因于 failure attribution、skill rewriting/discovery 与可持续写回,而不是单纯“能读 skill + 能执行 LLM”。Router ablation 显示 BM25 与未行为对齐的 Qwen3 embedding 都不足,Memento-Qwen 在 Recall@1、route hit rate、judge success rate 上都有提升。
作者明确呈现的局限有两类。第一,跨任务迁移依赖任务结构:GAIA 的高度异质性导致许多 learned skills 无法在 test set 被触发。第二,某些 domain(如 HLE Engineering)较早饱和,提示仅靠 skill-level abstraction 可能不足以覆盖需要深层知识、工具链或精确计算的任务。另一个复现层面的限制是:公开 repo 当前没有给出论文中 InfoNCE router training 与 GAIA/HLE experiment launch config,实验超参需要后续 release 才能完整复现。
总体结论:Memento-Skills 证明了 continual learning 不一定要发生在模型权重里;如果 skill 是可检索、可执行、可反思、可写回的外部记忆单元,agent 就能在冻结 LLM 之上逐步设计、修复和扩展自己的 agents。