Files
nexus/wiki/concepts/交接协议.md
2026-04-23 04:02:48 +08:00

2.3 KiB
Raw Blame History

title, type, tags, sources, last_updated
title type tags sources last_updated
交接协议Handoff Protocol concept
openclaw
memory
model-switch
agentic-ai
养龙虾5天血泪史
2026-04-23

Definition

交接协议是 AI Agent 在模型切换或会话结束时,将当前上下文状态写入每日日志的规程。解决 OpenClaw Agent 切换模型时丢失所有上下文的核心问题。

The Problem

OpenClaw Agent 在切换模型时丢失所有上下文:

  • 新模型以新鲜上下文窗口开始
  • 只看到自动加载的文件
  • 当前会话状态、进行中的任务、待处理决定全部丢失

"切换模型后Agent 表现得像我们从未交谈过。我提到两天前的讨论决定,它一脸茫然。"

Solution

在任何模型切换或会话结束前执行交接:

# Handoff Protocol

## Current Session State
- Current task: [task description]
- Progress: [X% complete]
- Pending decisions: [list]
- Next steps: [action items]

## What Worked
- [insight 1]
- [insight 2]

## What Didn't Work
- [failed approach 1]
- [failed approach 2]

Implementation

在 AGENTS.md 顶部添加交接指令

# Handoff Protocol (必须执行)
Before any model switch or session end:
1. Write current task state to memory/YYYY-MM-DD.md
2. Include: progress, pending decisions, next steps
3. Note what worked and what didn't
4. This is non-negotiable — DO NOT skip

触发时机

  • /model 命令切换模型
  • /exit/quit 结束会话
  • 长时间无响应后的新会话
  • 主动要求交接时

Key Insight

"交接协议是模型切换的修复"

没有交接协议,新模型不知道发生了什么。有了交接协议,新模型从每日日志读取当前状态,无缝继续工作。

与上下文刷新的关系

  • 上下文刷新Memory Flush防止单次压缩周期内的信息丢失
  • 交接协议:防止模型切换时的信息丢失

两者互补,共同确保长期会话的信息完整性。

Connections