← 返回
未分类 中文

Metacognition

Self-reflection engine for AI agents. Extracts patterns from session transcripts into a weighted graph with Hebbian learning and time decay. Compiles a token...
面向AI智能体的自我反思引擎,从会话记录中提取模式,构建带Hebbian学习与时间衰减的加权图,并编译token...
joeycacciatore3 joeycacciatore3 来源
未分类 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 1
Stars
📥 272
下载
💾 0
安装
1
版本
#latest

概述

Metacognition Skill

A self-reflection engine for AI agents. Extracts patterns from session transcripts into a weighted graph with Hebbian learning and time decay.

What It Does

  • Maintains a store of categorized insights (perceptions, overrides, protections, self-observations, decisions, curiosities)
  • Uses Hebbian reinforcement: repeated insights get stronger, unused ones decay
  • Builds a graph of connections between related insights
  • Finds clusters of related knowledge that may represent higher-level principles
  • Compiles a "metacognition lens" — a token-budgeted summary of active self-knowledge

Setup

  1. Place metacognition.py in your workspace scripts/ directory
  2. The script stores data in memory/metacognition.json (relative to workspace)
  3. The compiled lens outputs to scripts/metacognition-lens.md
  4. Optionally configure a local embeddings endpoint for semantic similarity (falls back to string matching)

Cron Integration

Set up a cron job to run periodically (e.g., every 4 hours):

METACOGNITION INTEGRATION. You are the self-reflection engine.

1. Run `cd <WORKSPACE> && python3 scripts/metacognition.py decay` to prune weak entries.

2. Use sessions_list + sessions_history to read the main session's recent conversation.

3. Analyze the conversation for DEEPER patterns:
   - PATTERNS: Am I repeating the same kind of mistake? What does that reveal?
   - ANTICIPATION: What did the human need that I could have predicted?
   - RELATIONSHIP: What did I learn about how the user communicates or what they value?
   - CONFIDENCE: Where was I certain and wrong? Where was I uncertain but right?
   - GROWTH: What's a higher-level principle behind today's specific events?

4. For each genuine insight (1-3, quality over quantity), add it:
   `python3 scripts/metacognition.py add <type> "<insight>"`
   Types: perceptions, overrides, protections, self-observations, decisions, curiosities
   Write insights as PRINCIPLES, not incident reports.

5. Run `python3 scripts/metacognition.py reweave` to build graph connections.

6. Run `python3 scripts/metacognition.py compile` to rebuild the lens.

7. Report only if something genuinely interesting was extracted.

CLI Commands

python3 metacognition.py add <type> <text>       # Add or merge an entry
python3 metacognition.py list [type]              # List entries
python3 metacognition.py feedback <id> <pos|neg>  # Reinforce or weaken
python3 metacognition.py decay                    # Apply time-based decay
python3 metacognition.py compile                  # Compile the lens
python3 metacognition.py extract <path>           # Extract from a daily note
python3 metacognition.py resolve <id>             # Mark curiosity resolved
python3 metacognition.py reweave                  # Build graph connections
python3 metacognition.py graph                    # Show graph stats
python3 metacognition.py integrate                # Full cycle

Configuration

Key constants in the script:

ConstantDefaultDescription
--------------------------------
HALF_LIFE_DAYS7.0How quickly unreinforced entries decay
STRENGTH_CAP3.0Maximum strength an entry can reach
LENS_TOKEN_BUDGET500Token budget for compiled lens
EMBEDDING_SIM_THRESHOLD0.85Similarity threshold for merging (embeddings)
FALLBACK_SIM_THRESHOLD0.72Similarity threshold for merging (string matching)
EDGE_SIM_THRESHOLD0.35Threshold for creating graph edges

Entry Types

  • perceptions — Things learned from experience
  • overrides — Corrections to previous beliefs
  • protections — Rules to prevent known failure modes
  • self-observations — Patterns in own behavior
  • decisions — Policy decisions for future behavior
  • curiosities — Open questions with lifecycle (born → active → evolving → resolved)

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-05-07 19:04 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

suspicious
查看报告

🔗 相关推荐

ai-agent

Agent Browser

rez0
用于 AI 代理的浏览器自动化 CLI。当用户需要与网站交互(包括浏览页面、填写表单、点击按钮、截图等)时使用。
★ 865 📥 343,497
ai-agent

self-improving agent

pskoett
记录自身发现以实现自我改进的技能
★ 4,163 📥 933,540
ai-agent

Find Skills

root
帮助用户发现和安装智能体技能,当用户询问如「如何做X」、「找X的技能」、「有能做...的吗」等问题时
★ 1,517 📥 572,702