Context Budgeting Skill
This skill provides a systematic framework for managing the finite context window (RAM) of an OpenClaw agent.
Core Concepts
1. Information Partitioning
- - Objective/Goal (10%): Core task instructions and active constraints.
- Short-term History (40%): Recent 5-10 turns of raw dialogue.
- Decision Logs (20%): Summarized outcomes of past steps ("Tried X, failed because Y").
- Background/Knowledge (20%): High-relevance snippets from MEMORY.md.
2. Pre-compression Checkpointing (Mandatory)
Before any compaction (manual or automatic), the agent MUST:
- 1. Generate Checkpoint: Update
memory/hot/HOT_MEMORY.md with:
-
Status: Current task progress.
-
Key Decision: Significant choices made.
-
Next Step: Immediate action required.
- 2. Run Automation: Execute
scripts/gc_and_checkpoint.sh to trigger the physical cleanup.
Automation Tool: gc_and_checkpoint.sh
Located at: INLINECODE3
Usage:
- - Run this script after updating
HOT_MEMORY.md to finalize the compaction process without restarting the session.
Integration with Heartbeat
Heartbeat (every 30m) acts as the Garbage Collector (GC):
- 1. Check
/status. If Context > 80%, trigger the Checkpointing procedure. - Clear raw data (e.g., multi-megabyte JSON outputs) once the summary is extracted.
上下文预算技能
本技能提供了一套系统化框架,用于管理OpenClaw代理的有限上下文窗口(RAM)。
核心概念
1. 信息分区
- - 目标/意图(10%):核心任务指令和有效约束条件。
- 短期历史记录(40%):最近5-10轮原始对话内容。
- 决策日志(20%):过往步骤的总结性结果(尝试了X,因Y失败)。
- 背景/知识(20%):来自MEMORY.md的高相关性片段。
2. 预压缩检查点(强制要求)
在进行任何压缩操作(手动或自动)前,代理必须:
- 1. 生成检查点:更新memory/hot/HOT_MEMORY.md,包含:
-
状态:当前任务进度。
-
关键决策:已做出的重要选择。
-
下一步:需要立即执行的操作。
- 2. 运行自动化脚本:执行scripts/gcandcheckpoint.sh以触发物理清理。
自动化工具:gcandcheckpoint.sh
位于:skills/context-budgeting/scripts/gc
andcheckpoint.sh
使用方法:
- - 在更新HOT_MEMORY.md后运行此脚本,无需重启会话即可完成压缩流程。
与心跳机制的集成
心跳机制(每30分钟)充当垃圾回收器(GC):
- 1. 检查/status。若上下文使用率超过80%,则触发检查点流程。
- 提取摘要后,清除原始数据(例如数兆字节的JSON输出)。