← 返回
AI智能 中文

Instruction Anchor Guard

Preserve user-critical instructions across long sessions and context compaction. Use when users mark constraints as important/must/always/never/highest-prior...
在长时间会话和上下文压缩中保留关键用户指令。用户标记约束为重要/必须/始终/永不/最高优先级时使用。
dalomeve
AI智能 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 545
下载
💾 9
安装
1
版本
#latest

概述

---

name: instruction-anchor-guard

version: 1.1.0

description: Preserve user-critical instructions across long sessions and context compaction. Use when users mark constraints as important/must/always/never/highest-priority/rules, and enforce anchor checks before and after compaction to prevent plan drift.

metadata:

openclaw:

emoji: "[ANCHOR]"

category: resilience


Instruction Anchor Guard

Prevent loss or drift of user-critical constraints during compaction, session restart, or long multi-turn tasks.

When To Trigger

Trigger when any of these appear:

  • User marks an instruction as important, critical, must, always, never, highest priority, rule, or constraint
  • A task has more than 3 steps and spans multiple turns
  • Compaction happened (or is likely) and the task has non-negotiable requirements
  • Agent behavior shows possible drift from prior explicit user constraints

Anchor Ledger Schema

Store anchors in first available path:

  1. memory/anchors.md
  2. memory/instruction-anchors.md
  3. .anchors.md (workspace root fallback only)

Entry schema (append-only, one section per anchor):

## Anchor: <id>
- **source**: <session-id|message-id|user>
- **instruction**: <canonical instruction text>
- **verbatim**: <short quote from user>
- **priority**: P0 | P1 | P2
- **scope**: global | session | task:<id> | channel:<id>
- **createdAt**: <ISO-8601 timestamp>
- **expiresAt**: <ISO-8601 timestamp or "never">
- **status**: active | paused | expired | superseded
- **signature**: <stable hash of canonical instruction>
- **supersedes**: <anchor-id or none>

Workflow

1) Capture

  • Parse latest user message for candidate anchor statements
  • Keep only instruction/constraint content; remove examples/chatter
  • Assign default values:
  • priority: P1 (unless user says critical/highest -> P0)
  • scope: session (unless user explicitly asks global/task scope)
  • expiresAt: session end (unless user explicitly sets never/date)

2) Confirm for Broad Anchors

  • If scope is global or priority is P0, ask a one-line confirmation before persisting
  • Do not auto-promote P2/P1 to P0 without explicit user intent

3) Persist

  • Append anchor entry to ledger
  • If new anchor conflicts with old same-scope anchor, mark old one superseded
  • Never rewrite history silently; keep audit trail

4) Rehydrate (each turn and after compaction)

  • Load active anchors (status=active and not expired)
  • Build an in-memory ANCHOR_SET sorted by priority and recency
  • Inject ANCHOR_SET into planning phase before tool execution

5) Drift Check (before final answer and before destructive actions)

  • Compare current plan against active anchors
  • On conflict:
  • P0 conflict: stop and correct plan immediately
  • P1 conflict: auto-correct and note adjustment
  • P2 conflict: continue only if no user-level contradiction
  • Emit DRIFT_CHECK block in response

Conflict Resolution

Priority order:

  1. System and safety policy
  2. User anchors (P0 > P1 > P2)
  3. Current-turn temporary preferences

Tie-breakers:

  • More specific scope wins (task > session > global) if same priority
  • Newer anchor wins if same priority and same scope
  • Explicit user override wins only when safety is not violated

Output Template

When anchors exist, include this compact block:

ANCHORS_ACTIVE
| ID | P | Scope | Expires | Instruction |
|----|---|-------|---------|-------------|
| anchor-001 | P0 | global | never | Never perform destructive data deletion without confirmation |

PLAN_GUARD
- Current action: <action>
- Conflicts: none | <anchor ids>
- Decision: clear | corrected | paused-awaiting-user

DRIFT_CHECK
- Last anchor sync: <timestamp>
- Drift: no | yes
- Fix applied: <none|what changed>

Safety Boundaries

  • Never store tokens, API keys, passwords, cookies, or auth headers
  • Never store raw personal data unless strictly required by user instruction
  • Redact sensitive literals as [REDACTED]
  • Store constraints, not datasets
  • Do not execute destructive commands solely because an anchor exists; still require explicit confirmation for destructive actions

Expiry and Maintenance

  • Mark expired when expiresAt < now
  • Support control intents:
  • /anchors list
  • /anchors pause
  • /anchors resume
  • /anchors delete
  • /anchors pin never
  • Rotate ledger when > 200 entries into memory/anchors-archive-YYYY-MM.md

Integration Notes

  • Pair with memory-self-heal for retry/fallback after drift correction
  • Pair with task-execution-guard to enforce anchor checks at each milestone
  • Keep this skill deterministic and concise; avoid free-form interpretation when conflict exists

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-03-30 06:52 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

data-analysis

Ui Design Optimizer

dalomeve
利用本地样式、色彩和排版数据集,生成实用的UI设计系统及起始页面。适用于落地页或仪表盘UI的规划与实现。
★ 0 📥 1,165
ai-intelligence

ontology

oswalpalash
类型化知识图谱,用于结构化智能体记忆与可组合技能。支持创建/查询实体(人员、项目、任务、事件、文档)及关联...
★ 712 📥 243,802
ai-intelligence

Proactive Agent

halthelobster
将AI智能体从任务执行者升级为主动预判需求、持续优化的智能伙伴。集成WAL协议、工作缓冲区、自主定时任务及实战验证模式。Hal Stack核心组件 🦞
★ 836 📥 213,107