🤖
Context Budgeting
Manage and optimize OpenClaw context window usage via partitioning, pre-compression checkpointing, and information lifecycle management. Use when the session context is near its limit (>80%), when the agent experiences "memory loss" after compaction, or when aiming to reduce token costs and latency for long-running tasks.
安全通过
💬Prompt
技能说明
name: context-budgeting description: Manage and optimize OpenClaw context window usage via partitioning, pre-compression checkpointing, and information lifecycle management. Use when the session context is near its limit (>80%), when the agent experiences "memory loss" after compaction, or when aiming to reduce token costs and latency for long-running tasks.
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:
- Generate Checkpoint: Update
memory/hot/HOT_MEMORY.mdwith:- Status: Current task progress.
- Key Decision: Significant choices made.
- Next Step: Immediate action required.
- Run Automation: Execute
scripts/gc_and_checkpoint.shto trigger the physical cleanup.
Automation Tool: gc_and_checkpoint.sh
Located at: skills/context-budgeting/scripts/gc_and_checkpoint.sh
Usage:
- Run this script after updating
HOT_MEMORY.mdto finalize the compaction process without restarting the session.
Integration with Heartbeat
Heartbeat (every 30m) acts as the Garbage Collector (GC):
- Check
/status. If Context > 80%, trigger the Checkpointing procedure. - Clear raw data (e.g., multi-megabyte JSON outputs) once the summary is extracted.
如何使用「Context Budgeting」?
- 打开小龙虾AI(Web 或 iOS App)
- 点击上方「立即使用」按钮,或在对话框中输入任务描述
- 小龙虾AI 会自动匹配并调用「Context Budgeting」技能完成任务
- 结果即时呈现,支持继续对话优化