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
- 1. 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
- 1. Execute the script:
Run the
check_context.ps1 script to get the current session status and determine the required action.
CODEBLOCK0
- 2. Evaluate the output:
The script will return one of three possible string commands:
*
SWITCH_TO:<model_id>
*
HANDOFF_NOW
* INLINECODE6
- 3. Take Action:
Based on the output, execute the appropriate agent command.
* If SWITCH_TO:<model_id>, run session_status with the new model ID:
CODEBLOCK1
* 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:
CODEBLOCK2
New HEARTBEAT.md using this skill:
CODEBLOCK3
This makes the logic reusable and keeps the HEARTBEAT.md file clean and focused on execution.
上下文哨兵
本技能提供自动化“级联模型协议”的脚本,确保代理在会话增长过程中从高成本模型优雅降级至高上下文模型。
协议概要
- 1. Opus 4.6: 使用至上下文占用80%,然后切换至Opus 4.5。
- Opus 4.5: 使用至上下文占用80%,然后切换至Gemini 2.5 Pro。
- Gemini Pro: 使用至上下文占用80%,然后触发交接。
本技能将MEMORY.md中定义的逻辑付诸实施。
使用方法
本技能设计为定期运行,可通过cron任务或作为主代理HEARTBEAT.md检查清单的一部分执行。
工作流程
- 1. 执行脚本:
运行check_context.ps1脚本以获取当前会话状态并确定所需操作。
powershell
powershell -File scripts/check_context.ps1
- 2. 评估输出:
脚本将返回以下三种可能的字符串命令之一:
* SWITCH
TO:id>
* HANDOFF_NOW
* STATUS_OK
- 3. 执行操作:
根据输出结果,执行相应的代理命令。
* 如果是SWITCHTO:id>,使用新的模型ID运行session_status:
sessionstatus model=id>
* 如果是HANDOFF_NOW,通过写入交接文件触发交接流程。通常通过运行特定的预定义提示或脚本完成。
* 如果是STATUS_OK,则无需任何操作。
在HEARTBEAT.md中的使用示例
您可以将HEARTBEAT.md中的手动检查替换为调用本技能的脚本。
旧的HEARTBEAT.md:
markdown
级联模型协议(每次心跳检查)
- 1. 检查状态: 获取当前模型和上下文占用百分比。
- Opus 4.6: 如果模型为Opus 4.6且上下文占用 > 80% -> 切换至Opus 4.5。
...
使用本技能后的新HEARTBEAT.md:
markdown
上下文哨兵(每次心跳检查)
- 1. 运行powershell -File skills/context-sentinel/scripts/checkcontext.ps1。
- 评估输出并执行操作(SWITCH
TO、HANDOFF
NOW或STATUSOK)。
这使得逻辑可复用,并保持HEARTBEAT.md文件简洁且专注于执行。