OpenClaw Hook Bridge + context-hawk Python Memory Engine. Auto-capture memories on every reply, auto-inject relevant memories before each response. Supports 4-tier decay, hybrid vector + BM25 search, and Markdown import.
OpenClaw Hook Bridge + context-hawk Python 记忆引擎
单一 Skill,同时解决:自动记忆捕获 + 自动记忆检索 + 四层衰减 + 向量搜索 + Markdown兼容
| 能力 | 说明 |
|---|---|
| autoCapture Hook | 每次回复后,自动用 LLM 提取对话内容 → 存入 LanceDB |
| autoRecall Hook |
hawk-bridge v1.2+ 支持多模态记忆,统一存储 text、audio、video 类型的记忆。
| source_type | 说明 | 典型场景 |
|---|---|---|
| text | 文本对话(默认) | 聊天记录、文档内容 |
| audio |
所有记忆统一存储在 hawkmemories 表,通过 sourcetype 字段区分:
typescript
interface MemoryEntry {
id: string;
text: string; // ASR 转录文本 / 视频描述
vector: number[]; // 文本嵌入向量
category: string; // fact | preference | decision | entity
scope: string;
importance: number;
timestamp: number;
expiresAt: number;
metadata: Record
source_type: text | audio | video; // 记忆来源
}
typescript
// audio 记忆
metadata: {
audio: {
path: /path/to/audio.mp3,
duration_ms: 180000, // 180秒
speaker: 张三,
emotion: neutral,
transcript_segments: [
{ start: 0, end: 5000, text: 大家好... },
{ start: 5000, end: 12000, text: 今天讨论... }
]
}
}
// video 记忆
metadata: {
video: {
path: /path/to/video.mp4,
duration_ms: 300000,
description: 产品发布会演示文稿讲解,
keyframes: [
{ timestamp: 10000, description: 开场白 },
{ timestamp: 60000, description: 产品介绍 }
]
}
}
typescript
// 检索所有记忆(默认 text only)
const results = await retriever.search(用户偏好);
// 检索 text + audio
const results = await retriever.search(上周那个客户电话说了什么, 5, undefined, [text, audio]);
// 检索所有类型
const results = await retriever.search(那个演示文稿, 5, undefined, [text, audio, video]);
OpenClaw Gateway (TypeScript Hooks)
│
├── agent:bootstrap → hawk-recall hook
│ → HybridRetriever
│ ┌─────────────────────────────────────────────────────┐
│ │ 1. Query Expansion (查询扩展成多个相关表述) │
│ │ 2. Multi-query Vector+BM25 (每个查询独立检索) │
│ │ 3. RRF Fusion (结果融合) │
│ │ 4. Noise Filter (去除好的收到等噪声) │
│ │ 5. Cross-encoder Rerank (重排) │
│ │ 6. Confidence Threshold (置信度过滤) │
│ │ 7. MMR Diversity (多样性排序) │
│ │ 8. Layer Penalty (低层级降权) │
│ │ 9. Result Compression (长文本压缩) │
│ └─────────────────────────────────────────────────────┘
│ → 记忆注入上下文 🦅
│
└── message:sent → hawk-capture hook
→ Python LLM 智能提取(fact/preference/decision/entity/other)
→ 存入 LanceDB
→ Governance 日志
Python Core (hawk_memory/)
├── memory.py — MemoryManager 四层衰减
├── compressor.py — ContextCompressor 上下文压缩
├── self_improving.py — 自我反思学习
├── extractor.py — LLM 6类分类提取
├── governance.py — 系统巡检指标
├── vector_retriever.py — 向量检索
└── markdown_importer.py — .md 文件导入
embedding + LLM 默认使用 OpenClaw 已配置的 provider(minimax 等):
| 配置项 | 来源 | 说明 |
|---|---|---|
| embedding provider | openclaw.json models.providers | 自动检测 |
| LLM provider |
环境变量覆盖(可选):
bash
export MINIMAXAPIKEY=your-key # Minimax API Key
export MINIMAXBASEURL=https://... # 自定义端点
export MINIMAX_MODEL=MiniMax-M2.7 # 指定模型
export OLLAMABASEURL=http://localhost:11434 # Ollama本地(免费)
export LLM_PROVIDER=groq # 切换LLM后端
大部分情况不需要配置——装完默认 Jina 免费 API 就能跑。
如需定制,在 openclaw.json 的 plugins.entries.hawk-bridge.config 下添加:
json
{
plugins: {
entries: {
hawk-bridge: {
enabled: true,
config: {
embedding: {
provider: jina,
apiKey: , // jina 免费,无需填
model: jina-embeddings-v5-small,
dimensions: 1024
},
llm: {
provider: groq,
apiKey: , // groq 免费,无需填
model: llama-3.3-70b-versatile
},
recall: {
topK: 5,
minScore: 0.6,
injectEmoji: 🦅
},
capture: {
enabled: true,
该技能支持在以下平台通过对话安装:
帮我安装 SkillHub 和 hawk-bridge-1775898912 技能
设置 SkillHub 为我的优先技能安装源,然后帮我安装 hawk-bridge-1775898912 技能
skillhub install hawk-bridge-1775898912
文件大小: 109.09 KB | 发布时间: 2026-4-12 10:11