## §0 TL;DR Cheat Sheet

> 💡 **8 句话搞定 Self-Evolving Agents** — 一页拿下 2024-2026 最前沿方向（详见 §1–§11 推导）。

1. **核心问题**：让 agent 在**长程任务**里持续提升能力，而不靠人类反复标注。形式化为 $\pi_t \to \pi_{t+1}$ 的更新算子 $\mathcal{T}$ 的收敛性 / 稳定性 / 渐进有效性。

2. **三大范式**：① Experience-Driven（人造任务 + reward，如 AgentTuning、Voyager）；② Adversarial Self-Play（Challenger-Solver，如 Absolute Zero、Ctx2Skill）；③ Meta-Learning / Reward-Free（无任务无奖励探索 + outcome-based reward，如 Native Evolution）。

3. **能力载体**：**自然语言 skill / world knowledge K 写成 markdown**——这是 2024-2026 年最重要的范式转移，绕开参数更新，所有内容都是 inference-time `system_prompt += K`。

4. **Ctx2Skill 5-角色 self-play**（arXiv 2604.27660）：Challenger / Reasoner / Judge / Proposer / Generator，**冻结 LM 但 skill set 在进化**。Cross-Time Replay 选 $\arg\max_i \rho^h_i \cdot \rho^e_i$ 防 adversarial collapse。

5. **Native Evolution 两阶段**（arXiv 2604.18131）：Evolution phase 无任务无 reward 探索 → 蒸馏 markdown K；Execution phase 用 K 当 system prompt。训练信号 $R_\text{evolve}(\mathcal{K}) = \text{Success}(\mathcal{T}_E\mid\mathcal{K}) - \text{Success}(\mathcal{T}_E\mid\varnothing)$。

6. **A²RD 三件套**（arXiv 2605.06924）：MVMem（textual states + frames + videos + dependency DAG）+ Adaptive Segment Gen + HITS（frame-level + video-level 自检）。直接迁移到任意长程 agent 当作 memory + audit 模板。

7. **理论上界**：[arXiv:2601.05280] 在**外源 grounding 信号缺失**时 closed-loop density matching 退化（**不是**所有 reward-free 训练必崩，是该 setting 下的特定结论）；[arXiv:2507.00075] 把 solver-verifier gap 建模 + 经验拟合成 capability dynamics。

8. **常见故障**：adversarial collapse（Challenger 极端化）、memory drift（K 内部矛盾累积）、reward hacking（self-rewarding 漂移）、bias amplification（agent 在自己输出上重训）、capability ceiling（外源 grounding 缺失时 self-improvement 退化）。

## §1 Self-Evolving Agent 直觉

"Self-evolving" 不是 magic。一个 LLM agent 由四件东西组成：

- **policy $\pi$**：参数化或纯 in-context 的决策函数
- **memory / knowledge $\mathcal{K}$**：外部化、通常是 markdown 形式的长期状态
- **skills $\mathcal{S}$**：可复用的过程性知识，每个 skill 是一个 markdown 文档
- **environment $E$**：可交互的世界（web / code / paper / sandbox / OS）

"Self-evolution" 就是定义一个更新算子 $\mathcal{T}$：

$$\big(\pi_t, \mathcal{K}_t, \mathcal{S}_t\big) \xrightarrow{\mathcal{T}(E, \text{trajectories})} \big(\pi_{t+1}, \mathcal{K}_{t+1}, \mathcal{S}_{t+1}\big)$$

按照 $\mathcal{T}$ 更新的对象，2024-2026 大致可以分四个"层"：

| 层 | 更新对象 | 更新方式 | 代表作 |
|---|---|---|---|
| L1 参数层 | $\pi$ (model weights) | SFT / RFT / RL | AgentTuning、Native Evolution |
| L2 能力层 | $\mathcal{S}$ (skills markdown) | self-play + replay | Voyager、Ctx2Skill、CoEvoSkills |
| L3 记忆层 | $\mathcal{K}$ (world knowledge markdown) | exploration + summarize | MemGPT、MVMem、Native Evolution |
| L4 系统层 | workflow orchestration | inference-time only | Anthropic Skills、ARIS-style harness |

> 💡 **重要直觉** — L1 是"训出本能"；L2/L3 是"长出工具箱 + 笔记本"；L4 是"工作流编排"。**2025-2026 主流是 L2 + L3，L1 主要做训练—测试解耦的预备工作**。

面试常错的两个直觉：

- ❌ "self-evolving = 自动训出新模型权重"——错，**绝大多数 work 不更新参数**（Voyager、Ctx2Skill、Generative Agents、A²RD 全是 training-free / inference-time）。
- ❌ "self-evolving = agent 想干什么就干什么"——错，2026 主流是**严格 grounding** 的 self-improvement：要么 code executor（Absolute Zero），要么 math checker（STaR），要么 rubric judge（Ctx2Skill），要么 outcome utility（Native Evolution）。

## §2 三种 Self-Evolution 范式的形式化

Native Evolution 论文 [arXiv:2604.18131] 给出了一个非常清晰的分类——我们补充上 mathematical formulation。

### 2.1　Experience-Driven Evolution

**Setting**：人提供任务集 $\mathcal{T}$、reward 函数 $R: \mathcal{O} \times \mathcal{A} \to \mathbb{R}$ 和 workflow。Agent 跑 trajectory $\tau$、按 $R(\tau)$ 加权更新。

**Update operator**：

$$\theta_{t+1} = \theta_t + \eta \,\mathbb{E}_{\tau \sim \pi_{\theta_t}}\!\left[\nabla_\theta \log \pi_\theta(\tau)\, R(\tau)\right]$$

这就是标准 policy gradient——AgentTuning、ToolLLM、Voyager 早期变种属于此类。

**优点**：监督密度高，收敛快。**缺点**：人力成本巨大（每个新环境都要重新设计 reward）。

### 2.2　Adversarial Self-Play Evolution

**Setting**：两 agent（Challenger + Solver）共同 evolve，无外部任务来源——任务由 Challenger 产生、Solver 解、verifier 给反馈。

**Update operator**（以 Absolute Zero / R-Zero 形式化）：

$$\theta^{\text{ch}}_{t+1}, \theta^{\text{sol}}_{t+1} = \arg\min_{\theta^{\text{ch}}, \theta^{\text{sol}}} \;\mathbb{E}_{t\sim \pi^\text{ch}_t}\big[\ell^\text{ch}(t)\big] + \lambda\, \mathbb{E}_{(t,a)\sim \pi^\text{ch}_t,\pi^\text{sol}_t}\big[\ell^\text{sol}(t,a)\big]$$

具体的"learnability reward"（Absolute Zero, arXiv 2505.03335）：

$$R^\text{learn}(t) = \pi^\text{sol}_t(\text{correct}\mid t)\cdot \big(1 - \pi^\text{sol}_t(\text{correct}\mid t)\big)$$

最大化时偏好 50% 难度——既不太简单也不太难。这是 curriculum-as-reward 的核心。

**优点**：无需人造任务集；**缺点**：仍需 verifier（code executor / math checker），且容易 **adversarial collapse**（Challenger 出极端任务、Solver 学到 trivial defense）。

### 2.3　Meta-Learning / Reward-Free Evolution

**Setting**（Native Evolution）：训练阶段给 outcome-based reward（**不是** step-level）；推理阶段无任务、无 reward——agent 自主探索 → 蒸馏 markdown world knowledge $\mathcal{K}$ → 下游任务里用 $\mathcal{K}$ 作 system prompt。

**Reward 设计**（Native Evolution 核心公式）：

$$\boxed{\;R_\text{evolve}(\mathcal{K}) \;=\; \text{Success}(\mathcal{T}_E \mid \mathcal{K}) \;-\; \text{Success}(\mathcal{T}_E \mid \varnothing)\;}$$

其中 $\mathcal{T}_E$ 是环境 $E$ 的 downstream task 集合（训练时观察得到）。**reward 衡量的是 K 的下游 utility gain**，不需要 step-level 监督。

**优点**：完全 task-free / reward-free at inference；**缺点**：训练成本高（rejection sampling RFT × 2 iteration），且 $\mathcal{T}_E$ 在训练时仍需 labeled data。

> ⚠️ **常错点：reward-free at inference ≠ reward-free 训练** — Native Evolution evolution phase **推理时**确实无 reward / 无 task；但**训练**时仍然需要 600 deep search questions × 20 websites 的 labeled set 来算 $R_\text{evolve}$。这是面试加分点：要主动 disambiguate。

### 2.4　三范式对比（必背）

| 维度 | Experience-Driven | Adversarial | Meta-Learning |
|---|---|---|---|
| 训练时 task 来源 | 人 | Challenger agent | 内生探索 + labeled downstream |
| 训练时 reward | 人 | verifier | outcome utility |
| 推理时 task | 人给 | 人给 / agent 自己 | 人给 |
| 推理时 reward | 不需要 | 不需要 | **不需要** ✓ |
| 推理时 workflow | 人编排 | 人编排 | **agent 自驱**（先 evolve 再 execute）✓ |
| 代表作 | AgentTuning、ToolLLM | AZR、R-Zero、Ctx2Skill | Native Evolution |
| 工程成本 | 高（reward eng.）| 中（verifier 编排）| 高（rejection sampling）|
| arXiv | 2310.12823 | 2505.03335 / 2604.27660 | 2604.18131 |

## §3 Skill / Knowledge 的 Markdown 化（最重要的工程转移）

2024 年最重要的一个范式转移是：**长期记忆和能力扩展不通过权重更新，而是通过外部 markdown 文档**。

### 3.1　Anthropic Skills + Native Evolution 的趋同

Anthropic 在 2025 年公开了 `skills/` 范式（每个 skill 是一个独立 markdown 文件，agent 按需 load 到 system prompt）。Native Evolution 在论文里**明确引用了 Anthropic skills**作为 K 的实现 reference（论文 §3，footnote 1 指向 `github.com/anthropics/skills/tree/main/skills`）。

| 维度 | Anthropic Skills | Native Evolution K |
|---|---|---|
| 表示 | markdown | markdown |
| 加载 | 按 task 选择 skill 注入 system prompt | 按 environment 加载 K 注入 system prompt |
| 粒度 | "如何做 PDF / Excel / git commit" | "ACL2025 网站结构 / 某 code repo 拓扑" |
| 监督 | 人写 | agent 自动 distill |
| 来源 | 静态人造 | 训练后内生 |

→ 趋同结论：**system prompt 是新的 model weights，markdown 文档是新的 fine-tuning data**。

### 3.2　Skill / K 文件的典型 schema

```
# skill_name
## Trigger / When-to-use
<什么 task 该用这个 skill>

## Steps
1. ...
2. ...

## Resources / References
- file paths / URLs

## Failure modes
- 已知陷阱 + 修复方式
```

Native Evolution 的 K 还会显式存：

- **Visual arcs**（实体/环境的视觉演化）
- **Spatial relations**（subject-relation-object triplets）
- **Camera states / Site map**（环境拓扑）
- **Token budget allocation**（每个子页面分多少 token）

### 3.3　为什么 markdown 而不是 vector embedding？

- **可解释**：人类可以审计、修订、merge
- **可组合**：skill A + skill B 直接 prepend
- **可路由**：可以 LLM 自己读 trigger 段决定 load 哪个
- **可演化**：自然语言 diff 比 vector diff 更稳定

代价：检索精度不如 vector RAG；解决方式是 hybrid（vector 做 candidate selection → markdown 做精读）。

## §4 Voyager / Reflexion / STaR：奠基三件套

进入 2024-2026 前沿之前，必须先把三个奠基 work 嚼透——面试官十有八九会问 baseline。

### 4.1　Voyager（Wang 2023 NeurIPS, NVIDIA + Caltech）

第一个真正意义上的"自动 curriculum + skill library"端到端 agent：在 Minecraft 里跑 GPT-4，让它自己出任务、写 JS code（每段 code 是一个 skill）、自检、并把成功的 skill 存进 library。

核心三件套：

- **Automatic Curriculum**：根据当前 inventory 状态让 GPT-4 提出下一个 task
- **Skill Library**：每个新 skill 是 JS function，embedding 索引、按 description 检索
- **Iterative Prompting + Self-Verification**：execute → env feedback → critic agent → revise，直到通过

> ⚠️ **常见误传** — Voyager 不更新 GPT-4 权重，纯 inference-time。也不用 reward；用的是 GPT-4 自己当 critic 判断 task 成功，属于 self-verification 类（不是 RL）。

### 4.2　Reflexion（Shinn 2023 NeurIPS, Northeastern）

把"verbal RL"概念固化：每次失败后，agent 用自然语言对自己 trajectory 写一段反思（reflection），存进 episodic memory，下次 prompt 时 prepend。

形式化（伪 Bellman）：

$$M_{t+1} = M_t \cup \big\{\text{reflect}(\tau_t, r_t)\big\}$$

其中 $\text{reflect}$ 是 LLM 自己实现的 "what went wrong + how to fix" 文本生成。

**为什么有效**（理论上）：reflection 把稀疏 reward 信号压缩成结构化文本，绕开梯度更新；等价于在 in-context 域做一种**非参数化 policy improvement**。但缺乏收敛 guarantee。

### 4.3　STaR (Self-Taught Reasoner, Zelikman 2022 NeurIPS, Stanford)

让 LM 自己**生成 rationale → 答错就用真答案 rationalize → 把对的 (q, rationale, a) 拿来 SFT**。是 self-improvement on reasoning 的真正起点。

伪算法：

```
for iter in 1..N:
    for each (q, a_gt) in D:
        r, a_pred = LM(q)
        if a_pred == a_gt:
            collect (q, r, a_gt)
        else:
            r' = LM(q, hint=a_gt)        # rationalize
            if r' produces a_gt:
                collect (q, r', a_gt)
    SFT(LM, collected)
```

STaR 的关键缺陷（也是 [arXiv:2601.05280] 攻击 self-improvement 的核心论据）：**rationalization 是 reverse-engineering 答案，不一定反映真实推理过程**，导致 distribution drift。

## §5 Ctx2Skill：5-角色 Self-Play Loop（重点 1）

> 这一节几乎逐字对应 arXiv 2604.27660 的 §3，因为面试官可能从论文里逐字问。

### 5.1　Problem formulation

给一个 context $C$（可能是 100k+ tokens 的 manual / paper / repo / dataset），一个 task 集 $\mathcal{T} = \{t_j\}$，每个 task 有 binary rubric 集 $\mathcal{R}_j = \{r_{j,k}\}$。Solving indicator：

$$y_j(\pi; C) = \prod_k \mathbb{I}\big[r_{j,k}(a_j) = \text{pass}\big], \quad a_j \sim \pi(\,\cdot\mid C, t_j)$$

目标：构造 markdown skill set $\mathcal{S}^R$ 使得：

$$a_j \sim \pi(\,\cdot\mid \mathcal{S}^R, C, t_j) \quad \text{maximizes}\ \mathbb{E}_j y_j$$

且**不更新 $\pi$ 的参数**——只更新 $\mathcal{S}^R$。

### 5.2　5 个 frozen LM 角色

| 角色 | 输入 | 输出 | 直觉 |
|---|---|---|---|
| **Challenger** | $C$, $\mathcal{S}^C_{i-1}$ | 一批 $(t_m, \mathcal{R}_m)$ | 出 probing 任务 |
| **Reasoner** | $C$, $\mathcal{S}^R_{i-1}$, $t_m$ | $a_m$ | 用 skill 解题 |
| **Judge** | $a_m$, $\mathcal{R}_m$ | binary $y_m$ | 严格按 rubric 验 |
| **Proposer (per side)** | failed/solved batch + 当前 skill set | 自然语言 diagnosis | 找根因，不写 skill |
| **Generator (per side)** | proposer diagnosis + 当前 skill set | 新 skill set | materialize 修改 |

注意**两路独立 evolve**：

- **Reasoner side**：失败案例 → Reasoner Proposer 诊断"缺什么 contextual knowledge" → Reasoner Generator 写新 $\mathcal{S}^R_i$
- **Challenger side**：被太容易解的案例 → Challenger Proposer 诊断"为什么 challenger 出题太弱" → Challenger Generator 强化 $\mathcal{S}^C_i$

→ 这两路**永远不交换 skill set**——保持严格对抗。

### 5.3　Cross-Time Replay 机制（核心防 collapse）

iteration 越多，Challenger 越极端，Reasoner 越 over-specialize 到极端任务。直接返回 $\mathcal{S}^R_N$ 会糟。

**Replay 流程**：

1. 训练过程中维护两个 probe set：
   - **Hard set $\mathcal{Q}^h$**：每 iteration 选 rubric pass rate 最低的失败 task
   - **Easy set $\mathcal{Q}^e$**：每 iteration 选 rubric pass 最少的 solved task（"刚好解出来"的）

2. 训练结束后，对每个候选 $\mathcal{S}^R_i$（$i=1\ldots N$）跑 Reasoner $\pi^R$ 在两个 probe set 上：

$$\rho^h(i) = \frac{\sum_{q\in \mathcal{Q}^h} y_q(\pi^R; C, \mathcal{S}^R_i) + 1}{|\mathcal{Q}^h| + 1}, \quad \rho^e(i) = \frac{\sum_{q\in \mathcal{Q}^e} y_q(\pi^R; C, \mathcal{S}^R_i) + 1}{|\mathcal{Q}^e| + 1}$$

（Laplace smoothing 防 probe set 为空）

3. 选：

$$\boxed{\;\mathcal{S}^R_\star = \mathcal{S}^R_{i^\star}, \quad i^\star = \arg\max_i \big(\rho^h(i) \cdot \rho^e(i)\big)\;}$$

**为什么乘积而不是加和**：乘积惩罚 catastrophic forgetting（如果某版本 $\rho^e \to 0$，整个分数 → 0），强制选两边都不太差的版本。Ctx2Skill ablation 显示用加和会让最终精度下降 ~1.5%。

### 5.4　Ctx2Skill 5-角色 + Replay 代码骨架

```python
def ctx2skill_loop(context: str, llm, num_iters: int = 5, M: int = 5):
    """
    Ctx2Skill: 5 frozen LM 角色 + Cross-Time Replay.
    返回 cross-time-replay 选出的最优 Reasoner skill set.
    所有 LM 调用都是同一个 frozen backbone, 只有 skill set 在变.
    """
    S_R = ""                    # Reasoner skill markdown (初始空)
    S_C = ""                    # Challenger skill markdown
    candidates = []             # 历史 S_R 候选 (cross-time)
    Q_hard, Q_easy = [], []     # 两个 probe set

    for i in range(1, num_iters + 1):
        # ── (1) Challenger 出 batch ──
        batch = llm(role="challenger", prompt=challenger_prompt(context, S_C), n=M)
        # batch = [(t_m, rubrics_m), ...]

        failed, solved = [], []
        for t_m, rubrics_m in batch:
            # ── (2) Reasoner 解题 ──
            a_m = llm(role="reasoner", prompt=reasoner_prompt(context, S_R, t_m))
            # ── (3) Judge per-rubric ──
            per_rubric = [llm(role="judge", prompt=judge_prompt(a_m, r))
                          for r in rubrics_m]
            y_m = all(per_rubric)
            pass_rate = sum(per_rubric) / len(per_rubric)
            (failed if not y_m else solved).append(
                (t_m, rubrics_m, a_m, pass_rate)
            )

        # ── 维护 probe sets (Laplace 平滑前预备) ──
        if failed:
            hardest = min(failed, key=lambda x: x[3])
            Q_hard.append((hardest[0], hardest[1]))
        if solved:
            # solved 中 pass_rate 最低的 (即 "勉强解出" — 所有 rubric pass 但很多 prompt 都险险通过)
            # 注意：solved 的 entries 都满足 all(per_rubric)，所以 pass_rate=1.0；
            # 实际生产里 "勉强解出" 应该用 per-rubric soft 分数 (例如 LLM-judge 给 [0,1] 而非 0/1)，
            # 这里教学版以接近解题边界的 task 为代表（即 batch 中 reasoner 用了最多 retry 的）
            easiest_among_solved = solved[-1]  # 教学简化：取最后一个 solved task
            Q_easy.append((easiest_among_solved[0], easiest_among_solved[1]))

        # ── (4) 双路 Proposer 诊断 ──
        diag_R = llm(role="reasoner_proposer",
                     prompt=proposer_prompt(failed, S_R))
        diag_C = llm(role="challenger_proposer",
                     prompt=proposer_prompt(solved, S_C))

        # ── (5) 双路 Generator 写 skill ──
        S_R = llm(role="reasoner_generator",
                  prompt=generator_prompt(diag_R, S_R))
        S_C = llm(role="challenger_generator",
                  prompt=generator_prompt(diag_C, S_C))

        candidates.append(S_R)

    # ── Cross-Time Replay ──
    best_idx, best_score = 0, -1.0
    for i, cand in enumerate(candidates):
        rho_h = laplace_smoothed_rate(Q_hard, cand, llm, context)
        rho_e = laplace_smoothed_rate(Q_easy, cand, llm, context)
        score = rho_h * rho_e
        if score > best_score:
            best_score, best_idx = score, i

    return candidates[best_idx]


def laplace_smoothed_rate(probe, skill_set, llm, context):
    """ Laplace-smoothed pass rate: (sum_q y_q + 1) / (|probe| + 1).
    
    Args:
        probe:     list[(task, rubrics)]
        skill_set: candidate S_R^i 要评估的 markdown skill
        llm:       frozen LM
        context:   原始 context（与 ctx2skill_loop 入参同源；必须显式传入，
                   防止 closure 误用）
    """
    num_pass = 0
    for t_q, rubrics_q in probe:
        a = llm(role="reasoner",
                prompt=reasoner_prompt(context, skill_set, t_q))
        if all(llm(role="judge", prompt=judge_prompt(a, r))
               for r in rubrics_q):
            num_pass += 1
    return (num_pass + 1) / (len(probe) + 1)
```

### 5.5　Ctx2Skill 实验结果（必记）

CL-bench 上，**没有任何参数更新**：

| backbone | w/o skills | Ctx2Skill | Δ |
|---|---|---|---|
| GPT-4.1 | 11.1% | **16.5%** | **+5.4** |
| GPT-5.1 | 21.2% | **25.8%** | **+4.6** |
| GPT-5.2 | 18.2% | **21.4%** | **+3.2** |

→ 用 GPT-4.1 + Ctx2Skill (16.5%) **超过** 无 skill 的 Gemini 3 Pro (15.8%)——印证"high-quality skill 可弥补 model 差距"。

### 5.6　Ctx2Skill ablation（面试加分）

| 去掉的部件 | GPT-4.1 Δ from 16.5 | GPT-5.1 Δ from 25.8 |
|---|---|---|
| Cross-Time Replay | −1.8 (→14.7) | −2.8 (→23.0) |
| decoupling Proposer + Generator | −0.6 | −0.7 |
| Challenger evolving | **−2.6 (→13.9)** ← 最大 | −3.3 ← 最大 |
| Easy probe set | −0.8 | −1.6 |
| Hard probe set | −1.3 | −1.1 |
| Laplace smoothing | −1.0 | −0.6 |

**Challenger evolving 的下降最大**——证明"持续 adversarial pressure"是 Reasoner 进步的真正动力。

## §6 Native Evolution：Reward-Free Meta-Learning（重点 2）

> 全部对应 arXiv 2604.18131。Tencent + HKUST(GZ)，2026-04-20。

### 6.1　核心 architecture：双阶段解耦

```
  ┌─────────────────────────────────┐       ┌──────────────────────────────┐
  │      Native Evolution Phase     │       │   Knowledge-Enhanced Execution│
  │      (推理时 task-free + rf)     │       │   (推理时拿 K 当 system prompt)│
  │                                 │       │                              │
  │   π_θ(K | E)                    │  ──→  │   π_task(a_t | o_t, K, Task) │
  │   "exploring + summarizing"     │       │                              │
  │                                 │       │                              │
  └──────────────┬──────────────────┘       └──────────────────────────────┘
                 │
                 │ (训练时用 outcome-based reward 监督 evolve)
                 ▼
  R_evolve(K) = Success(T_E | K) − Success(T_E | ∅)
```

**关键 design choice**：evolution 和 execution 用**同一个 LLM**（不像 RLHF 区分 SFT-policy / RM）；只是给不同 system prompt + 训练阶段经过 SFT + RFT 让它学会 "evolution mode"。

### 6.2　Outcome-Based Reward 设计

$$\boxed{\;R_\text{evolve}(\mathcal{K}) = \underbrace{\text{Success}(\mathcal{T}_E\mid \mathcal{K})}_{\text{有 K 时下游成功率}} - \underbrace{\text{Success}(\mathcal{T}_E\mid \varnothing)}_{\text{无 K baseline}}\;}$$

其中 $\text{Success}(\mathcal{T}_E\mid \mathcal{K}) = \frac{1}{M}\sum_{j=1}^M \mathbb{I}\big[f(Q_j, \mathcal{K}) = A_j\big]$。

**为什么 outcome-based 而不是 step-level？**

| 维度 | step-level | outcome-based |
|---|---|---|
| 监督密度 | 高 | 低 |
| 信号噪声 | 中（中间状态难评估）| 低（end-task 答案是 ground truth）|
| reward hacking 风险 | 高（agent 学到 short-cut 拿中间分）| 低（只能靠真正提高 task 成功）|
| 工程复杂度 | 高（需 PRM）| 低 |

Native Evolution 选 outcome-based 还有一个特殊原因：**$\mathcal{K}$ 是整段 markdown（374.8 步 × 3322.4 tokens/step），step-level reward 在如此长 horizon 上几乎无意义**。

### 6.3　两阶段训练：SFT → RFT

**Stage 1 (SFT)**：
- 用 teacher model $\pi_T$ (Gemini-2.5-Pro) 生成 3 个候选 $\{\mathcal{K}_i\}_{i=1}^3$
- 算 $R_\text{evolve}(\mathcal{K}_i)$，选最优 $\mathcal{K}^\star$
- 用 $T^\star = \{Q, o_1^\star, a_1^\star, \ldots, o_k^\star, a_k^\star\}$ trajectory SFT base model $\pi_{\theta_0}$
- 训练数据：600 deep search questions × 20 websites

**Stage 2 (RFT, Rejection Sampling Fine-Tuning)**：
- 用 $\pi_{\theta_1}$ 自己生成 $C$ 个候选 K
- 按 $R_\text{evolve}$ 选最高分
- 用最高分 trajectory 继续 fine-tune
- 跑 2 iteration

> ⚠️ **常见误解** — Native Evolution 用 RFT 而不是 GRPO/PPO 的原因：(1) trajectory horizon ~ 374 步，GRPO 反传不可行；(2) reward 评估要跑 auxiliary agent 在 downstream task 上，太贵 → 用 offline rejection sampling 解耦 trajectory 生成与 policy 更新。

### 6.4　Native Evolution 训练 + 推理代码骨架

```python
def native_evolution_pipeline(base_model, teacher_model, env_pool,
                              downstream_tasks_per_env, num_iter=2,
                              C_sft: int = 3, C_rft: int = 8):
    """
    Native Evolution: SFT + RFT (2 iter) → 学会 reward-free self-evolution.
    
    Args:
        C_sft: SFT 阶段 teacher 生成 K 候选数（论文 3）
        C_rft: RFT 阶段 pi 自生成候选数（论文 8）
    """
    # ── Stage 1: SFT ──
    sft_data = []
    for E in env_pool:
        T_E = downstream_tasks_per_env[E]            # labeled downstream
        # baseline: 不给 K
        s0 = success_rate(base_model, T_E, K=None)

        # teacher 生成 C_sft 个候选 K
        candidates = [explore_and_summarize(teacher_model, E)
                      for _ in range(C_sft)]
        # 评 reward = Success(T_E | K) − Success(T_E | ∅)
        rewards = [success_rate(base_model, T_E, K=K) - s0
                   for K in candidates]
        K_star = candidates[argmax(rewards)]
        traj_star = extract_trajectory(teacher_model, E, K_star)
        sft_data.append(traj_star)                   # ~374 steps each

    pi_1 = sft(base_model, sft_data)                 # warm-up

    # ── Stage 2: RFT × num_iter ──
    pi = pi_1
    for it in range(num_iter):
        rft_data = []
        for E in env_pool:
            T_E = downstream_tasks_per_env[E]
            s0 = success_rate(pi, T_E, K=None)
            # pi 自己生成 C_rft 个候选
            candidates = [explore_and_summarize(pi, E) for _ in range(C_rft)]
            rewards = [success_rate(pi, T_E, K=K) - s0
                       for K in candidates]
            best = candidates[argmax(rewards)]
            rft_data.append(extract_trajectory(pi, E, best))
        pi = sft(pi, rft_data)                       # next iter

    return pi   # π_θ*: 学会了 native evolution


def native_evolution_inference(pi_star, new_env, task):
    """
    推理时: 无 task, 无 reward → 探索 → 蒸馏 K → 用 K 解题.
    """
    K = explore_and_summarize(pi_star, new_env)      # task-free!
    answer = pi_star(task, system_prompt=K)          # K-augmented
    return answer
```

### 6.5　Native Evolution 实验结果

WebVoyager + WebWalker，14B Qwen3 / 36B Seed-OSS：

| backbone | w/o K | Native Evolution (RFT) | Δ |
|---|---|---|---|
| Qwen3-30B (WebWalker) | 22.04 | **40.91** | **+18.9** |
| Qwen3-30B (WebVoyager) | 41.08 | **57.44** | **+16.4** |
| Seed-OSS-36B (WebWalker) | 19.50 | 36.72 | +17.2 |

**最 striking**：14B Qwen3 + transferred K from 36B → 35.6% conference accuracy；**unassisted Gemini-2.5-Flash 只有 31.3%**——证明 high-quality K 可超过纯参数缩放。

### 6.6　Native Evolution vs Ctx2Skill 对比

| 维度 | Native Evolution | Ctx2Skill |
|---|---|---|
| 是否更新参数 | 是（SFT + RFT × 2 iter）| 否（frozen LM, 只更新 skill）|
| 推理时是否需 task | 否（先 evolve 再 execute）| 是（task-driven）|
| Knowledge 容器 | $\mathcal{K}$（markdown 环境 map）| $\mathcal{S}^R$（markdown skills）|
| Reward 设计 | outcome-based downstream utility | binary rubric judge |
| 反 collapse 机制 | rejection sampling (filter)| Cross-Time Replay |
| 训练成本 | 高 | 低 |
| 推理成本 | 较低 | 中 |
| 适用任务 | new environment 探索 | dense context task |

→ **它们是互补的**：Native Evolution 让 backbone 学会**怎么探索**；Ctx2Skill 让冻结 backbone**怎么把 context 蒸馏成可复用 skill**。可以叠加。

## §7 A²RD 与 Long-Horizon Memory Architecture（重点 3）

> arXiv 2605.06924，Google Cloud AI + NUS，2026-05-07。虽然是 video，但 memory schema 直接迁移到所有 long-horizon agent。

### 7.1　Retrieve → Synthesize → Refine → Update 闭环

```
   ┌──────────────────────────────────────────────────────────────┐
   │   for segment i = 1..N:                                       │
   │     1. Retrieve relevant context from MVMem (T_j, F_j, V_j)   │
   │     2. Decide mode: extrapolation vs interpolation            │
   │     3. Synthesize boundary frames F_i^begin, F_i^end          │
   │     4. HITS (frame-level): verify + revise frames             │
   │     5. Synthesize video segment V_i = TI2V(P_i, F_i, F^rel)   │
   │     6. HITS (video-level): verify + revise via MAPO           │
   │     7. Update MVMem with (F_i, V_i, T_i, T_{i+1}^F)           │
   └──────────────────────────────────────────────────────────────┘
```

### 7.2　MVMem schema（textual states + frames + videos）

$$\mathcal{M} := \{\mathcal{M}_1, \ldots, \mathcal{M}_N\} \cup \mathcal{R} \cup \mathcal{D}$$

每段 $\mathcal{M}_j = \{T_j, \mathcal{F}_j, V_j\}$：

- **Textual States $T_j$**：包含 Visual Arcs（entity identity / motion）+ Spatial Relations（subject-relation-object triplets，ground geometric layout）+ Camera trajectories
- **Frames $\mathcal{F}_j = \{F_j^\text{begin}, F_j^\text{end}\}$**：keyframes
- **Videos $V_j$**：完整 segment

加上：

- **$\mathcal{R}$**：global reference frames (background, entity references)
- **$\mathcal{D}$**：prompt database（失败 prompt 也存）

### 7.3　Dependency DAG（关键 trick）

reference 之间有依赖：entity 依赖 environment、camera 依赖 entity 位置。A²RD 建一个 DAG：

$$\mathcal{G} := \text{MLLM}_\text{dep}(\mathcal{P}_\mathcal{R})$$

然后 topological sort 决定合成顺序。直接迁移到 ARIS-style agent：研究项目里 claim ← experiment ← code ← idea，typed memory 也是 DAG。

### 7.4　HITS: Hierarchical Test-Time Self-Improvement

两级：

- **Frame-level HITS**：对每个 $F^\text{begin}, F^\text{end}$ 用 VLM verify "是否符合 textual state"，不符合 → MAPO (Multi-Aspect Prompt Optimization) 改 prompt → 重生成
- **Video-level HITS**：对整段 $V_i$ 用 VLM verify "narrative continuity"，不符合 → 改 video prompt → 重生成

→ **inner-segment + inter-segment 两个 scale 的自检**——比单层 self-improvement 防 drift 更强。

### 7.5　迁移到通用 long-horizon agent（典型 cheat-sheet）

```python
class TypedMemory:
    """A²RD MVMem 思想 ⇒ 通用 long-horizon agent memory."""
    def __init__(self):
        self.segments = []          # list of {state, artifacts, deps}
        self.global_refs = {}       # 全局实体 (e.g., paper-level claim)
        self.dep_graph = {}         # DAG: which artifact depends on which
        self.failure_db = []        # 失败 trace 数据库

    def retrieve(self, current_segment_ctx, k=3):
        """检索 narratively-relevant 上下文 (前 k 段)."""
        cands = []
        for j, M_j in enumerate(self.segments):
            score = relevance(M_j["state"], current_segment_ctx)
            cands.append((score, j))
        topk = sorted(cands, reverse=True)[:k]
        return [self.segments[j] for _, j in topk]

    def update(self, segment, deps):
        self.segments.append(segment)
        seg_id = len(self.segments) - 1
        self.dep_graph[seg_id] = deps      # parent ids

    def topo_synthesis_order(self, num_segments: int) -> list[int]:
        """A²RD 的 dependency DAG → 决定生成顺序.
        
        Args:
            num_segments: 待生成段总数；自动补充未在 dep_graph 中的节点为 root.
        Returns:
            合法的 topological order (list of segment indices).
        """
        # 自动把所有 0..num_segments-1 都加入 graph (没有依赖的视为 root)
        graph = {i: self.dep_graph.get(i, []) for i in range(num_segments)}
        return topological_sort(graph)


def long_horizon_agent_with_hits(memory, segments_to_generate, llm, verifier):
    """A²RD 风格的 R→S→R→U 闭环.
    
    Note: segments_to_generate 是需要生成的段的 context 描述列表；
    生成 order 由 memory.dep_graph 决定（若空，则默认顺序生成）。
    """
    order = memory.topo_synthesis_order(num_segments=len(segments_to_generate))
    for i in order:
        # Retrieve
        ctx = memory.retrieve(segments_to_generate[i])
        # Synthesize
        artifact = llm.generate(segments_to_generate[i], context=ctx)
        # Frame-level HITS (artifact 内部一致性)
        for _ in range(MAX_REFINES):
            if verifier.frame_check(artifact): break
            artifact = llm.refine(artifact, verifier.feedback)
        # Video-level HITS (artifact 与历史一致性)
        for _ in range(MAX_REFINES):
            if verifier.video_check(artifact, ctx): break
            artifact = llm.refine(artifact, verifier.feedback)
        # Update
        memory.update(artifact, deps=ctx)
```

## §8 Self-Improvement 的理论上界（L3 level）

两篇 2025-2026 必读理论 paper——这是顶级 lab 面试可能问的部分。

### 8.1　On the Limits of Self-Improving in LLMs（arXiv 2601.05280）

**全名**: "On the Limits of Self-Improving in LLMs: The Singularity Is Not Near Without Symbolic Model Synthesis"

**Setup**：把 self-training 建模成概率分布上的 dynamical system：

$$p_{t+1} = \mathcal{T}_\text{closed}(p_t) = \mathbb{E}_{x \sim p_t}\big[\delta_{x'}\big],\quad x' = \pi_t(x)$$

即 $p_{t+1}$ 是当前模型在自己样本上重训得到的分布。

**主定理（叙述版）**：在 closed-loop density matching（无外源 grounding signal）下，若 $\pi_t$ 没有访问 ground truth，则 $\{p_t\}$ 一般不收敛到 target $p^\star$，且会在 mode collapse / drift 中退化。

**核心 mechanism**：

$$D_\text{KL}(p^\star \,\|\, p_{t+1}) \;\ge\; D_\text{KL}(p^\star \,\|\, p_t) - \Delta_\text{grounding}$$

其中 $\Delta_\text{grounding}$ 是 grounding 信号带来的 KL 减少。无 grounding ($\Delta = 0$) 时 KL 不降反升。

**正面 implication**：**self-improvement 需要外源 grounding**——code executor / math checker / human label / rubric judge——这就是为什么 Absolute Zero 必须挂 code executor，STaR 必须用 ground-truth answer 做 rationalization，Ctx2Skill 必须用 Judge 验 rubric。

> ⚠️ **误读警告（面试加分）** — 这篇 paper **不是**证明 "reward-free 训练一定崩"；它证明的是 closed-loop density matching 在外源 grounding 信号缺失时退化。**Native Evolution 仍然合规**——它有 outcome-based reward 当 grounding。

### 8.2　Solver-Verifier Gap（arXiv 2507.00075）

**Setup**：把 capability 演化建模成两个变量 $\theta^\text{sol}, \theta^\text{ver}$ 的耦合 dynamics：

$$\begin{cases} \dot\theta^\text{sol} = \eta_s\, g_s(\theta^\text{sol}, \theta^\text{ver}) \\ \dot\theta^\text{ver} = \eta_v\, g_v(\theta^\text{sol}, \theta^\text{ver}) \end{cases}$$

**经验观察**：capability $C(\theta)$ 在 self-improvement 下服从（拟合的）**指数律**：

$$C(\theta_t) \approx C_\infty - (C_\infty - C_0)\, e^{-\kappa t}$$

且 $\kappa$ 与 solver-verifier gap $\Delta := C^\text{ver} - C^\text{sol}$ **正相关**（gap 越大、improvement 越快），但 gap 太大也会 saturate（verifier 给的反馈 solver 学不到）。

**对工程的指导**：

- 跨模型 reviewer（如 ARIS 用 Codex 5.5 review Claude）天然制造 verifier-solver gap → 加速 self-improvement
- 同模型 self-review 几乎无 gap → 收敛慢甚至无效

> ✅ **这是支撑"executor != reviewer family"协议的最佳理论 motivation** —— 但请记住这是 **modeling + empirical fit，不是现成定理**。

### 8.3　两篇论文的实际含义

| 论文 | 主张 | 工程 takeaway |
|---|---|---|
| 2601.05280 | 无 grounding 时 closed-loop self-training 退化 | 必须有外源 verifier（executor / judge / rubric）|
| 2507.00075 | solver-verifier gap 与 improvement 速率正相关（建模 + 经验）| 用跨模型 reviewer 提高 gap |

→ 二者结合：**reward-free at inference + grounded at training** 是 Native Evolution 等 work 能 work 的根本原因；**ARIS-style 跨模型 audit** 是 system-level 加速 self-improvement 的工程选择。

## §9 Memory-Driven Self-Evolution

### 9.1　Generative Agents（Park 2023 UIST, Stanford）

最经典的 long-horizon 仿真：observation stream → memory store → reflection (LLM 自己写 insight) → planning。

记忆三层：

- **Observation memory**：原始 timestamp + 字面描述
- **Reflection memory**：由 retrieval-augmented LLM 生成"insight"
- **Planning memory**：long-term goal

**retrieval score**：

$$\text{score}(m) = \alpha_\text{recency}\, r(m) + \alpha_\text{importance}\, i(m) + \alpha_\text{relevance}\, s(m, q)$$

其中 $r(m) = \gamma^{\Delta t}$（指数 decay），$i(m) \in [1,10]$（LLM 自评），$s(m,q)$ cosine similarity。

### 9.2　MemGPT（Packer 2023, Berkeley）

OS-style hierarchical memory：

- **Main context**（LLM token budget）= "RAM"
- **External archival**（disk）= "HDD"
- LLM 学会 paging：`memgpt_function_call(load, save, summarize)`

**核心 trick**：让 LLM 在自己 context 内观察到 token usage，主动决定换页——这是把 OS 抽象搬到 LLM agent。

### 9.3　这一层与 Ctx2Skill / Native Evolution 关系

| 维度 | Generative Agents | MemGPT | Ctx2Skill | Native Evolution |
|---|---|---|---|---|
| 进化对象 | reflection / plan | paging policy | skill | K (world map)|
| 是否更新参数 | 否 | 否 | 否 | 是 |
| 触发频率 | per observation | per context overflow | per failure batch | per training epoch |
| 是否 task-driven | 是 | 是 | 是 | 否（evolution 阶段）|

→ memory-driven 这条线 2024-2026 演化方向：**从 episodic（GA）→ hierarchical (MemGPT) → typed + DAG (MVMem)**。

## §10 Skill / K 检索与排序（工程实践）

实际部署时，skill library 几十到几百条，必须**按需 load**——否则 token 爆炸。

### 10.1　Hybrid retrieval pipeline

```python
def hybrid_skill_retrieval(task: str, skills: list, k=3):
    """
    Stage A: 粗筛 (vector embedding, fast)
    Stage B: 精排 (LLM scoring on description, accurate)
    Stage C: 按 trigger 段精确匹配 (deterministic)
    """
    # ── Stage A: BM25 + dense embedding hybrid ──
    bm25_scores = bm25_search(task, [s.description for s in skills], topn=20)
    dense_scores = dense_search(task, [s.embedding for s in skills], topn=20)
    candidates = top_k(merge(bm25_scores, dense_scores), n=10)

    # ── Stage B: LLM rerank ──
    reranked = []
    for skill in candidates:
        prompt = f"task={task}\nskill trigger={skill.trigger}\n" \
                 f"Q: relevant? (yes / no / partial)"
        verdict = llm(prompt)
        score = {"yes": 1.0, "partial": 0.5, "no": 0.0}[verdict]
        reranked.append((score, skill))

    # ── Stage C: 关键词强匹配 ──
    keyword_hits = [s for s in skills
                    if any(kw in task.lower() for kw in s.exact_triggers)]

    # 合并去重 → 取 top k
    final = top_k(reranked + [(2.0, s) for s in keyword_hits], k=k)
    return [s for _, s in final]
```

### 10.2　Skill 排序公式

加权融合 3 个信号：

$$\text{score}(s, q) = \alpha_\text{sim}\, \cos(\mathbf{e}_s, \mathbf{e}_q) + \alpha_\text{prior}\, \log(1 + n_\text{used}(s)) + \alpha_\text{recent}\, \gamma^{\Delta t}$$

其中 $n_\text{used}$ 是历史调用次数（越常用越可靠），$\gamma^{\Delta t}$ 是 recency decay。

### 10.3　Skill 的更新（防陈旧）

每个 skill 维护：

- `success_count`, `fail_count`
- `last_updated`
- `version`

触发更新条件：

- `fail_count / total > τ_fail`（失败率过高）→ 修订
- `last_updated > T_stale`（陈旧）→ 重新探索
- environment 变化检测 → 触发 Native-Evolution-style 重新蒸馏

## §11 Inference-Time Orchestration（如 ARIS）vs Training-Time Meta-Learning（如 Native Evolution）

> 顶级 lab 面试 L3 必问：把握 inference-time orchestration 和 training-time meta-learning 的根本数学区别。

### 11.1　数学 formulation 对比

| 维度 | Inference-Time Orchestration | Training-Time Meta-Learning |
|---|---|---|
| 优化对象 | system prompt $\mathcal{K}, \mathcal{S}$ | model params $\theta$ |
| 形式 | $\pi_{\theta}(\,\cdot\mid \mathcal{S}\oplus \text{ctx})$ | $\theta_{t+1} = \theta_t - \eta\,\nabla \mathcal{L}$ |
| 反馈来源 | 外部 verifier（cross-model）| outcome reward + RFT |
| 持久化形式 | markdown files on disk | 模型权重 |
| 测试时是否 update | 是（每次任务都可更新 file）| 否（参数 frozen）|
| 收敛 dynamics | 文档语言 diff，非梯度 | gradient flow |
| 理论工具 | bandit / online learning / sequential decision | RL theory, meta-learning theory |

### 11.2　各自局限

**Inference-time orchestration**：
- ❌ 不能内化 skill 进 weights → 每次需 load token
- ❌ Context 长度上限会成瓶颈
- ❌ 难以学习 low-level subtoken pattern
- ✅ 立刻可解释，可审计
- ✅ 不需要 GPU

**Training-time meta-learning**：
- ❌ 训练昂贵（rejection sampling × 2 iter, 600 task × 20 env）
- ❌ 一旦 train 完，进化能力固化
- ❌ 跨 environment 泛化仍是开问题
- ✅ 一次训练长期受益
- ✅ 行为可内化到 fast inference path

### 11.3　实际系统的混合形态

主流 production agent 往往是**两层都用**：

- **底层**：fine-tune 过 instruction follow + tool use（一次性训练）
- **上层**：inference-time 编排 skill / memory（持续 update）

这也是 ARIS 类型 system 的实际位置——上层 inference-time orchestration，下层依赖 GPT-4.5 / Claude Opus 等已经 trained-to-follow-skill 的 backbone。

## §12 失败模式与防御（必背）

### 12.1　Adversarial Collapse

**症状**：Challenger 越来越极端，Reasoner 学会的 skill 只对极端 case 有效，对正常 case 退化。

**Ctx2Skill 解法**：Cross-Time Replay 选 $\arg\max \rho^h \cdot \rho^e$，乘积形式强制保留 easy task 性能。

**通用解法**：

- 维护历史 probe set（不只看 current iteration）
- 选最 balanced 而非 last-iteration skill
- 用 KL penalty 防 skill set 单步剧变：$\mathcal{L}_\text{KL} = \beta \,D_\text{KL}(\mathcal{S}_i \| \mathcal{S}_{i-1})$（textual KL 可近似为 BLEU/edit distance）

### 12.2　Memory Drift

**症状**：long-horizon agent 把矛盾 / 过时信息累积进 K 或 memory，越用越糟。

**A²RD 解法**：
- HITS 在每个 segment 跟 retrieved context cross-check
- typed memory schema 强制 schema validation
- failure_db 单独存"已知不可信"trace

**通用解法**：

- 定期跑 self-consistency check：让 LLM 读自己 K 找内部矛盾
- 给每个 entry 加 confidence 衰减
- 触发"K 重蒸馏"机制（Native-Evolution-style）

### 12.3　Reward Hacking

**症状**：self-rewarding 训练（Yuan et al. 2024 Self-Rewarding LM）中，model 学到 game 自己的 reward function。

**防御**：

- **跨模型 reward**：让另一个 model family 当 verifier
- **outcome-grounded reward**：不让 LLM 给自己评分；用 code executor / math checker / labeled downstream task
- **reward dropout / regularization**：random subset of reward components

### 12.4　Bias Amplification（Echo Chamber）

**症状**：STaR-style rationalization 把 model 训练在自己生成的 rationale 上，扩大 mode collapse。

**[arXiv:2601.05280] 给出的 KL bound 直接对应这种情况** —— 无外源 grounding，KL 不降反升。

**防御**：
- 永远保留一部分 ground-truth supervision
- 用真实人类反馈 anchor
- diverse seed prompts 强制多模态

### 12.5　Sandbox Contamination

**症状**：agent 自己生成 test case → 自己 train on 这些 case → eval 上看上去很高但实际是 train-test 重叠。

**防御**：
- 严格 holdout set，agent 完全无 access
- benchmark 由 third-party 维护
- 多 round canonical eval（如 Ctx2Skill 用 CL-bench）

### 12.6　Capability Ceiling

**症状**：经过 N 轮 self-improvement 后曲线 saturate，无论多少 compute 都不再涨。

**Solver-Verifier Gap [arXiv:2507.00075] 的解释**：当 gap $\Delta \to 0$ 时 $\kappa \to 0$，improvement rate → 0。

**突破方式**：

- 引入更强的 verifier（如换 stronger model 当 judge）
- 增加 task 难度（Ctx2Skill 的 Challenger evolve）
- **symbolic 模型综合** ([arXiv:2601.05280] 提出的最后救命稻草)：让 LLM 同时维护一个 symbolic / programmatic model 防 drift

### 12.7　Hallucination Compounding（独立 reviewer 也可能共幻觉）

**症状**：跨模型 reviewer 都同意一个错误结论（如 Claude 写 + GPT 审，都漏掉同一个 bug）。

**防御**（briefing 中 codex round 2 也提过）：
- reviewer 一定要接 raw evidence / executable check（unit test, claim audit against raw experiment output）
- 不能只靠 LLM 的 textual judgment

## §13 25 高频面试题（L1 + L2 + L3）

### L1 必会 (Q1-Q10)

<details>

<summary>Q1. 什么是 self-evolving agent？与普通 LLM agent 有何区别？</summary>

普通 agent：固定 policy / prompt / skill，**所有 capability 来自 pretrain + 一次性 prompt engineering**。

Self-evolving agent：在使用过程中持续更新某一层（参数 / skill markdown / memory / workflow）的 capability。

关键：**不依赖每次都人工标注**——可能依赖外源 verifier，但不依赖 step-level 人标。代表作 Voyager, Reflexion, Ctx2Skill, Native Evolution。

</details>

<details>

<summary>Q2. 三大 self-evolution 范式是什么？各举一例。</summary>

按 Native Evolution 论文 §2 分类：

- **Experience-Driven**：人造任务 + reward，如 AgentTuning, ToolLLM。
- **Adversarial Self-Play**：challenger-solver，如 Absolute Zero (arXiv 2505.03335), Ctx2Skill (arXiv 2604.27660)。
- **Meta-Learning / Reward-Free**：训练时给 outcome reward，推理时无 task 无 reward，如 Native Evolution (arXiv 2604.18131)。

</details>

<details>

<summary>Q3. Voyager 的三件套是什么？为什么不更新 GPT-4 权重？</summary>

Voyager (Wang et al. NeurIPS 2023, NVIDIA + Caltech)：

- **Automatic Curriculum**：根据 inventory 自动出下一个 task
- **Skill Library**：每个 skill 是 JS function，按 description embedding 检索
- **Iterative Prompting + Self-Verification**：critic agent 验证，失败 revise

不更新 GPT-4 权重的原因：当时（2023）GPT-4 API 不开 fine-tune；且 Voyager 想证明 in-context skill 累积也能 evolve。但缺点是 token cost 高 + 不能内化 sub-token pattern。

</details>

<details>

<summary>Q4. Reflexion 与 RL 的关系？为什么叫"verbal RL"？</summary>

Reflexion (Shinn 2023 NeurIPS, Northeastern) 把 sparse reward 信号压成自然语言反思，存进 memory。

类比标准 RL：

- $r_t$ → "reflection text"（structured failure summary）
- $V(s_t)$ → 在 prompt 中检索到的 reflection
- policy improvement → 用 reflection 改后续 action

但**不更新 weights**——所以叫 verbal RL（用文本而非梯度做 credit assignment）。**不是真正 RL**，没有收敛 guarantee。

</details>

<details>

<summary>Q5. STaR 怎么 self-train？关键缺陷是什么？</summary>

STaR (Zelikman 2022 NeurIPS)：

1. LM 生成 (rationale, answer)
2. 答对 → 收集 (q, rationale, a)
3. 答错 → 给 ground truth, 让 LM 反向 rationalize
4. SFT on collected

**关键缺陷**：rationalization 是反推答案，rationale 可能并非真实推理过程；distribution drift。

[arXiv:2601.05280] 给出形式化批评：closed-loop training 无外源 grounding 会退化 KL。

</details>

<details>

<summary>Q6. Anthropic Skills 和 Native Evolution K 的关系？</summary>

两者都是**markdown 文件作为 system prompt 注入**。Native Evolution 论文 §3 footnote 1 显式引用 `github.com/anthropics/skills/tree/main/skills` 作为 K 的实现 reference。

区别：

- Anthropic Skills：人写，静态，任务级
- Native Evolution K：agent 自动 distill，动态，环境级

→ 趋同结论：**system prompt 是新的 model weights**。

</details>

<details>

<summary>Q7. 为什么 self-evolving 不一定意味着 update 模型参数？</summary>

绝大多数 2024-2026 work 不更新参数：

- Voyager: frozen GPT-4
- Reflexion: frozen base LM
- Generative Agents: frozen LM
- Ctx2Skill: frozen LM
- A²RD: training-free

原因：(1) 不需要 GPU，(2) 可解释 / 可审计，(3) skill 是 portable 的（可移植到其他 backbone），(4) 即时生效。

参数更新的代表（Native Evolution, AgentTuning）通常用于让 backbone 学会"如何利用 skill / K"，而 skill / K 本身仍是文件。

</details>

<details>

<summary>Q8. Reflexion 的 memory 和 RAG 的区别？</summary>

- RAG：检索的是**external knowledge documents**（如 wiki）
- Reflexion memory：检索的是 **agent 自己历史 trajectory 的反思**

后者强制要求 agent 反思自己的失败/成功 pattern，不只是 retrieve 别人写的事实。

工程上 Reflexion 也会做检索，只不过 doc 库是 self-generated。

</details>

<details>

<summary>Q9. self-play 训练为什么需要"learnability reward"？写一下公式。</summary>

Absolute Zero (arXiv 2505.03335) 提出 learnability reward：

$$R^\text{learn}(t) = \pi^\text{sol}_t(\text{correct}\mid t)\cdot \big(1 - \pi^\text{sol}_t(\text{correct}\mid t)\big)$$

最大化时 $\pi^\text{sol} = 0.5$——task 既不太简单（reward → 0）也不太难（reward → 0）。

**为什么需要**：若不约束，Challenger 会 explode 到极端任务（Solver 全错）→ 信号无用；这是 curriculum learning 的核心 trick。

</details>

<details>

<summary>Q10. 什么是 adversarial collapse？怎么防？</summary>

**症状**：多轮 self-play 后，Challenger 越来越极端、Solver 学 over-specialize 到极端 case、忘掉 base task。

**Ctx2Skill 解法**：Cross-Time Replay——维护 hard + easy probe set，选 $\arg\max_i \rho^h(i)\cdot \rho^e(i)$。乘积形式强制 easy task 不能塌。

**通用解法**：early stopping、replay buffer、显式 KL penalty。

</details>

### L2 进阶 (Q11-Q20)

<details>

<summary>Q11. 推导 Cross-Time Replay 为什么用乘积 ρ^h · ρ^e 而不是 ρ^h + ρ^e。</summary>

设候选 A 满足 $(\rho^h, \rho^e) = (0.8, 0.1)$，候选 B 满足 $(0.45, 0.45)$。

- 加法：A=0.9, B=0.9 → 不可分辨
- 乘法：A=0.08, B=0.2025 → 选 B

**为什么乘法更对**：A 在 easy 上几乎全错（catastrophic forgetting），但加法把它的 hard 表现拉成总分平。乘法对任何一边 → 0 都施加 catastrophic penalty——这就是反 over-specialization 的关键。

Ctx2Skill ablation 显示用 additive scoring（$\rho^h + \rho^e$）会让最终精度下降约 1-1.5 pts。

</details>

<details>

<summary>Q12. Native Evolution 的 outcome-based reward 为什么不能用 step-level？</summary>

R_evolve = Success(T_E | K) − Success(T_E | ∅)。

**Step-level reward 不可行**因为：

1. $\mathcal{K}$ 生成 trajectory ~374.8 步 × 3322.4 tokens/step，step-level signal 极度稀疏
2. 没有 ground truth 中间状态——每步对错很难判
3. step-level reward 鼓励 short-cut（生成"看起来勤奋"的 K 但下游无用）

outcome-based 用 downstream task pass rate 当 reward——直接、抗 hacking、与 K 真实价值挂钩。

</details>

<details>

<summary>Q13. Native Evolution 为什么用 RFT 而不是 GRPO？</summary>

(1) Trajectory horizon ~374 步——GRPO/PPO 反传无法在如此 long horizon 上稳定。
(2) Reward 评估要跑 auxiliary agent 在 downstream task 上——online 评估太贵。
(3) RFT (Rejection Sampling Fine-Tuning) 解耦 trajectory generation 与 policy update：先用 $\pi_t$ 生成 $C$ 个 trajectory → 按 reward 排序 → 选最优 trajectory 做 SFT → 下一个 iter。

→ offline、可并行、可控。代价：data efficiency 比 GRPO 低，需要更多 sample。

</details>

<details>

<summary>Q14. 推导 self-improvement 在无 grounding 下退化的 KL 论证。</summary>

设 $p^\star$ 是 target distribution，$p_t$ 是 model 在 iteration $t$ 的 distribution。

closed-loop self-training：用 $p_t$ 自己采样的 $x_t$（无 ground truth label）继续训练。

$$p_{t+1}(x) = \mathbb{E}_{x' \sim p_t}\big[\pi_\text{train}(x \mid x')\big]$$

若 $\pi_\text{train}$ 是 maximum likelihood 类训练，且无 external label 修正：

$$D_\text{KL}(p^\star \| p_{t+1}) \;\ge\; D_\text{KL}(p^\star \| p_t)$$

**直觉**：$p_t$ 已经 biased，按它采样训出来的 $p_{t+1}$ 只能保留或放大 bias。

若引入 grounding（外源 label $y$ 对应 $x$），训练目标变成 conditional $p(x | y)$ 修正：

$$D_\text{KL}(p^\star \| p_{t+1}) \;\le\; D_\text{KL}(p^\star \| p_t) - \Delta_\text{grounding}$$

其中 $\Delta_\text{grounding} > 0$ 量化外源信号带来的 KL 修正。

参考 [arXiv:2601.05280] §3。

> **注意**：这是简化版叙述（formal version 需对 $\pi_\text{train}$、$\pi_t$ 关系做技术性假设，参原文）。**面试可以引用 [arXiv:2601.05280]，但不要声称自己独立推出**。

</details>

<details>

<summary>Q15. 解释 solver-verifier gap 与 self-improvement 速率的关系。</summary>

设 capability $C(\theta_t)$ 按 [arXiv:2507.00075] 经验拟合服从指数律：

$$C(\theta_t) \approx C_\infty - (C_\infty - C_0)\, e^{-\kappa t}$$

定义 gap $\Delta := C^\text{ver} - C^\text{sol}$。论文中 $\kappa = \kappa(\Delta)$ 经验上**正相关**但**非单调**：

- $\Delta$ 过小 → verifier 与 solver 同质，无新信号 → $\kappa \approx 0$
- $\Delta$ 过大 → solver 学不到（feedback 过于复杂）→ $\kappa$ 反而下降

→ 最佳：**verifier 比 solver 强一档**（如 Claude executor + GPT-5.5 reviewer）。

**注意**：原文给出的是 **modeling + 经验拟合**，不是现成可移植定理；不要在面试或论文中 over-claim 为"已证明定理"。

</details>

<details>

<summary>Q16. A²RD 的 MVMem 与传统 vector memory 的区别？</summary>

Vector memory（如 MemGPT, LangChain memory）：

- 存 embedding + 原文 chunk
- 检索：cosine similarity
- 缺点：长程一致性（entity identity / spatial relation）容易丢

MVMem：

- 存**textual states**（Visual Arcs / Spatial Relations / Camera trajectories）+ frames + videos + dependency DAG
- 检索：MLLM-based retrieval（textual + image + 上下文综合）
- 优点：可显式 track entity identity，避免 character look 漂移

对 long-horizon agent 启示：**typed memory schema**（不是 free-form text）+ **dependency DAG** 决定生成顺序。

</details>

<details>

<summary>Q17. HITS 的 frame-level 与 video-level 有何不同？为什么要分层？</summary>

- **Frame-level HITS**：对单 frame 与 textual state cross-check（"该 frame 是否反映 entity X 的 identity"）
- **Video-level HITS**：对整段 video 与 narrative 一致性 check（"这段视频是否符合 story progression"）

分层原因：

- 单 frame 错误 → 在该 segment 局部修就行
- 跨 segment narrative 错误 → 必须更大尺度上检
- 类比：unit test vs integration test

迁移到通用 long-horizon agent：local artifact check + global workflow consistency check。

</details>

<details>

<summary>Q18. Generative Agents 的 memory retrieval 公式是什么？</summary>

$$\text{score}(m) = \alpha_\text{recency}\, r(m) + \alpha_\text{importance}\, i(m) + \alpha_\text{relevance}\, s(m, q)$$

其中：

- $r(m) = \gamma^{\Delta t}$ exponential decay
- $i(m) \in [1, 10]$，由 LLM 自评 importance
- $s(m, q)$ cosine similarity

Park 2023 UIST 设 $\gamma=0.995$/hour，$\alpha$ 均匀分配。

**面试加分**：importance 评分用 LLM 自评本身可能 hallucinate；现代 system 改用 cross-model 评分或 task-conditioned importance。

</details>

<details>

<summary>Q19. MemGPT 是怎么做"OS-style memory"的？为什么这思路启发了后续 work？</summary>

MemGPT (Packer 2023):

- Main context（fast, expensive）= "RAM"
- External archival（slow, cheap）= "HDD"
- LLM 函数调用 `pagein / pageout / summarize` 自主管理

启发：

- 让 LLM 看见自己的 context 状态（token usage、可见 vs 不可见）
- 让 LLM 自主决定 "now save this to disk" / "now load that"
- 这是 LLM agent 第一次实现**真正意义上的长期记忆主动管理**——不依赖 RAG 框架

后续 work：MemoryBank, MemChat, MVMem 都受其启发；ARIS-style research-wiki 也是同款思路（agent 自己决定写入 / 读取 wiki）。

</details>

<details>

<summary>Q20. 比较 Voyager（自由探索）和 Ctx2Skill（context-driven）的 skill discovery 哲学。</summary>

**Voyager**：在开放沙盒（Minecraft）里自动出 task → skill 是"如何 craft / kill"具体程序。
- skill 形态：JS code
- skill 触发：在做 task 时检索
- 缺乏外部 context

**Ctx2Skill**：给定 dense context $C$（可能是 100k+ token），提取该 context 的 procedure / rule。
- skill 形态：natural language markdown
- skill 触发：context 加载时直接 prepend
- 必须依赖 context

**核心区别**：Voyager 是**环境驱动**（skill = "在这个 world 怎么做事"），Ctx2Skill 是**context 驱动**（skill = "这份文档的 procedural knowledge"）。

Ctx2Skill 更适合**新 manual / new repo / new product doc** 场景；Voyager 更适合**新 environment exploration**。

</details>

### L3 顶级 lab (Q21-Q25)

<details>

<summary>Q21. 推 Ctx2Skill 5-role loop 收敛到 stable skill set 的充分条件（非平凡 setting）。</summary>

直接证明 5-role loop 收敛较难，但可以给出充分条件的叙述性论证：

设 $\mathcal{S}^R_i, \mathcal{S}^C_i$ 是 iteration $i$ 的两路 skill set。定义 capability：$C^R_i = \mathbb{E}_t[\rho^h(\mathcal{S}^R_i) \cdot \rho^e(\mathcal{S}^R_i)]$（with Cross-Time Replay metric）。

**充分条件**（直觉版）：

1. **Judge 可校准** (calibrated)：$\mathbb{E}[Judge(a, r)] = \mathbb{E}[\text{ground-truth}(a, r)]$。即 Judge 不漂移。
2. **Proposer 是 monotone improver**：每次 proposer 给出的 diagnosis 让 generator 写出的新 skill 在该 batch 上 strictly improving expected pass rate (with prob $\ge 1 - \delta$)。
3. **Probe set 平稳分布**：$\mathcal{Q}^h, \mathcal{Q}^e$ 经过 K 次更新后分布稳定（不再剧变）。
4. **Skill set 容量有上限**：$|\mathcal{S}^R| \le L$（防 unbounded growth）。

在 (1)-(4) 下，$\{C^R_i\}$ 是 **bounded + 几乎处处 monotone non-decreasing** 序列（在 prob $\ge 1-\delta$ 下 strict improving；上界由 Probe set 的 pass rate $\le 1$ 给出）。这种过程不严格是 supermartingale（supermartingale 是 $\mathbb{E}[C_{i+1}|\mathcal{F}_i] \le C_i$，方向相反），更准确的叙述是 **bounded monotone improvement 序列 / submartingale-like**——按经典 monotone convergence theorem 收敛到 $C^R_\infty \le 1$。

**注意**：这是叙述性 sketch；formal proof 需要构造合适概率空间、定义 $\sigma$-algebra、并细致处理 Judge 的 stochastic noise + monotone improvement 是高概率非确定性的 —— 属于 PhD-level theory 题，**不应在面试现场推满**，能讲清"为什么 bounded + monotone improvement 蕴含收敛"已足够。

</details>

<details>

<summary>Q22. 推 Native Evolution 在 reward-free phase 如何避免 policy 退化到 trivial behavior（information-theoretic 论证）。</summary>

设 $\pi^\star$ 是已 train 好的 Native Evolution policy。Evolution phase：

$$\mathcal{K}^\star = \arg\max_\mathcal{K} I(\mathcal{K}; E)$$

其中 $I(\mathcal{K}; E)$ 是 K 与 environment 的 mutual information。**直觉**：好的 K 是 E 的足够统计量。

退化 (trivial $\mathcal{K}$) 对应 $I(\mathcal{K}; E) \to 0$（$\mathcal{K}$ 与 E 独立、是无信息文本）。

**为什么训练时 outcome reward 防退化**：

$$R_\text{evolve}(\mathcal{K}) = \text{Success}(\mathcal{T}_E \mid \mathcal{K}) - \text{Success}(\mathcal{T}_E \mid \varnothing)$$

By data processing inequality：

$$I(\mathcal{K}; \mathcal{T}_E) \le I(\mathcal{K}; E)$$

且 $\text{Success}(\mathcal{T}_E \mid \mathcal{K})$ 单调依赖于 $I(\mathcal{K}; \mathcal{T}_E)$（K 提供越多 task-relevant info → success rate 越高）。

所以训练时 maximize $R_\text{evolve}$ → 隐式 maximize $I(\mathcal{K}; \mathcal{T}_E) \le I(\mathcal{K}; E)$ → 推 policy 远离 trivial K。

→ 推理时 policy 已经 internalize 了"如何产生 high-info K"的 instinct，所以无 reward 也能保持非 trivial 行为——但 **only on environments similar to training distribution**。

> ⚠️ **caveat** — 在 train distribution 之外（OOD environment），无 grounding 信号防退化，policy 可能仍然 fail。这是 Native Evolution 的 open problem 之一。

</details>

<details>

<summary>Q23. Self-improvement 在 reasoning-hard 任务上为什么会撞 capability ceiling？引用 [arXiv:2601.05280] dynamics argument。</summary>

reasoning-hard 任务（如 IMO problem, theorem proof）的特点：

1. ground truth 稀有，外源 grounding 信号几乎不可得
2. 中间推理步骤的对错很难自动判（无 cheap verifier）
3. self-rationalization（STaR-style）容易制造 plausible-but-wrong rationale

按 [arXiv:2601.05280] 的 dynamics argument：

$$D_\text{KL}(p^\star \| p_{t+1}) - D_\text{KL}(p^\star \| p_t) \;\ge\; -\Delta_\text{grounding}$$

reasoning-hard 任务 $\Delta_\text{grounding} \to 0$（无 verifier）→ KL 不降 → capability 不增。

**[arXiv:2601.05280] 的最终 implication**：要突破 reasoning hard 任务的 ceiling，需要 **symbolic model synthesis**——让 LLM 同时维护一个 programmatic / symbolic 模型作为 grounding anchor（如 Lean / Coq / Z3 verifier）。

这也解释了为什么 AlphaProof 等 work 必须挂 Lean 做 verifier 才能在 IMO 上突破——而单纯 LLM self-improvement on Olympiad 一直 saturate 在某个水平。

</details>

<details>

<summary>Q24. ARIS 这种 inference-time orchestration 与 Native Evolution 的 training-time meta-learning 在 mathematical formulation 上的根本区别？</summary>

**Training-time meta-learning (Native Evolution)**：

优化对象：model params $\theta$，目标 $\arg\max_\theta \mathbb{E}_E\, R_\text{evolve}(\mathcal{K}_\theta(E))$。

$\theta$ 由 gradient 决定，演化轨迹 in **continuous Euclidean space** ($\mathbb{R}^d$, $d$ 是参数数)。

理论工具：RL theory（policy gradient theorem）、meta-learning theory（MAML inner / outer loop）。

收敛通过传统 SGD 分析（Lipschitz, smoothness, variance bound）。

**Inference-time orchestration (ARIS-style)**：

优化对象：external state $\Sigma_t = (\mathcal{S}_t, \mathcal{K}_t, \text{workflow}_t)$，目标 $\arg\max_\Sigma \mathbb{E}_\tau\, U(\tau \mid \pi, \Sigma)$，其中 $\pi$ frozen。

$\Sigma$ 由文本 diff 决定，演化轨迹 in **combinatorial discrete space**（所有 markdown documents 的集合）。

理论工具：online learning（regret bound）、sequential decision making（bandit）、textual KL or edit-distance bound。

收敛分析需要新工具——传统 SGD 不适用。

**核心区别 list**：

| 维度 | training-time | inference-time |
|---|---|---|
| 状态空间 | $\mathbb{R}^d$ | text strings $\Sigma^\star$ |
| 更新算子 | gradient | LLM-generated edit |
| 持久化 | weights | markdown files |
| 测试时 update 频率 | 不 update | every task |
| 跨 backbone 移植 | 难 | 易（文件直接 copy）|
| 可解释性 | 低 | 高 |
| GPU 需求 | 高 | 低 |
| 理论工具 | RL theory | online / bandit / regret |

→ **二者其实是互补层**：底层用 training-time 让 backbone 学会 generic skill following，上层用 inference-time 编排具体 task。

> ⚠️ **常被混淆的 framing** — 不要把 ARIS 说成 "reward-free self-evolution"——它是 **inference-time, non-parametric, system-level adaptation**，与 Native Evolution 的 training-time meta-learning 是不同 mathematical regime。这是 cross-paper 阅读的 sanity check。

</details>

<details>

<summary>Q25. 假如让你设计 2026 下半年的下一代 self-evolving agent benchmark，你会注意什么？</summary>

**问题观察**：

- GAIA / WebVoyager 已饱和 (90%+)
- TRACE (2510.00415) 让 agent 自演化 benchmark，避免 saturation
- Ctx2Skill 用 CL-bench（500 contexts × 1899 tasks × 31607 rubrics）
- Native Evolution 用 WebVoyager / WebWalker subset (1427 queries)

**应注意的 design principle**：

1. **Holdout 严格**：3rd-party 维护，agent 在训练中看不到 test environment
2. **Capability 分层**：基础能力（reading / tool use）+ 长程能力（multi-step reasoning, memory）+ self-evolution capability（adapt to new env）分开打分
3. **Cost-aware**：每 task 计成本（API tokens / GPU hours），不允许"用 100K tokens 答 1 个问题"刷分
4. **Cross-Time 评估**：取多个时间点 snapshot，看 model 在 long-term 是否 collapse / drift
5. **Adversarial held-in / held-out 切换**：train env 演化能力 ≠ test env 演化能力
6. **可解释 audit trail**：每个答案附 reasoning trace，供 reviewer audit
7. **多模型 reviewer**：avoid same-model hallucination consensus
8. **Capability ceiling 探测**：刻意构造需要 symbolic verifier 的任务（IMO-style），看 self-improvement 在 reasoning-hard 上多远会撞墙
9. **Negative transfer 检测**：测 skill from env A 是否伤害 env B
10. **Knowledge transferability**：可移植性测试——A 训出 K，B 模型用 K，看 boost 是否成立

→ Native Evolution 论文已在 Cross-Model World Knowledge Transfer (Figure 3) 体现 (10) 这点：Seed-36B 训出的 K 加到 Qwen3-14B 上能 +18.3%。

**Bonus**：可以做 "self-evolution dashboard" 量化 capability dynamics（取 [arXiv:2507.00075] 的指数律）：

$$C(t) = C_\infty - (C_\infty - C_0) e^{-\kappa t}$$

拟合 $\hat\kappa$ 作 model 的 self-evolution rate metric——比 final accuracy 更 informative。

</details>

## §A 附录：完整 from-scratch 代码骨架

### A.1　Skill library 完整实现

```python
import json, time, math
from dataclasses import dataclass, field, asdict
from typing import Callable, Optional


@dataclass
class Skill:
    """Markdown skill with metadata for retrieval + lifecycle."""
    name: str
    trigger: str            # when-to-use 段
    body: str               # 真正 system-prompt 注入的 markdown
    exact_triggers: list = field(default_factory=list)
    success_count: int = 0
    fail_count: int = 0
    last_updated: float = field(default_factory=time.time)
    version: int = 1
    embedding: list = field(default_factory=list)


class SkillLibrary:
    """Skill 持久化、检索、生命周期管理."""

    def __init__(self):
        self.skills: dict[str, Skill] = {}
        self.callbacks_on_update: list[Callable] = []

    def add(self, s: Skill) -> None:
        self.skills[s.name] = s

    def retrieve(self, query: str, embed_fn, k: int = 3) -> list[Skill]:
        """Hybrid retrieval: keyword + dense + recency."""
        q_emb = embed_fn(query)
        scored = []
        now = time.time()
        for name, s in self.skills.items():
            sim = self._cos(s.embedding, q_emb) if s.embedding else 0.0
            prior = math.log(1 + s.success_count)
            recency = math.pow(0.999, max(0, (now - s.last_updated) / 3600))
            kw_hit = 1.0 if any(t.lower() in query.lower()
                                for t in s.exact_triggers) else 0.0
            score = 0.5 * sim + 0.2 * prior + 0.2 * recency + 0.1 * kw_hit
            scored.append((score, s))
        scored.sort(reverse=True, key=lambda x: x[0])
        return [s for _, s in scored[:k]]

    @staticmethod
    def _cos(a: list, b: list) -> float:
        if not a or not b: return 0.0
        dot = sum(x * y for x, y in zip(a, b))
        na = math.sqrt(sum(x * x for x in a))
        nb = math.sqrt(sum(y * y for y in b))
        return dot / (na * nb + 1e-9) if na > 0 and nb > 0 else 0.0

    def update_outcome(self, skill_name: str, success: bool) -> None:
        s = self.skills[skill_name]
        if success: s.success_count += 1
        else:       s.fail_count    += 1

    def should_revise(self, skill_name: str,
                      tau_fail: float = 0.5,
                      t_stale: float = 7 * 24 * 3600) -> bool:
        s = self.skills[skill_name]
        total = s.success_count + s.fail_count
        if total > 0 and s.fail_count / total > tau_fail:
            return True
        if time.time() - s.last_updated > t_stale:
            return True
        return False

    def revise(self, skill_name: str, new_body: str) -> None:
        s = self.skills[skill_name]
        s.body = new_body
        s.last_updated = time.time()
        s.version += 1
        s.success_count = 0
        s.fail_count = 0
        for cb in self.callbacks_on_update:
            cb(s)

    def serialize(self) -> str:
        return json.dumps({n: asdict(s) for n, s in self.skills.items()})

    def assemble_prompt(self, skills: list[Skill]) -> str:
        return "\n\n".join([f"# {s.name}\n{s.body}" for s in skills])
```

### A.2　Reflexion memory 完整实现

```python
@dataclass
class Reflection:
    trajectory_summary: str
    failure_root_cause: str
    fix_strategy: str
    timestamp: float


class ReflexionMemory:
    """verbal-RL style memory."""

    def __init__(self, max_entries: int = 50):
        self.entries: list[Reflection] = []
        self.max_entries = max_entries

    def add(self, traj: str, llm: Callable) -> None:
        """让 LLM 自己生成 reflection."""
        prompt = (
            f"Trajectory: {traj}\n\n"
            f"Task FAILED. Write a short reflection in JSON with keys: "
            f"trajectory_summary, failure_root_cause, fix_strategy."
        )
        raw = llm(prompt)
        try:
            obj = json.loads(raw)
        except Exception:
            obj = {"trajectory_summary": traj[:400],
                   "failure_root_cause": "parse_failed",
                   "fix_strategy": raw[:400]}
        self.entries.append(Reflection(
            trajectory_summary=obj["trajectory_summary"],
            failure_root_cause=obj["failure_root_cause"],
            fix_strategy=obj["fix_strategy"],
            timestamp=time.time(),
        ))
        # 保留最近 max_entries 条
        if len(self.entries) > self.max_entries:
            self.entries = self.entries[-self.max_entries:]

    def render(self) -> str:
        """渲染成 prefix prompt."""
        return "\n".join([
            f"[Reflection {i}] cause: {r.failure_root_cause}\n"
            f"           fix: {r.fix_strategy}"
            for i, r in enumerate(self.entries[-5:])
        ])
```

### A.3　Sanity check 输出（伪示）

```
[a] SkillLibrary.add + retrieve            ✓ topk = ['voyager_craft', 'minecraft_kill']
[b] update_outcome 累积 success_count       ✓ s.success_count = 3
[c] should_revise 触发条件 (fail rate)       ✓ tau_fail=0.5 → True
[d] revise 后 version += 1                  ✓ s.version: 1 → 2
[e] Reflexion.add 解析 LLM JSON            ✓ len(entries) = 1
[f] Reflexion render 取最近 5 条            ✓ render len = 154 chars
[g] hybrid retrieval 中 keyword_hit 权重    ✓ keyword > dense when exact match
[h] cross-time replay arg max(rho_h * rho_e)✓ best_idx = 2 (out of 5)
[i] Native Evolution outcome reward 计算   ✓ R_evolve = 0.18 (≥ 0)
```

代码经独立 reviewer 静态检查，逻辑通过 dataclass / 类型注解约束。

---

> ✅ **总结** — 2026 的 self-evolving agent 不是 magic，而是**三个核心范式（Experience / Adversarial / Meta-Learning）+ 三个核心载体（params / skills / K）+ 三个核心防御（Cross-Time Replay / typed memory + DAG / cross-model grounding）的组合工程**。理论上界由 [arXiv:2601.05280] 与 [arXiv:2507.00075] 给出——**外源 grounding 信号决定上限**。
>
> 面试时记住一句话：**self-evolution is not the singularity; it is the engineering of grounded, sustained capability growth under finite supervision**.
