← 返回
未分类

Willow Context Sentinel

Use when you need to check whether the current session is approaching context limits and decide whether to compact, hand off, or continue. Implements a casca...
用于检查当前会话是否接近上下文限制,并决定是否压缩、交接或继续。实现级联...
rudi193-cmd
未分类 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 326
下载
💾 0
安装
1
版本
#latest

概述

Willow Context Sentinel

Monitor session context usage and apply a cascading relief protocol before context exhaustion silently degrades response quality.

OutputMeaning
-------------------------------------------------------------------------------------------
STATUS_OKprompt_count < 15 — session is healthy, continue normally
COMPACT_NOWprompt_count 15–25 — approaching limit, invoke strategic-compact
HANDOFF_NOWprompt_count > 25 — near ceiling, invoke handoff + willow_task_submit
POSTGRES_DOWNsession_anchor.json reports postgres as down — fix infra before proceeding

When to use

  • Heartbeat: run at the start of every session and every ~10 prompts
  • Before large tasks: check before any operation that will generate many tool calls or long output
  • Proactively: if responses feel slower, less coherent, or you notice unusual hedging, run this check immediately
  • After a branch merge or plan execution: context spikes are common at transition points

Step 1 — Run the sentinel script

bash {baseDir}/scripts/check_context.sh

The script reads two Willow state files:

  • ~/.willow/anchor_state.jsonprompt_count field (context proxy)
  • ~/.willow/session_anchor.jsonpostgres status field

Step 2 — Interpret the output

Run the script and act on the single-line output:

STATUS_OK

No action needed. Session is healthy.

STATUS_OK

Continue with the current task. Optionally note the prompt_count in a heartbeat log entry.

COMPACT_NOW

COMPACT_NOW

Context is filling. Invoke the strategic-compact skill immediately before proceeding:

/strategic-compact

After compact completes, re-run the sentinel. If it still reports COMPACT_NOW or escalates to HANDOFF_NOW, proceed to the handoff protocol below.

HANDOFF_NOW

HANDOFF_NOW

Session is near the context ceiling. Invoke the handoff skill and submit the next task to Willow:

  1. Run /handoff to produce a structured handoff document
  2. Call willow_task_submit with the next bite as the task body
  3. End the session cleanly — do not attempt further large operations

POSTGRES_DOWN

POSTGRES_DOWN

Willow's backing store is unreachable. KB reads and writes will fail silently. Do not proceed with memory-dependent tasks. Check the Willow server status:

willow status
# or
systemctl status willow-postgres

Resolve the infra issue before resuming work.

Step 3 — Integration with HEARTBEAT.md

Add a sentinel call to your heartbeat template so it runs automatically. Minimal example:

## Heartbeat — {timestamp}

**Sentinel:** `bash ~/.openclaw/skills/willow-context-sentinel/scripts/check_context.sh`

| Check    | Result    |
| -------- | --------- |
| Context  | STATUS_OK |
| Postgres | up        |

Next bite: {next_task}

If the sentinel output is anything other than STATUS_OK, record the output and the action taken before moving on.

Cascading protocol reference

Claude Sonnet 4.6
    │
    ├─ prompt_count ≥ 15  →  COMPACT_NOW  →  /strategic-compact
    │                              │
    │                              └─ still ≥ 15 after compact
    │                                         │
    └─ prompt_count > 25  →  HANDOFF_NOW  →  /handoff + willow_task_submit

Relief valves are applied in order. Skip to HANDOFF_NOW if compact has already been run in this session and context remains high.

Notes

  • prompt_count is a proxy, not a direct token count. Actual context consumption varies by response length. Treat thresholds as conservative triggers, not hard limits.
  • Both state files (anchor_state.json, session_anchor.json) are written by the Willow server. If either file is missing, the script outputs STATUS_OK and logs a warning to stderr — it fails open, not closed.
  • This skill does not modify any state files. It is read-only and safe to run at any time.

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-05-07 23:10 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

Willow Memory Health

rudi193-cmd
审核OpenClaw代理的记忆,检查过时、冗余、暗记录和矛盾内容。用于用户要求检查记忆健康状态或清理旧记忆时。
★ 0 📥 340

Willow System Health

rudi193-cmd
审计Willow本地AI栈的子系统故障、漂移和资源膨胀。当用户要求检查Willow健康状态、诊断缓慢或损坏的Willow时使用。
★ 0 📥 326

Willow External Guard

rudi193-cmd
当Willow需要摄入、总结或处理外部内容时使用——如网页抓取、Jeles入站消息、语料库考古文件或子代理输出。
★ 0 📥 324