MUSE-Autoskill 论文精读与 Hermes Agent 技能生命周期集成方案

Codex 核验(2026-10-09):保留正文 v1 实验快照;论文 v2(2026-07-03) 已改报成功覆盖子集上的自生成技能 85.24%,同一子集人工技能 81.17%,迁移 Hermes 51.90%。正文将成功筛选的 35 个任务 87.94% 与全集人工 68.40% 比较,分母不同,不能得出超过人工上限。gate 是该次测试通过,不是普适可靠性证明;subprocess 不是操作系统沙箱,隐藏文件也不会自动被 tar 排除。Hermes 的集成代码与效果仍是提案,未在当前版本重现。

论文: MUSE-Autoskill: Self-Evolving Agents via Skill Creation, Memory, Management, and Evaluation
arXiv: 2605.27366
作者: Huawei Lin, Peng Li, Jie Song, Fuxin Jiang, Tieying Zhang (ByteDance Inc. / RIT)
日期: 2026-05-26
分析日期: 2026-05-28


一、摘要原文及翻译

原文摘要

Large language model (LLM) agents rely on reusable skills to solve complex tasks. However, existing skill creation approaches treat skills as isolated and static artifacts, limiting their reusability, reliability, and long-term improvement. We propose MUSE-Autoskill Agent (Memory-Utilizing Skill Evolution), a skill-centric agent framework that lets agents continuously improve their task-solving capability by creating, reusing, and refining skills under a unified lifecycle (creation, memory, management, evaluation, and refinement). Our framework enables agents to create skills on demand, store and reuse them across tasks, organize and select them efficiently, and evaluate them through unit tests and runtime feedback for continuous refinement. We further introduce skill-level memory that accumulates experience for each skill across tasks, enabling more effective reuse and adaptation over time. Experiments on SkillsBench provide initial evidence that lifecycle-managed skills can improve task success, efficiency, reuse, and cross-agent transfer, highlighting the importance of treating skills as long-lived, experience-aware, and testable assets.

中文翻译

大型语言模型(LLM)智能体依赖可复用的技能来解决复杂任务。然而,现有的技能创建方法将技能视为孤立和静态的工件,限制了其可复用性、可靠性和长期改进能力。我们提出 MUSE-Autoskill Agent(内存利用型技能进化 —— Memory-Utilizing Skill Evolution),一个以技能为中心的智能体框架,允许智能体通过统一的技能生命周期(创建、记忆、管理、评估、精炼)持续改进其任务解决能力。我们的框架使智能体能够按需创建技能,跨任务存储和复用技能,高效组织和选择技能,并通过单元测试和运行时反馈进行评估以进行持续精炼。我们进一步引入了技能级记忆(skill-level memory),为每个技能跨任务积累经验,从而实现更有效的复用和随时间适应的能力。在 SkillsBench 上的实验提供了初步证据,表明生命周期管理的技能可以提高任务成功率、效率、复用性和跨智能体迁移能力,凸显了将技能视为长期存在、经验感知、可测试的资产的重要性。


二、论文核心贡献

  1. 技能生命周期概念:将技能从一次性生成输出重新定义为长期存在、可进化的资产,包含五个阶段:创建(Creation)、记忆(Memory)、管理(Management)、评估(Evaluation)、精炼(Refinement)。这是第一个覆盖完整生命周期的训练无关(training-free)框架。

  2. MUSE-Autoskill 框架:一个以技能为中心的智能体系统,在统一智能体循环中集成技能创建、执行、记忆、管理和评估。

  3. 三层记忆架构:短期记忆 + 长期记忆 + 技能级记忆(每个技能携带 .memory.md,跨任务积累经验)。

  4. 自适应上下文压缩:基于 DAG 的两级压缩机制(Level-1 单节点摘要 + Level-2 区间合并),支持长 horizon 任务。

  5. 跨智能体技能迁移:生成的技能可直接注入不同智能体(MUSE → Hermes)并保持高精度。


三、核心架构图 (ASCII)

┌─────────────────────────────────────────────────────────────────────────────┐
│                        MUSE-Autoskill Agent Architecture                    │
│                     (Memory-Utilizing Skill Evolution)                      │
└─────────────────────────────────────────────────────────────────────────────┘

                                  ┌─────────────┐
                                  │    User      │
                                  │  issues task │
                                  └──────┬──────┘
                                         │
                                  ┌──────▼──────────────────────────────────┐
                                  │         ORCHESTRATOR                     │
                                  │    Master Agent (ReAct Loop)             │
                                  │    ┌──────────┬──────────┬──────────┐   │
                                  │    │ Planning │  Action  │Observat'n│   │
                                  │    │ decompos │ inv skill│  read    │   │
                                  │    │ & choose │ or tool  │  result  │   │
                                  │    └──────────┴──────────┴──────────┘   │
                                  └──────┬───────────────────────┬──────────┘
                                         │                       │
              ┌──────────────────────────┼───────────────────────┼──────────┐
              │         SKILL SUBSYSTEM  │                       │          │
              │                          │                       │          │
              │   ┌──────────────────────▼──────────────┐        │          │
              │   │    Need a new skill?                │        │          │
              │   │    ┌─── Yes ───┐    ┌─── No ───┐   │        │          │
              │   │    ▼           │    ▼          │   │        │          │
              │   │  ┌────────┐   │  ┌────────┐   │   │        │          │
              │   │  │ Skill  │   │  │  Skill │   │   │        │          │
              │   │  │Creator │   │  │  Bank  │   │   │        │          │
              │   │  └───┬────┘   │  └───┬────┘   │   │        │          │
              │   │      │        │      │        │   │        │          │
              │   │      ▼        │      ▼        │   │        │          │
              │   │  ┌──────────────────────┐     │   │        │          │
              │   │  │   Skill Package      │◄────┘   │        │          │
              │   │  │  SKILL.md            │         │        │          │
              │   │  │  scripts/            │         │        │          │
              │   │  │  tests/              │         │        │          │
              │   │  │  resources/          │         │        │          │
              │   │  │  .memory.md          │         │        │          │
              │   │  └───────┬──────────────┘         │        │          │
              │   └──────────┼────────────────────────┘        │          │
              │              │                                 │          │
              │   ┌──────────▼──────────────────────────────┐ │          │
              │   │         EVALUATION                       │ │          │
              │   │    Run tests/ in sandbox                │ │          │
              │   │    ┌───── PASS ──────┐  ┌── FAIL ──┐  │ │          │
              │   │    ▼                 │  ▼          │  │ │          │
              │   │  Register skill      │  ┌────────┐ │  │ │          │
              │   │  into Skill Bank     │  │Refiner │ │  │ │          │
              │   │                      │  │ update │◄┘  │ │          │
              │   │                      │  │ skill  │    │ │          │
              │   │                      │  └────────┘    │ │          │
              │   └───────────────────────────────────────┘ │          │
              │                                             │          │
              │   ┌──────────────────────────────────────┐  │          │
              │   │        MEMORY HIERARCHY               │  │          │
              │   │  ┌─────────────┐  ┌────────────────┐ │  │          │
              │   │  │ Short-term  │  │  Long-term     │ │  │          │
              │   │  │ (session    │  │  (cross-session│ │  │          │
              │   │  │  context)   │  │  notes/lessons)│ │  │          │
              │   │  └─────────────┘  └────────────────┘ │  │          │
              │   │  ┌─────────────────────────────────┐  │  │          │
              │   │  │  Skill-level Memory (.memory.md) │  │  │          │
              │   │  │  per-skill experience across     │  │  │          │
              │   │  │  tasks: usage notes, failure     │  │  │          │
              │   │  │  modes, input quirks, tips       │  │  │          │
              │   │  └─────────────────────────────────┘  │  │          │
              │   └──────────────────────────────────────┘  │          │
              └─────────────────────────────────────────────┼──────────┘
                                                            │
                                                    ┌───────▼───────┐
                                                    │   FINAL       │
                                                    │   OUTPUT      │
                                                    └───────────────┘

         SKILL LIFECYCLE FLOW:
         ┌─────────┐    ┌────────┐    ┌──────────┐    ┌────────┐    ┌───────────┐
         │Creation │───►│Memory  │───►│Management│───►│Evalua- │───►│Refinement │
         │on-demand│    │store + │    │retrieve  │    │tion    │    │auto-fix on│
         │via      │    │experience│ │organize  │    │unit    │    │test fail  │
         │skill_   │    │.memory │    │merge/    │    │tests + │    │via update │
         │create   │    │.md     │    │prune     │    │runtime │    │_skill     │
         └─────────┘    └────────┘    └──────────┘    └────────┘    └───────────┘

四、核心算法提取

4.1 技能创建算法 (Skill Creation)

MUSE 通过内置的 skill_create 工具在运行时循环中动态创建技能,消除”创建-使用脱节”(creation–usage mismatch)。

Algorithm: Skill Creation Pipeline
─────────────────────────────────────────────────────────────────────────────
Input:  task specification, LLM backbone, built-in tools (skill_create, sandbox)
Output: registered skill package or updated skill

1. Agent detects existing skills insufficient for current task
2. Agent invokes skill_create with:
   - high-level purpose specification
   - expected inputs/outputs
   - optionally: successful trajectory (Phase 1 → Phase 2 distillation)
3. System generates skill package:
   a. SKILL.md: YAML frontmatter (name, description) + body (when-to-use,
      core principles, recommended tools, step-by-step workflow)
   b. scripts/: executable code (Python, shell, Node) [optional]
   c. tests/: pytest-compatible unit tests [optional but enforced]
   d. resources/: auxiliary data [optional]
4. Gate: Run unit tests in sandbox
   ┌── All tests PASS → Register skill into Skill Bank
   └── Any test FAIL  → Inspect error trace
                       → Invoke update_skill to patch package
                       → Re-run tests (loop until pass or max retries)
5. Skill-level memory (.memory.md) lazily created on first write
6. Catalog entry (name + description) injected into agent's system prompt
─────────────────────────────────────────────────────────────────────────────

关键创新点:

  • 创建发生在运行时循环内(非独立阶段)
  • 创建后立即评估(unit test gating)
  • “创建→评估→注册”循环确保只有可靠技能进入技能库
  • 技能可作为独立目录冷传递到其他智能体

4.2 技能记忆管理 (Skill Memory)

MUSE 提出三层记忆架构,核心创新是 技能级记忆 (skill-level memory)。

Memory Architecture
─────────────────────────────────────────────────────────────────────────────
Level 1: Short-term Memory (session-scoped)
  - Current task context: intermediate reasoning, observations, execution results
  - Adaptive compression when exceeding token budget
  - File: sessions/<session_id>/memory.md
  - Cleared between sessions

Level 2: Long-term Memory (cross-session)
  - Persistent notes, reusable conclusions, environment quirks
  - General lessons outside any single skill
  - File: ~/.autoskill/memory/long_term_memory/memory.md
  - Append-only, no compression
  - Not subject to context compression

Level 3: Skill-level Memory ✦ NOVEL ✦
  - Per-skill experience accumulated across tasks
  - Each skill has sibling .memory.md (lazy-created on first write)
  - Content: known failure modes, input format quirks, performance caveats,
    usage patterns, observed pitfalls
  - Surfaced alongside SKILL.md when skill is loaded
  - NOT transferred when skill is exported (leading dot, excluded from .tar)
  - Format: append-only Markdown, timestamped entries

      .memory.md example:
      ## 2026-05-07 10:34:33 UTC
      - Timeout on PDFs > 100MB; should use _retry(parse, timeout=30)
      - Users prefer markdown output over plain text
      - This task requires batched I/O rather than per-row processing

Memory File Format (uniform across all three levels):
  ## 2026-05-07 10:34:33 UTC
  <agent-written content, one short paragraph or list>
─────────────────────────────────────────────────────────────────────────────

4.3 技能管理算法 (Skill Management)

Algorithm: Skill Bank Management
─────────────────────────────────────────────────────────────────────────────
Data Structure: Skill Bank = {skill_id → Skill Package}
  Each package: SKILL.md + optional scripts/ + tests/ + resources/ + .memory.md
  Indexed by: name, description (from YAML frontmatter)

Management Operations:
1. RETRIEVAL (progressive disclosure):
   a. At task start → inject catalog into system prompt
      Catalog = [{name, description} for each skill in bank]
      (~5-10K tokens for 100 skills)
   b. Agent reads catalog, selects relevant skill
   c. Agent optionally loads full SKILL.md via read_skill tool
   d. Full body loaded only after agent decides skill is worth pulling in

2. REFINEMENT (update_skill):
   a. Trigger on: failed unit tests OR incorrect runtime outputs
   b. Agent inspects error trace, patches package files
   c. Re-runs tests; loop until pass

3. MERGING (redundancy elimination):
   a. Trigger on: newly created skill overlaps with existing ones
   b. Merge into single, more general skill
   c. Remove redundant skills

4. PRUNING (cleanup):
   a. Trigger: skills that consistently fail OR remain unused over time
   b. Remove from skill bank
   c. Keeps bank compact, reliable, scalable

5. CATALOG UPDATE:
   Every skill creation/merge/prune → regenerate catalog
   Catalog injected into system prompt at task start
─────────────────────────────────────────────────────────────────────────────

4.4 技能评估与精炼闭环 (Evaluation & Refinement)

Algorithm: Self-Evolution Loop (Evaluation → Refinement)
─────────────────────────────────────────────────────────────────────────────

CREATE PHASE (第一次创建时):
  1. Skill Creator 生成 skill package(含 tests/)
  2. Evaluator 在 sandbox 中运行 tests/
  3. ┌── all pass → 注册到 Skill Bank
  4. └── any fail → Refiner 读取 error trace
       → update_skill 修改 scripts/ 或 SKILL.md
       → 重新运行 tests/(循环直到 pass)
  5. 注册成功后,技能进入 Skill Bank

EXECUTION PHASE (运行时):
  1. Agent 从 Skill Bank 检索并调用 skill
  2. Skill 在 sandbox 中执行(隔离的 filesystem)
  3. 执行结果返回给 Agent 的 ReAct 循环
  4. Agent 根据 observation 判断:
     ┌── 成功 → 继续执行或输出最终结果
     │          → 可选地追加 notes 到 .memory.md
     └── 失败 → 检查错误原因
                → 如果是 skill 问题 → invoke update_skill
                → 重新评估 skill
                → 更新 .memory.md 记录失败模式

REFINEMENT TRIGGER MATRIX:
  ┌──────────────────────┬────────────────────────────────────────────────┐
  │ 触发条件              │  动作                                           │
  ├──────────────────────┼────────────────────────────────────────────────┤
  │ Unit test fail       │  Inspect trace → patch code → re-run tests     │
  │ Runtime error        │  Update .memory.md with error pattern          │
  │ Overlap new/existing │  Merge into general skill, prune duplicate     │
  │ Consistently fails   │  Remove from bank (or mark deprecated)         │
  │ Unused for period    │  Prune from bank                               │
  │ Phase 1 success      │  Distill trajectory → generate skill package   │
  └──────────────────────┴────────────────────────────────────────────────┘
─────────────────────────────────────────────────────────────────────────────

4.5 自适应上下文压缩算法

Algorithm: Adaptive Context Compression
─────────────────────────────────────────────────────────────────────────────
Input:  ctx (conversation DAG), model (LLM), budget (COMPRESS_TOKEN_THRESHOLD=180K)
Output: compressed active chain (within budget)

def maybe_compress_history(ctx, model):
    chain = walk(parent_id from tip to root)
    total_tokens = sum(estimate_tokens(node) for node in chain)

    if total_tokens <= COMPRESS_TOKEN_THRESHOLD:
        return                                    # under budget

    # ---- Level 1: per-node in-place summary ----
    # Never touch first K=5 or last K=5 turns
    middle = chain[KEEP_FIRST : -KEEP_LAST]
    for node in middle:
        if estimate_tokens(node) > NODE_COMPRESS_TOKEN_THRESHOLD (15K):
            summary = model.summarize(node.input + node.model_output)
            node.compressed_input = summary
            node.is_node_compressed = True

    if recompute_total(chain) <= COMPRESS_TOKEN_THRESHOLD:
        return                                    # Level 1 was enough

    # ---- Level 2: collapse middle span into one summary node ----
    span = chain[KEEP_FIRST : -KEEP_LAST]
    summary = model.summarize(concat(span))
    sNode = new ConversationNode(
        is_summary = True,
        parent_id = chain[KEEP_FIRST - 1].node_id,
        compressed_input = summary,
    )
    chain[-KEEP_LAST].parent_id = sNode.node_id   # rewire chain

  # ---- Audit trail preserved ----
  # Original node.input never mutated
  # Full history accessible via immutable history_prev/history_next pointers
─────────────────────────────────────────────────────────────────────────────

4.6 技能格式规范 (Package Schema)

MUSE 采用 Anthropic Agent Skills 格式,Hermes Agent 已原生支持此格式。

Skill Package Directory Layout:
  <kebab-case-skill-name>/
  ├── SKILL.md                    # REQUIRED: YAML frontmatter + markdown body
  │   ┌──────────────────────────────────────┐
  │   │ ---                                 │
  │   │ name: <kebab-case-identifier>       │
  │   │ description: <one-paragraph>        │
  │   │ ---                                 │
  │   │ # Title                             │
  │   │ ## When to use                      │
  │   │ ## Core principles                  │
  │   │ ## Recommended tools and libraries  │
  │   │ ## Workflow                         │
  │   └──────────────────────────────────────┘
  ├── .memory.md                   # OPTIONAL: per-skill experience (lazy)
  ├── scripts/                     # OPTIONAL: executable code
  │   ├── main.py
  │   └── utils.py
  ├── tests/                       # OPTIONAL: pytest unit tests
  │   └── test_skill.py
  ├── resources/                   # OPTIONAL: data/docs/prompts
  └── references/                  # OPTIONAL: reference docs

Catalog Routing(渐近式披露):

  • 任务开始时,仅注入 catalog(每个技能 name + description)到 system prompt
  • Agent 通过 read_skill 工具按需加载完整 SKILL.md
  • 100 skills 仅增加 ~5-10K tokens 的 catalog 开销

五、实验关键数据

配置准确率 (51 tasks)
MUSE-Autoskill 无技能 (baseline)53.19%
MUSE-Autoskill 人工技能68.40%
MUSE-Autoskill 自生成技能60.35%
自生成技能成功的35个任务上87.94%
Hermes + MUSE 生成技能(迁移)58.40%
Hermes 人工技能 (reference)61.21%

关键发现:

  • v1 自生成技能在35个成功任务子集上为 87.94%;人工 68.40% 为全集结果,不能直接比较或称为超过人工天花板
  • 生成的技能从 MUSE 转移到 Hermes 后,仅损失 ~2 pp 精度(60.35%→58.40%),关闭了 79% 的技能差距
  • 使用生成技能后 token 减少 20-48%,延迟减少 30-37%
  • 技能生成的一次性成本 (383K tokens, 164s) 约在 3 次复用后回本

六、与现有工作的对比

方法创建记忆管理评估精炼跨智能体训练无关
Voyager✓✗✓△✓△✓
AutoSkill✓△△✗✓✗✓
EvoSkill✓✗△✓✓✗✓
SkillGen✓✗✗✓✓△✓
Anthropic Skills✓✗✓✗✗△✓
SkillMaster✓✗△△✓✗✗
SkillOS✓✓✓△✓✗✗
MUSE-Autoskill✓✓✓✓✓✓✓

七、Hermes Agent 技能系统现状分析

7.1 当前 Hermes 技能系统

位置: ~/.hermes/skills/
规模: ~78 个技能
格式: 每个目录包含 SKILL.md(YAML frontmatter + Markdown body)
路由: 通过 triggers: 字段匹配用户输入
工具: 通过 tools: 字段声明所需工具
示例 skill 结构:

---
name: brain-ops
version: 1.0.0
description: Brain knowledge base operations...
triggers:
  - any brain read/write/lookup/citation
tools:
  - search
  - query
  - get_page
  - put_page
mutating: true
---

已支持的 Anthropic Skills 格式: ~/.hermes/anthropic-skills/skills/ 包含 17 个标准技能

7.2 差距分析

MUSE 能力Hermes 当前状态差距
技能级记忆 (.memory.md)❌ 无核心缺失
单元测试评估 (tests/)❌ 无核心缺失
自动精炼循环 (update_skill)❌ 无核心缺失
运行时技能创建 (skill_create)❌ 无核心缺失
技能合并/裁剪❌ 无需要实现
自适应上下文压缩❌ 无需要实现
渐近式 catalyst 注入△ 所有技能 SKILL.md 已索引需要 catalog 机制
Anthropic Skills 格式✓ 已支持无差距
技能目录结构△ 类似但无 tests/ 和 .memory.md小差距

八、可执行的 Hermes Skill 集成方案

8.1 集成策略概览

将 MUSE-Autoskill 的五阶段生命周期迁移到 Hermes Agent 的 skill 系统,分三个里程碑实现:

里程碑 1 (Quick Wins)    →  里程碑 2 (核心循环)    →  里程碑 3 (完整闭环)
────────────────────     ────────────────────     ────────────────────
.skill_memory.md        skill_create tool        skill_merge
skill catalog           unit test gating         auto-prune
update_skill tool       evaluator sandbox        自适应上下文压缩
read_skill tool         self-evolution loop      跨 session resume

8.2 里程碑 1 — Quick Wins(立即执行)

8.2.1 引入技能级记忆 (.skill_memory.md)

在 Hermes 的 skill 目录结构中添加 .skill_memory.md 文件,作为技能的跨任务经验仓库。

文件位置: ~/.hermes/skills/<slug>/.skill_memory.md

格式(append-only markdown):

## 2026-05-28 10:34:33 UTC
- 这个技能的常见失败模式: ...
- 用户偏好: ...
- 性能建议: ...

agent 行为变化:

  • 每次调用 skill 后,可追加经验笔记
  • 下次加载 skill 时,自动读取 .skill_memory.md 内容附加到上下文
  • 经验不随 skill 导出(leading dot,保持隐私)

实施要点:

# 在 skill_loader 中添加 .skill_memory.md 读取
def load_skill_memory(skill_path: str) -> str:
    memory_path = os.path.join(skill_path, ".skill_memory.md")
    if os.path.exists(memory_path):
        with open(memory_path) as f:
            return f.read()
    return ""
 
# 在 skill 调用后追加笔记
def append_skill_memory(skill_path: str, note: str):
    memory_path = os.path.join(skill_path, ".skill_memory.md")
    with open(memory_path, "a") as f:
        f.write(f"## {datetime.utcnow()}\n{note}\n\n")

8.2.2 技能 Catalog 渐近式披露

将 Hermes 当前的所有 SKILL.md 全量加载改为仅注入 catalog 到 system prompt。

Catalog 格式:

available_skills:
  - name: brain-ops
    description: Brain knowledge base operations...
  - name: data-science
    description: Data analysis and machine learning workflows...

Agent 新增工具:

  • read_skill(name: str) — 加载完整 SKILL.md 到上下文
  • search_skills(query: str) — 语义搜索技能库

好处: 当技能库扩展到 100+ 时,catalog 仅 ~5-10K tokens,而非全量 ~500K tokens。

8.2.3 update_skill 工具

新增 update_skill 内置工具,允许 agent 在运行时修改技能文件。

@tool
def update_skill(
    skill_name: str,
    file_path: str,      # e.g. "SKILL.md" or "scripts/main.py"
    new_content: str,
    reason: str,         # 更新原因,写入变更日志
) -> bool:
    """Update a skill's file content. Use when skill needs refinement."""

8.3 里程碑 2 — 核心生命周期循环

8.3.1 skill_create 工具

允许 agent 在运行过程中动态创建新技能。

@tool
def skill_create(
    name: str,
    description: str,
    specification: str,    # 高层次的技能规格
) -> SkillPackage:
    """Create a new skill from specification.
    
    1. Generate SKILL.md with frontmatter + workflow
    2. Generate scripts/ (optional)
    3. Generate tests/ (optional)
    4. Run unit tests in sandbox
    5. If tests pass → register into skill bank
    6. If tests fail → auto-refine and retry (max 3 attempts)
    """

生成策略:

  • 从成功轨迹中蒸馏(Phase 1 → Phase 2 模式)
  • 或从高层次规格即时生成
  • 遵循 Anthropic Skills 格式确保兼容性

8.3.2 单元测试门控 (Unit Test Gating)

在每个技能包中引入 tests/ 目录,创建和更新时自动运行测试。

测试框架: pytest-compatible
沙箱执行: 在 sandbox 中隔离运行(Docker 或子进程)
门控逻辑:

Skill Creation:
  1. Generate package (SKILL.md + scripts/ + tests/)
  2. Run: pytest tests/ --junitxml=result.xml
  3. ┌── all green → 注册到 Skill Bank
  4. └── failures  → parse error trace
       → update_skill 修补代码
       → re-run tests (max 3 retries)
       → 如果仍失败 → 标记为 draft,写入 .skill_memory.md 记录失败原因

8.3.3 self-evolution 循环

整合创建→评估→记忆→精炼的闭环。

Task Execution Loop with Self-Evolution:
  ┌─────────────────────────────────────────────────────┐
  │ while task not solved:                               │
  │   plan → detect if existing skills suffice           │
  │   ├── yes → retrieve + invoke skill                  │
  │   │        ├── success → update .skill_memory.md     │
  │   │        └── failure → invoke update_skill         │
  │   │                     → retry or fallback           │
  │   └── no  → invoke skill_create                      │
  │              → evaluate + register                   │
  │              → invoke newly created skill            │
  │   observe → feed results back to planner             │
  └─────────────────────────────────────────────────────┘

8.4 里程碑 3 — 高级能力

8.4.1 技能合并与裁剪

合并触发条件: 新创建的技能与已有技能功能重叠
合并策略:

  1. 检测 SKILL.md 中 “When to use” 和 “Core principles” 的语义相似度
  2. 如果重叠度 > 70% → 建议合并
  3. 合并后的技能保留更通用的描述和工作流

裁剪触发条件: 技能连续 N 次调用失败或 M 日未被使用
裁剪策略:

  1. 标记为 deprecated(不从 catalog 中删除)
  2. 移出 active catalog(不再注入 system prompt)
  3. 归档到 ~/.hermes/skills/.archive/ 目录

8.4.2 自适应上下文压缩

实现 MUSE 的两级上下文压缩机制(参见 4.5 节算法)。

实现要点:

# 在每次 LLM 调用前检查 context 大小
def maybe_compress(conversation, model):
    total = sum(token_count(node) for node in conversation.active_chain)
    if total <= COMPRESS_THRESHOLD:  # 180K
        return
    
    # Level 1: 压缩单个超大的 node
    for node in compressible_middle(conversation):
        if token_count(node) > NODE_THRESHOLD:  # 15K
            node.summarize(model)
    
    if total_after_level1 <= COMPRESS_THRESHOLD:
        return
    
    # Level 2: 合并中间区间为一个摘要节点
    span = compressible_span(conversation)
    summary_node = create_summary_node(model, span)
    conversation.rewire(parent_chain, summary_node)

8.4.3 跨 Session 状态持久化

在 session 结束时序列化完整 agent 状态(conversation DAG, skill usage, memory),支持断点续传。

# ctx_state.json
conversation_dag:
  nodes:
    - id: "node_1"
      plan: "..."
      action: "..."
      observation: "..."
      timestamp: "..."
      compressed_input: null
      parent_id: null
      history_prev: null
      history_next: "node_2"
  active_tip: "node_7"

8.5 集成时间线与优先级

优先级组件复杂度依赖交付物
P0.skill_memory.md简单无PR: skill 经验记忆
P0skill catalog 渐近式注入简单无PR: catalog + read_skill
P0update_skill 工具简单无PR: 技能更新能力
P1skill_create 工具中等catalogPR: 运行时技能创建
P1tests/ 门控中等sandboxPR: 单元测试评估
P1self-evolution 循环中高skill_create + evalPR: 自我进化闭环
P2技能合并/裁剪中等skill_createPR: 技能库维护
P2自适应上下文压缩高conversation DAGPR: 长上下文处理
P2跨 session resume高state persistencePR: 断点续传

预估工作量:

  • P0 项: 每个 1-2 天(已有 skill 系统基础上扩展)
  • P1 项: 每个 3-5 天(需 sandbox 集成和循环逻辑)
  • P2 项: 每个 5-10 天(需较大架构调整)

九、结论与启示

MUSE-Autoskill 提供了目前最完整的技能生命周期框架,其核心洞见是:

  1. 技能应被视为长期存在的、可进化的资产,而非一次性生成产物
  2. 技能级记忆是区分”真有经验”和”每次都从头推理”的关键机制
  3. 单元测试门控保证技能库质量,自动精炼循环确保持续改进
  4. 训练无关设计使得技能可跨智能体迁移,最大化复用价值
  5. Anthropic Skills 格式是实际部署中的统一接口标准

对于 Hermes Agent,P0 优先级的三个组件(技能级记忆、渐近式 catalog、update_skill 工具)可以在当前 skill 系统上快速集成,带来显著的能力提升。完整生命周期闭环的集成将使 Hermes Agent 具备与 MUSE-Autoskill 同等级别的自我进化能力。


本分析基于 arXiv:2605.27366v1 全文精读,SkillBench 基准测试数据引用自论文第 4 节,架构设计引用自第 3 节及附录 B/C/E。