Context Sentinel
/install context-sentinel
Context Sentinel
This skill provides a script to automate the "Cascading Model Protocol," ensuring the agent gracefully degrades from high-cost models to high-context models as the session grows.
Protocol Summary
- Opus 4.6: Use until 80% context, then switch to Opus 4.5.
- Opus 4.5: Use until 80% context, then switch to Gemini 2.5 Pro.
- Gemini Pro: Use until 80% context, then trigger a handoff.
This skill operationalizes the logic defined in MEMORY.md.
How to Use
This skill is designed to be run periodically, either via a cron job or as part of the main agent's HEARTBEAT.md checklist.
Workflow
-
Execute the script: Run the
check_context.ps1script to get the current session status and determine the required action.powershell -File scripts/check_context.ps1 -
Evaluate the output: The script will return one of three possible string commands:
SWITCH_TO:\x3Cmodel_id>HANDOFF_NOWSTATUS_OK
-
Take Action: Based on the output, execute the appropriate agent command.
-
If
SWITCH_TO:\x3Cmodel_id>, runsession_statuswith the new model ID:session_status model=\x3Cmodel_id> -
If
HANDOFF_NOW, trigger the handoff process by writing to the handoff file. This is typically done by running a specific, pre-defined prompt or script. -
If
STATUS_OK, no action is needed.
-
Example Usage in HEARTBEAT.md
You can replace the manual checks in your HEARTBEAT.md with a call to this skill's script.
Old HEARTBEAT.md:
## Cascading Model Protocol (Check Every Heartbeat)
1. **Check Status:** Get current model and context %.
2. **Opus 4.6:** If model is `Opus 4.6` and context > 80% -> Switch to `Opus 4.5`.
...
New HEARTBEAT.md using this skill:
## Context Sentinel (Check Every Heartbeat)
1. Run `powershell -File skills/context-sentinel/scripts/check_context.ps1`.
2. Evaluate the output and take action (`SWITCH_TO`, `HANDOFF_NOW`, or `STATUS_OK`).
This makes the logic reusable and keeps the HEARTBEAT.md file clean and focused on execution.
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install context-sentinel - 安装完成后,直接呼叫该 Skill 的名称或使用
/context-sentinel触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
Context Sentinel 是什么?
Monitors session context and automatically manages model switching based on a cascading protocol. Use as part of a heartbeat or cron job to maintain session health and optimize token usage. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 1309 次。
如何安装 Context Sentinel?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install context-sentinel」即可一键安装,无需额外配置。
Context Sentinel 是免费的吗?
是的,Context Sentinel 完全免费(开源免费),可自由下载、安装和使用。
Context Sentinel 支持哪些平台?
Context Sentinel 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 Context Sentinel?
由 Nietzsche247(@nietzsche247)开发并维护,当前版本 v1.0.0。