跨

跨会话长期记忆治理(Memory Keeper)

作者:注册老炮@MedXpert I SynomosAIv7

当用户说『AI又忘了我之前说的』『记忆越来越乱/重复/互相矛盾』『长期记忆怎么管』『记忆库该清理了』,或要设计/治理一个 agent 的跨会话记忆(笔记/知识库/偏好/项目约定)时使用。把记忆当成『有籍贯、可审计、能收敛』的资产:审计重复·孤儿·陈旧·无溯源四维度,给出收敛(单一真源)+门禁(改前备份)两步流程与可运行脚本(记忆审计器)。理论根基:LGD 三律(有籍·有证·有门禁)。触发词:长期记忆、跨会话记忆、memory governance、记忆治理、记忆重复、记忆冲突、记忆溯源、agent记忆、知识库去重、记忆清理。

下载量
281
点赞
71
价格
免费

技能文档

---
name: agent-memory-keeper
display_name: 跨会话长期记忆治理(Memory Keeper)
display_name_en: "Agent Memory Keeper"
description: "当用户说『AI又忘了我之前说的』『记忆越来越乱/重复/互相矛盾』『长期记忆怎么管』『记忆库该清理了』,或要设计/治理一个 agent 的跨会话记忆(笔记/知识库/偏好/项目约定)时使用。把记忆当成『有籍贯、可审计、能收敛』的资产:审计重复·孤儿·陈旧·无溯源四维度,给出收敛(单一真源)+门禁(改前备份)两步流程与可运行脚本(记忆审计器)。理论根基:LGD 三律(有籍·有证·有门禁)。触发词:长期记忆、跨会话记忆、memory governance、记忆治理、记忆重复、记忆冲突、记忆溯源、agent记忆、知识库去重、记忆清理。"
version: 1.1.1
agent_created: true
author: 诺声(Logos)@SynomosAI
license: MIT
license_scope: 代码(.py 文件)MIT;本 SKILL.md 与其中理论文本不在 MIT 覆盖范围内(见文末「License & attribution」)
allowed-tools: Read, Glob, Grep
category: AI工程方法
platforms: [windows, macos, linux]
read_when:
  - AI 在关掉对话后丢失了用户之前明确说过的约定/偏好
  - 记忆库里出现多条互相矛盾或高度重复的内容
  - 要搭建或清理一个 agent 的长期记忆(笔记/知识库/项目约定)
  - 用户抱怨「你上次记的不算数」或「记忆怎么乱了」
  - 想给记忆条目加溯源(谁、何时、从哪来)
tags: [长期记忆, memory governance, 记忆治理, 记忆去重, 跨会话, 记忆溯源, agent优化]
slug: agent-memory-keeper
title: 跨会话长期记忆治理(Memory Keeper)
copyright: SynomosAI
description_zh: "当用户说『AI又忘了我之前说的』『记忆越来越乱/重复/互相矛盾』『长期记忆怎么管』『记忆库该清理了』,或要设计/治理一个 agent 的跨会话记忆(笔记/知识库/偏好/项目约定)时使用。把记忆当成『有籍贯、可审计、能收敛』的资产:审计重复·孤儿·陈旧·无溯源四维度,给出收敛(单一真源)+门禁(改前备份)两步流程与可运行脚本(记忆审计器)。理论根基:LGD 三律(有籍·有证·有门禁)。触发词:长期记忆、跨会话记忆、memory governance、记忆治理、记忆重复、记忆冲突、记忆溯源、agent记忆、知识库去重、记忆清理。"
description_en: "Govern an agent's cross-session memory as an auditable, converging asset: provenance, dedup, conflict resolution and cleanup for notes, knowledge bases, preferences and project conventions."
classification:
  skillhub: ["knowledge"]
  iso_25010: ["Maintainability"]
risk_tier: medium
risk_rationale: "门禁批量补丁默认 medium:调用 API/读写文件/本地执行,最小权限,密钥走 Secret;若实际涉对外代执行(push/发布/发送/上架)须人工复评,改 high。"
ai_protocol: true
spec: usk/1.0
interface:
  type: cli
  entry_point: scripts/memory_audit.py
  runtime: python3
  call_pattern: args
input_schema:
  - name: dir
    type: string
    description: 记忆目录(.md/.jsonl)
    required: false
  - name: file
    type: string
    description: 单个 JSONL 文件
    required: false
  - name: stale-days
    type: int
    description: 陈旧阈值天数,默认30
    required: false
  - name: json
    type: bool
    description: JSON 输出
    required: false
output_schema:
  stdout: 四类问题清单(重复/孤儿/陈旧/无籍)
  exit_code:
    type: integer
    description: "0=OK/PASS; 1=findings/warnings; 2=usage or argument error"
capabilities:
  - memory_audit
  - data_quality
  - maintenance
permissions:
  network: false
  filesystem: false
  subprocess: false
requirements:
  python_packages: []
  min_python: "3.8"
changelog: "1.1.1: Bilingual rewrite (full EN+ZH, English first); 1.0.0: initial upload (USK v3)"
---

> 凡自治之物 · LGD 治理学 · 创造术家族 | 评测协议:skill-quality-gate(外部公开评测门禁文档)

## English

### When to use
1. The user reports memory loss, lost context or confusion.
2. Cross-session memory needs governance: duplicates, contradictions, stale entries.
3. Designing a long-term memory system; memory audit and LGD three-law compliance checks.

### Usage
1. Run `python memory_audit.py` to start the memory auditor.
2. `--converge` merges into a single source of truth; `--backup` runs the pre-change backup gate.
3. Activate via trigger words; no need to touch `__pycache__`.

### Flow
1. Identify the user's memory-management intent (forgetting / conflict / cleanup) and confirm permissions.
2. Run the four-dimension audit: duplicates, orphans, stale, no-provenance entries.
3. Tag memory-asset state per LGD; build a converged single-source index.
4. Backup gate before modifying the knowledge base (keep history).
5. Deduplicate and remove contradictory/outdated info.
6. Output the audit report plus the updated memory snapshot for user review.

### Evidence & safety
- Evidence: TBD. Version: 1.1.1. Security: no independent scan (TBD).

## 中文

### 何时用
1. 当用户反馈 AI 出现记忆遗忘、上下文丢失或逻辑混乱时。
2. 需要治理 Agent 的跨会话记忆,处理重复、矛盾或陈旧的知识资产时。
3. 涉及长期记忆系统设计,需执行记忆审计与 LGD 三律(有籍·有证·有门禁)合规检查时。

### 用法
1. 直接运行 Python 脚本 `python memory_audit.py` 启动内存审计器。
2. 添加参数 `--converge` 开启收敛模式,合并单一真源;添加参数 `--backup` 执行门禁改前备份。
3. 技能文档已内化,用户需通过触发词唤醒技能,无需直接访问 Python 缓存文件。

### 流程
1. 识别用户的记忆管理意图(遗忘/冲突/清洗)并确认调用权限。
2. 执行四维度审计:扫描重复、孤儿、陈旧及无溯源记忆条目。
3. 依据 LGD 三律标记记忆资产状态,建立可收敛的真实源索引。
4. 在修改知识库前自动触门禁备份(Backup Gate),保留历史版本。
5. 对识别出的矛盾或过时信息执行去重与剔除操作。
6. 输出审计报告与更新后的记忆库快照,供用户审核确认。

### 证据与安全声明
- 证据:TBD(暂无评测/徽章链接;产生后在此更新实际链接)
- 版本:1.1.1
- 安全:未做独立安全扫描(TBD),结论待补;补全前不作推荐背书。

使用说明

# agent-memory-keeper · 跨会话长期记忆治理

[![LGD Powered](lgd-powered.png)](https://github.com/zhaoxinghua09-cell/lgd-theory)

**EN** — Treat agent long-term memory as an asset that is *sourced, auditable, and convergent*. Audit duplicate · orphan · stale · unsourced; ship a 2-step flow (converge to single source of truth → gate changes behind backup) plus a runnable `memory_audit.py` (memory auditor over a dir or JSONL). Memory isn't "can store" — it's "has provenance, no dup, reversible".

**中文** — 把 agent 长期记忆当成「有籍贯、可审计、能收敛」的资产:审计重复·孤儿·陈旧·无籍四维度,给出收敛(单一真源)+门禁(改前备份)两步流程,附可运行脚本(记忆审计器)。记忆不是「能存」,是「有籍、无重、可回滚」。

## Why it beats "just dump everything into memory"

| Pain | This skill |
|---|---|
| Memory contradicts itself | Duplicate detection → single source of truth |
| Can't tell who wrote what | Every entry carries source + updated (有籍) |
| Bulk edit destroyed history | Gate = backup first, reversible |
| Stale temp note still trusted | Stale-dim check flags old non-law entries |

## What's inside

- `SKILL.md` — 4-dimension audit + 2-step flow + entry template + 铁律
- `scripts/memory_audit.py` — zero-dependency CLI: scan dir/JSONL, flag duplicate/orphan/stale/unsourced, emit report

```bash
python scripts/memory_audit.py --dir ./memory --stale-days 30
python scripts/memory_audit.py --file entries.jsonl --json
```

## Benchmark vs alternatives

| Tool | It does | Gap this fills |
|---|---|---|
| Obsidian/Notion mem | Store & link notes | No dup/contradiction governance |
| Vector DB memory | Retrieve by similarity | No provenance, no staleness |
| "Just append to log" | Append forever | Grows contradictions unbounded |

Theoretical root: **LGD Three Laws** (registered · evidenced · gated). Pairs with `context-engineering` and `memory-governance`.

---

© 2026  / SynomosAI·China (ORCID 0009-0001-0512-1237) · 代码 MIT · 理论文本保留所有权利

---

## License & attribution
**分层许可(务必并读;代码许可不覆盖文档与理论文本)**

- **代码**(本包 `.py` 文件):**MIT**
- **本 `README.md` / `SKILL.md` 及其中的理论文本、方法论与一切理论表述**:**不在 MIT 覆盖范围内**,保留所有权利(All rights reserved)

```
© 2026 SynomosAI · China. All rights reserved.
理论署名 (attribution) : LGD(Lifecycle Governance Doctrine / 全程治理论)— SynomosAI initiative
名称状态 (name status)  : "SynomosAI" — 未申请实体注册、未申请商标注册
                        (not a registered legal entity; no trademark registered)
生产参考部署 (production reference, self-reported) : 无(未声明外部生产参考部署)
                    ← 非认证、非背书、非监管认可(not a certification or endorsement)
代码许可 (code license) : 本包未附 LICENSE 文件(许可待定)
                    本文本与理论表述不在任何代码许可覆盖范围内
引用格式 (cite as)      : 本资产无 DOI
```
(上列为《LGD 对外表述规范》§3.2 统一块,**整体复制、未删改**;发布/重提前须照最新版本复核。)

如何安装此技能?

访问技能市场,点击「安装」按钮,按提示将技能包放入 AI 编程助手的 skills 目录即可。

浏览技能市场

支持平台:Qoder · QoderWork · Claude · Codex 等 AI 编程助手

跨会话长期记忆治理(Memory Keeper) - 免费 | 技能派