mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-03-12 18:01:30 +08:00
docs: update memory system docs
This commit is contained in:
@@ -5,23 +5,25 @@ description: CowAgent long-term memory system
|
||||
|
||||
The memory system enables the Agent to remember important information over time, continuously accumulating experience, understanding user preferences, and truly achieving autonomous thinking and continuous growth.
|
||||
|
||||
## How It Works
|
||||
|
||||
The Agent proactively stores memory in the following scenarios:
|
||||
|
||||
- **When user shares important information** — Automatically identifies and stores preferences, decisions, facts, and other key information
|
||||
- **When conversation reaches a certain length** — Automatically extracts summaries to prevent information loss
|
||||
- **When retrieval is needed** — Intelligently searches historical memory, combining context for responses
|
||||
|
||||
## Memory Types
|
||||
|
||||
### Core Memory
|
||||
### Core Memory (MEMORY.md)
|
||||
|
||||
Stored in `~/cow/memory/core.md`, containing long-term user preferences, important decisions, key facts, and other information that doesn't fade over time.
|
||||
Stored in `~/cow/MEMORY.md`, containing long-term user preferences, important decisions, key facts, and other information that doesn't fade over time. Automatically injected into the system prompt on every conversation turn as background knowledge.
|
||||
|
||||
### Daily Memory
|
||||
### Daily Memory (memory/YYYY-MM-DD.md)
|
||||
|
||||
Stored in `~/cow/memory/daily/` directory, organized by date, recording daily conversation summaries and key events.
|
||||
Stored in `~/cow/memory/` directory, named by date (e.g. `2026-03-08.md`), recording daily conversation summaries and key events. Files are only created on first write to avoid generating empty files.
|
||||
|
||||
## Memory Writing
|
||||
|
||||
The Agent automatically persists conversation content to daily memory through the following mechanisms:
|
||||
|
||||
- **On context trimming** — When conversation turns or tokens exceed the configured limit, the oldest half of the context is trimmed in batch, and the discarded content is summarized by LLM into key information and written to the daily memory file
|
||||
- **Daily scheduled summary** — A full summary is automatically triggered at 23:55 every day, ensuring memory is preserved even on low-activity days (skipped if content hasn't changed)
|
||||
- **On API context overflow** — When the model API returns a context overflow error, the current conversation summary is saved as an emergency measure
|
||||
|
||||
All memory writes run asynchronously in a background thread (LLM summarization + file writing), never blocking normal conversation replies.
|
||||
|
||||
## First Launch
|
||||
|
||||
@@ -31,8 +33,8 @@ On first launch, the Agent will proactively ask the user for key information and
|
||||
| --- | --- |
|
||||
| `system.md` | Agent system prompt and behavior settings |
|
||||
| `user.md` | User identity information and preferences |
|
||||
| `memory/core.md` | Core memory |
|
||||
| `memory/daily/` | Daily memory directory |
|
||||
| `MEMORY.md` | Core memory (long-term) |
|
||||
| `memory/YYYY-MM-DD.md` | Daily memory (created on demand) |
|
||||
|
||||
<Frame>
|
||||
<img src="https://cdn.link-ai.tech/doc/20260203000455.png" width="800" />
|
||||
@@ -45,7 +47,7 @@ The memory system supports hybrid retrieval modes:
|
||||
- **Keyword retrieval** — Match historical memory based on keywords
|
||||
- **Vector retrieval** — Semantic similarity search, finds relevant memory even with different wording
|
||||
|
||||
The Agent automatically triggers memory retrieval during conversation as needed, incorporating relevant historical information into context.
|
||||
The Agent automatically triggers memory retrieval during conversation as needed, incorporating relevant historical information into context. Core memory (`MEMORY.md`) is always injected into the system prompt, while daily memory is loaded on demand via retrieval.
|
||||
|
||||
## Configuration
|
||||
|
||||
@@ -53,12 +55,12 @@ The Agent automatically triggers memory retrieval during conversation as needed,
|
||||
{
|
||||
"agent_workspace": "~/cow",
|
||||
"agent_max_context_tokens": 40000,
|
||||
"agent_max_context_turns": 30
|
||||
"agent_max_context_turns": 20
|
||||
}
|
||||
```
|
||||
|
||||
| Parameter | Description | Default |
|
||||
| --- | --- | --- |
|
||||
| `agent_workspace` | Workspace path, memory files stored under this directory | `~/cow` |
|
||||
| `agent_max_context_tokens` | Max context tokens, affects short-term memory capacity | `40000` |
|
||||
| `agent_max_context_turns` | Max context turns, oldest conversations discarded when exceeded | `30` |
|
||||
| `agent_max_context_tokens` | Max context tokens; when exceeded, half is trimmed and summarized into memory | `40000` |
|
||||
| `agent_max_context_turns` | Max context turns; when exceeded, half is trimmed and summarized into memory | `20` |
|
||||
|
||||
@@ -5,23 +5,25 @@ description: CowAgent 的长期记忆系统
|
||||
|
||||
记忆系统让 Agent 能够长期记住重要信息,在对话中不断积累经验、理解用户偏好,真正实现自主思考和持续成长。
|
||||
|
||||
## 工作原理
|
||||
|
||||
Agent 会在以下场景主动存储记忆:
|
||||
|
||||
- **用户分享重要信息时** — 自动识别偏好、决策、事实等关键信息并存储
|
||||
- **对话达到一定长度时** — 自动提取摘要,避免信息丢失
|
||||
- **需要检索时** — 智能搜索历史记忆,结合上下文进行回答
|
||||
|
||||
## 记忆类型
|
||||
|
||||
### 核心记忆
|
||||
### 核心记忆(MEMORY.md)
|
||||
|
||||
存储在 `~/cow/memory/core.md` 中,包含用户的长期偏好、重要决策、关键事实等不会随时间淡化的信息。
|
||||
存储在 `~/cow/MEMORY.md` 中,包含用户的长期偏好、重要决策、关键事实等不会随时间淡化的信息。每次对话时自动注入系统提示词,作为 Agent 的背景知识。
|
||||
|
||||
### 天级记忆
|
||||
### 天级记忆(memory/YYYY-MM-DD.md)
|
||||
|
||||
存储在 `~/cow/memory/daily/` 目录下,按日期组织,记录每天的对话摘要和关键事件。
|
||||
存储在 `~/cow/memory/` 目录下,按日期命名(如 `2026-03-08.md`),记录每天的对话摘要和关键事件。仅在首次写入时创建,避免生成空文件。
|
||||
|
||||
## 记忆写入
|
||||
|
||||
Agent 通过以下机制自动将对话内容持久化为天级记忆:
|
||||
|
||||
- **上下文裁剪时** — 当对话轮次或 token 超出配置上限时,批量裁剪最早一半的上下文,并使用 LLM 将被裁剪的内容总结为关键信息写入当天记忆文件
|
||||
- **每日定时总结** — 每天 23:55 自动触发一次全量总结,防止低活跃日无记忆留存(内容无变化时自动跳过)
|
||||
- **API 上下文溢出时** — 当模型 API 返回上下文溢出错误时,紧急保存当前对话摘要
|
||||
|
||||
所有记忆写入均在后台异步执行(LLM 总结 + 文件写入),不阻塞正常对话回复。
|
||||
|
||||
## 首次启动
|
||||
|
||||
@@ -31,8 +33,8 @@ Agent 会在以下场景主动存储记忆:
|
||||
| --- | --- |
|
||||
| `system.md` | Agent 的系统提示词和行为设定 |
|
||||
| `user.md` | 用户身份信息和偏好 |
|
||||
| `memory/core.md` | 核心记忆 |
|
||||
| `memory/daily/` | 天级记忆目录 |
|
||||
| `MEMORY.md` | 核心记忆(长期) |
|
||||
| `memory/YYYY-MM-DD.md` | 天级记忆(按需创建) |
|
||||
|
||||
<Frame>
|
||||
<img src="https://cdn.link-ai.tech/doc/20260203000455.png" width="800" />
|
||||
@@ -45,7 +47,7 @@ Agent 会在以下场景主动存储记忆:
|
||||
- **关键词检索** — 基于关键词匹配历史记忆
|
||||
- **向量检索** — 基于语义相似度搜索,即使表述不同也能找到相关记忆
|
||||
|
||||
Agent 会在对话中根据需要自动触发记忆检索,将相关历史信息纳入上下文。
|
||||
Agent 会在对话中根据需要自动触发记忆检索,将相关历史信息纳入上下文。核心记忆(`MEMORY.md`)始终注入系统提示词,天级记忆通过检索按需加载。
|
||||
|
||||
## 相关配置
|
||||
|
||||
@@ -53,12 +55,12 @@ Agent 会在对话中根据需要自动触发记忆检索,将相关历史信
|
||||
{
|
||||
"agent_workspace": "~/cow",
|
||||
"agent_max_context_tokens": 40000,
|
||||
"agent_max_context_turns": 30
|
||||
"agent_max_context_turns": 20
|
||||
}
|
||||
```
|
||||
|
||||
| 参数 | 说明 | 默认值 |
|
||||
| --- | --- | --- |
|
||||
| `agent_workspace` | 工作空间路径,记忆文件存储在此目录下 | `~/cow` |
|
||||
| `agent_max_context_tokens` | 最大上下文 token 数,影响短期记忆容量 | `40000` |
|
||||
| `agent_max_context_turns` | 最大上下文轮次,超出后自动丢弃最早对话 | `30` |
|
||||
| `agent_max_context_tokens` | 最大上下文 token 数,超出时裁剪一半并总结写入记忆 | `40000` |
|
||||
| `agent_max_context_turns` | 最大上下文轮次,超出时裁剪一半并总结写入记忆 | `20` |
|
||||
|
||||
Reference in New Issue
Block a user