介绍
# Penfield Memory
能够复合增长的持久化记忆。你的智能体能够记住对话、学习偏好、连接想法,并完全从中断处继续——跨会话、跨天数、跨渠道。
## 工具
### 记忆
| 工具 | 用途 | 使用时机 | |------|---------|-------------| | `penfield_store` | 保存记忆 | 用户分享偏好、你有了新发现、做出决定、学到值得保留的内容时 | | `penfield_recall` | 混合搜索(BM25 + 向量 + 图) | 在响应前需要上下文、恢复话题、查找先前决策时 | | `penfield_search` | 语义搜索(更高的向量权重) | 在没有确切术语时进行模糊概念搜索 | | `penfield_fetch` | 按 ID 获取记忆 | 跟进召回结果中的特定记忆时 | | `penfield_update_memory` | 编辑现有记忆 | 进行更正、补充细节、更改重要性或标签时 |
### 知识图谱
| 工具 | 用途 | 使用时机 | |------|---------|-------------| | `penfield_connect` | 连接两个记忆 | 新信息与现有知识相关,随时间建立理解时 | | `penfield_explore` | 从某个记忆遍历图谱 | 理解想法如何连接,查找相关上下文时 |
### 上下文与分析
| 工具 | 用途 | 使用时机 | |------|---------|-------------| | `penfield_save_context` | 检查点保存会话 | 结束实质性工作,准备交接给另一个智能体时 | | `penfield_restore_context` | 从检查点恢复 | 你或另一个智能体接手继续工作时 | | `penfield_list_contexts` | 列出已保存的检查点 | 查找以前的会话以恢复时 | | `penfield_reflect` | 分析记忆模式 | 会话开始时的定位,查找主题,发现空白点时 |
### 制品
| 工具 | 用途 | 使用时机 | |------|---------|-------------| | `penfield_save_artifact` | 存储文件 | 保存图表、笔记、代码、参考文档时 | | `penfield_retrieve_artifact` | 获取文件 | 加载以前保存的工作时 | | `penfield_list_artifacts` | 列出存储的文件 | 浏览已保存的制品时 | | `penfield_delete_artifact` | 删除文件 | 清理过时的制品时 |
## 撰写真正有效的记忆
记忆内容的质量决定了 Penfield 是有用还是无用。关键在于具体性和上下文。
**糟糕——模糊、无上下文、以后无法找到:** ``` "User likes Python" ```
**优秀——具体、有上下文、可检索:** ``` "[Preferences] User prefers Python over JavaScript for backend work. Reason: frustrated by JS callback patterns and lack of type safety. Values type hints and explicit error handling. Uses FastAPI for APIs." ```
**是什么让记忆可被找到:**
1. **括号中的上下文前缀**:`[Preferences]`、`[Project: API Redesign]`、`[Investigation: Payment Bug]`、`[Decision]` 2. **“为什么”背后的“是什么”**——理由比事实本身更重要 3. **具体细节**——名称、数字、日期、版本,而不是模糊的总结 4. **对相关记忆的引用**——“这建立在 [关于 X 的早期发现] 之上”或“与 Y 的先前假设相矛盾”
## 记忆类型
使用正确的类型。系统使用这些类型进行过滤和分析。
| 类型 | 用于 | 示例 | |------|---------|---------| | `fact` | 已验证的、持久的信息 | “用户的公司在 AWS EKS 上运行 Kubernetes” | | `insight` | 模式或领悟 | “部署失败与周五发布相关” | | `correction` | 修正先前的理解 | “更正:超时不是 Redis 导致的——它是硬编码的批处理限制” | | `conversation` | 会话摘要、值得注意的交流 | “讨论了迁移策略。用户倾向于增量方法” | | `reference` | 源材料、引用 | “RFC 8628 定义了输入受限设备上 OAuth 的设备代码流” | | `task` | 工作项、行动项 | “待办:在索引重建后基准测试召回延迟” | | `strategy` | 方法、方案、计划 | “对于用户的代码库:总是先检查 types.ts,它是事实来源” | | `checkpoint` | 里程碑状态 | “项目进度 80%——认证完成,UI 待定” | | `identity_core` | 不可变的身份事实 | 通过个性配置设置,很少手动存储 | | `personality_trait` | 行为模式 | 通过个性配置设置,很少手动存储 | | `relationship` | 实体连接 | “用户与 Chad Schultz 合作网络安全内容” |
## 重要性评分
使用全范围。并非所有内容都是 0.5。
| 评分 | 含义 | 示例 | |-------|---------|---------| | 0.9–1.0 | 关键——永远不要忘记 | 架构决策、来之不易的更正、核心偏好 | | 0.7–0.8 | 重要——经常引用 | 项目上下文、关于用户工作的关键事实 | | 0.5–0.6 | 正常——有用的上下文 | 一般偏好、会话摘要 | | 0.3–0.4 | 次要——背景细节 | 外围事实、低风险的观察 | | 0.1–0.2 | 琐碎——可能不要存储 | 如果你怀疑是否应该存储它,那就不要存 |
## 连接记忆
连接是 Penfield 强大的关键。孤立的记忆只是一个笔记。连接的记忆才是理解。
**存储记忆后,始终问自己:** 这与什么相关?然后将其连接起来。
### 关系类型(24 种)
**知识演变:** `supersedes` · `updates` · `evolution_of` 当理解发生变化时使用。“我们以为是 X,现在我们知道是 Y。”
**证据:** `supports` · `contradicts` · `disputes` 当新信息验证或挑战现有信念时使用。
**层级:** `parent_of` · `child_of` · `sibling_of` · `composed_of` · `part_of` 用于结构关系。包含子主题的主题,包含组件的系统。
**因果:** `causes` · `influenced_by` · `prerequisite_for` 用于因果链和依赖关系。
**实现:** `implements` · `documents` · `tests` · `example_of` 当某事物演示、描述或验证另一事物时使用。
**对话:** `responds_to` · `references` · `inspired_by` 用于归因和对话线程。
**顺序:** `follows` · `precedes` 用于过程或时间线中的有序步骤。
**依赖:** `depends_on` 当一事物需要另一事物时使用。
## 召回策略
好的查询能找到东西。糟糕的查询只会返回噪音。
**根据查询类型调整搜索权重:**
| 查询类型 | bm25_weight | vector_weight | graph_weight | |-----------|-------------|---------------|--------------| | 精确术语查找(例如 “Twilio auth token”) | 0.6 | 0.3 | 0.1 | | 概念搜索(例如 “how we handle errors”) | 0.2 | 0.6 | 0.2 | | 关联知识(例如 “everything about payments”) | 0.2 | 0.3 | 0.5 | | 默认(平衡) | 0.4 | 0.4 | 0.2 |
**激进地过滤:** - `memory_types: ["correction", "insight"]` 以查找发现和更正 - `importance_threshold: 0.7` 以跳过噪音 - `enable_graph_expansion: true` 以跟随连接(默认设置,通常保持开启)
## 工作流
### 用户分享偏好
``` penfield_store({ content: "[Preferences] User wants responses under 3 paragraphs unless complexity demands more. Dislikes bullet points in casual conversation.", memory_type: "fact", importance: 0.8, tags: ["preferences", "communication"] }) ```
### 调查跟踪
``` // Start penfield_store({ content: "[Investigation: Deployment Failures] Reports of 500 errors after every Friday deploy. Checking release pipeline, config drift, and traffic patterns.", memory_type: "task", importance: 0.7, tags: ["investigation", "deployment"] })
// Discovery — connect to the investigation discovery = penfield_store({ content: "[Investigation: Deployment Failures] INSIGHT: Friday deploys coincide with weekly batch job at 17:00 UTC. Both compete for DB connection pool. Not a deploy issue — it's resource contention.", memory_type: "insight", importance: 0.9, tags: ["investigation", "deployment", "root-cause"] }) penfield_connect({ from_memory_id: discovery.id, to_memory_id: initial_report.id, relationship_type: "responds_to" })
// Correction — supersede wrong assumption correction = penfield_store({ content: "[Investigation: Deployment Failures] CORRECTION: Not a CI/CD problem. Friday batch job + deploy = connection pool exhaustion. Fix: stagger batch job to 03:00 UTC.", memory_type: "correction", importance: 0.9, tags: ["investigation", "deployment", "correction"] }) penfield_connect({ from_memory_id: correction.id, to_memory_id: initial_report.id, relationship_type: "supersedes" }) ```
### 会话交接
``` penfield_save_context({ name: "deployment-investigation-2026-02", description: "Investigated deployment timeout issues. memory_id: " + discovery.id, memory_ids: [discovery.id, correction.id, initial_report.id] }) ```
下一次会话或不同的智能体:
``` penfield_restore_context({ name: "deployment-investigation-2026-02" }) ```
## 什么不要存储
- 逐字逐句的对话记录(太冗长,信号低) - 容易通过谷歌搜索到的事实(改为使用网络搜索) - 短暂的任务状态(使用工作记忆) - 任何用户未同意存储的关于他们自己的信息 - 每一次微小的交流(要有选择性——质量重于数量)
## 标签
保持简短、一致、小写。每个记忆 2-5 个。
好:`preferences`、`architecture`、`investigation`、`correction`、`project-name` 坏:`2026-02-02`、`important-memory-about-deployment`、`UserPreferencesForCommunicationStyle`
## 也可在 OpenClaw 之外使用
原生 OpenClaw 插件是最快的途径,但 Penfield 可在任何地方的任何 AI 工具中工作:
**Claude Connectors**
```json Name: Penfield Remote MCP server URL: https://mcp.penfield.app ```
**Claude Code** ``` Claude mcp add --transport http --scope user penfield https://mcp.penfield.app ```
**MCP 服务器**——适用于 Gemini CLI、Cursor、Windsurf、Intent、Perplexity Desktop 或任何 MCP 兼容的工具:
```json { "mcpServers": { "penfield": { "command": "npx", "args": [ "mcp-remote@latest", "https://mcp.penfield.app/" ] } } } ```
**API**——位于 `api.penfield.app` 的直接 HTTP 访问,用于自定义集成。
相同的记忆、相同的知识图谱、相同的账户。插件速度快 4-5 倍(无 MCP 代理层),但无论你如何连接,所有内容都会保持同步。
## 链接
- 插件:[openclaw-penfield on npm](https://www.npmjs.com/package/openclaw-penfield) - 源码:[github.com/penfieldlabs/openclaw-penfield](https://github.com/penfieldlabs/openclaw-penfield) - 注册:[portal.penfield.app/sign-up](https://portal.penfield.app/sign-up) - 网站:[penfield.app](https://penfield.app) - X:[@penfieldlabs](https://x.com/penfieldlabs)