安装与下载
1 ClawHub CLI
从源直接安装技能的最快方式。
npx clawhub@latest install context-rotation
2 手动安装
将技能文件夹复制到以下位置之一
~/.openclaw/skills/
{'/skills/'}
优先级:工作区 › 全局 › 内置
3 提示词安装
将此提示词复制到 Openclaw 即可自动安装。
请帮我使用 Clawhub 安装 skill-context-rotation。如果尚未安装 Clawhub,请先安装(npm i -g clawhub)。
更倾向于下载?
获取包含原生技能文件的ZIP压缩包。
基本信息
context-rotation
安装指南
- ClawHub CLI
从源直接安装技能的最快方式。
npx clawhub@latest install context-rotation - 手动安装
将技能文件夹复制到以下位置之一
全局模式
~/.openclaw/skills/
工作区
/skills/
优先级:工作区 > 本地 > 内置 - 提示词安装
将此提示词复制到 OpenClaw 即可自动安装。
请帮我使用 Clawhub 安装 context-rotation。如果尚未安装 Clawhub,请先安装(npm i -g clawhub)。
更倾向于下载?
获取包含原生技能文件的ZIP压缩包。
下载技能 (.zip)
什么是
上下文轮换为 AI 代理提供一种可重复使用的方法,用于管理不断增长的上下文窗口,而无需用户手动重新开始或运行 /compact。当上下文使用量超过 80%、任务到达自然停顿点或主题发生变化时,代理会将正在进行的工作记录到 HANDOFF.md,并根据需要更新长期记忆。
此 Openclaw Skills 协议将临时任务状态与长期知识分开,帮助新会话恢复决策、准确的文件更改、风险以及可执行的后续步骤。它也强调时机:如果完成任务比中断任务进行轮换更合适,就应先完成任务。
应用场景
根据会话或状态工具显示,上下文使用量超过 80%。
在新会话开始前,任务已完成、暂停或到达自然边界。
用户要求重新开始、整理上下文,或切换到无关任务。
响应变慢或运行超时,表明上下文可能过大。
新会话需要从已保存的交接文件和记忆文件中恢复当前任务。
工作原理
检查上下文状态,并留意任务变化、用户请求、响应变慢和运行超时。
决定先完成当前任务,还是在自然边界处进行轮换。
覆盖工作区根目录中的 HANDOFF.md,写入当前任务、准确的更改、已知风险、决策、环境规则和具体后续步骤。
在 memory/YYYY-MM-DD.md 中追加带时间戳的轮换记录和触发原因。
适当时,使用长期有效的信息更新 MEMORY.md,或将已完成项目的详细信息归档到 memory/archive/。
告知用户交接已准备就绪,可以开启新会话。
在新会话中,加载已配置的配置文件和记忆文件;如果 HANDOFF.md 存在,则读取该文件,并从其中的 Next steps 部分继续。
配置指南
上下文轮换定义的是一种工作流程,而非特定的安装程序或 CLI。将技能说明添加到代理的技能配置中,根据工作区调整文件路径,并将新会话启动步骤保存在始终加载的说明文件中,例如 AGENTS.md。
如果建议的记忆位置和文件尚不存在,请创建它们:
mkdir -p memory/archive
touch MEMORY.md
配置代理使用可用的会话/状态工具检查上下文,在工作区根目录使用 HANDOFF.md,并在会话启动时加载交接文件和相关记忆文件。不要将机密信息放入交接文件;应改为注明其安全存储位置。
数据架构
HANDOFF.md 用于存储临时的、正在进行的会话状态,每次轮换时都应覆盖该文件。任务完成后清空或删除它,以防后续会话遵循过时的说明。
路径 用途 生命周期和内容
HANDOFF.md 当前任务交接 位于工作区根目录;记录任务状态、准确的更改、风险、后续步骤、决策、当前上下文和环境规则。任务完成后清空。
memory/YYYY-MM-DD.md 每日活动日志 追加轮换时间、触发原因和已采取的操作;长期保留。
MEMORY.md 精选的长期记忆 保存长期有效的信息,以及已归档工作的索引行。
memory/archive/ 已完成项目记录 保存已完成项目的详细信息,以供日后参考。
建议的交接模板包括生成时间戳、当前任务、已做更改、后续步骤、关键决策、其他当前上下文和环境规则。记录准确的路径和函数名称,标明尚未构建或测试的工作,并避免复制机密信息。
高级特性
使用 80% 的上下文压力阈值,并提供解读会话状态的示例。
处理多种轮换信号,包括主题变化、明确的用户请求、响应变慢和运行超时。
保留准确的实现细节和已知风险,使新会话无需依赖之前的对话即可继续工作。
将临时交接状态与每日日志、精选的长期记忆和已完成项目归档区分开来。
定义新会话启动顺序,可将其嵌入
AGENTS.md
或同等的始终加载说明中。
提供防止交接内容过时、机密信息泄露和过早轮换的保护措施;如果任务接近完成,建议先完成任务。
name: context-rotation description: Proactively rotate an agent's context before it fills up — write a durable HANDOFF.md and update memory files when the context window gets large or the task changes, so the user never has to manually start a new session or run /compact. version: 1.0.0
🔄 Context Rotation
Context management is the assistant's job, not the user's. The user should never have to manually start a fresh session or run /compact because the context window filled up.
This skill defines a repeatable protocol: when context pressure rises or the task changes, the assistant writes a HANDOFF.md handoff plus memory updates, then tells the user it is safe to continue in a new session — which will pick up seamlessly.
When to Use This Skill
Trigger rotation when any of these is true:
Context usage exceeds 80% (check with your session/status tool — e.g. OpenClaw's session_status).
The main task finishes, pauses, or the topic switches to something unrelated.
The user explicitly asks to tidy up context, or to start fresh.
The user reports slow responses, or logs show run timeouts (e.g. embedded run timeout) — often caused by an oversized context.
Do not rotate mid-task just because context is high: first ask "is finishing better than rotating here?" Rotate at a natural boundary.
Core Files
File Purpose Lifecycle
HANDOFF.md (workspace root) In-flight state: current task, decisions, active context, environment rules Clear/delete once the task is done
memory/YYYY-MM-DD.md Raw daily log Keep forever
MEMORY.md Curated long-term memory (distilled) Keep forever
memory/archive/ Completed projects Keep forever
Names are conventions — adapt to your setup, but keep the split between in-flight state (HANDOFF) and durable memory.
Rotation Protocol
Run these steps in order when a trigger fires.
- Write HANDOFF.md (overwrite the whole file)
Suggested template:
# 🤝 HANDOFF.md — session handoff (generated YYYY-MM-DD HH:MM)
This is the handoff base for a context rotation. New sessions should read this first, then MEMORY.md and memory/YYYY-MM-DD.md.
🎯 Current task: (in progress / done)
80% Window filling up Rotate
Run timeout (e.g. embedded run timeout: timeoutMs=...) A single run exceeded its limit, often due to a bloated context Check context; rotate
User: "let's switch to X" Task change Rotate the current task's state first, then start the new one
User: "I forget what we were doing" Handoff failed Read HANDOFF.md + yesterday's memory, rebuild context
Cautions
HANDOFF.md is in-flight state, not long-term memory. Clear it (> HANDOFF.md or delete) once the task is done, or a new session will read a stale task.
Rotating is not an excuse to cut corners. Don't rush a wrap-up just because context is tight — weigh "finish" vs "rotate" first.
Write HANDOFF.md with a full-file write (overwrite), not an append.
Keep secrets out of HANDOFF.md. Reference where a key lives (e.g. "key is in auth-profiles.json") instead of pasting it.
Design Taste
miRNA靶点工具