# 第三章 记忆系统与上下文工程

记忆不是单一的“向量数据库”问题，而是一个从认知模型、工作记忆管理、长期记忆存储，到检索组织与上下文编排的系统工程。本章的核心路径更适合理解为：先分清“模型内部记住了什么”和“系统外部该保存什么”，再决定哪些信息应留在上下文窗口里、哪些信息应写入长期记忆、写入后又该如何检索、更新和组织，最后回到完整的上下文工程与案例分析。

## 学习目标

完成本章后，你将能够：

1. **理解** 记忆系统的认知模型与设计原则
2. **选择** 适合项目需求的向量数据库方案
3. **设计** 面向长期记忆的检索、更新与图结构方案
4. **统筹** 上下文窗口、长期记忆与安全约束之间的取舍

## 章节地图

本章按照“认知模型 → 工作记忆 → 长期记忆 → 检索结构 → 上下文工程”的顺序展开，但这些内容并不是一条简单的流水线，而是同一套 Agent 记忆系统里的相互制约层：

* [3.1 记忆的认知模型](/agentic_ai_guide/di-yi-bu-fen-dan-ti-zhi-neng-jia-gou/03_memory/3.1_memory_models.md)：先回答“什么才算记忆”，建立参数记忆、非参数记忆与多层记忆架构的基本框架
* [3.2 短期记忆管理](/agentic_ai_guide/di-yi-bu-fen-dan-ti-zhi-neng-jia-gou/03_memory/3.2_short_term_memory.md)：聚焦上下文窗口这一工作记忆层，讨论预算、裁剪、摘要与动态分配
* [3.3 长期记忆与向量数据库](/agentic_ai_guide/di-yi-bu-fen-dan-ti-zhi-neng-jia-gou/03_memory/3.3_vector_databases.md)：讨论长期记忆的存储底座，以及向量数据库的选型与边界
* [3.4 Agent 中的 RAG 系统设计](/agentic_ai_guide/di-yi-bu-fen-dan-ti-zhi-neng-jia-gou/03_memory/3.4_rag_advanced.md)：把“能存”推进到“能取、能评、能和任务协同”
* [3.5 图记忆与知识图谱](/agentic_ai_guide/di-yi-bu-fen-dan-ti-zhi-neng-jia-gou/03_memory/3.5_graph_memory.md)：补上向量相似度难以表达的关系、时序与结构约束
* [3.6 上下文工程](/agentic_ai_guide/di-yi-bu-fen-dan-ti-zhi-neng-jia-gou/03_memory/3.6_context_engineering.md)：把窗口、记忆、工具与安全要求整合成统一系统；文末继续用案例研究收束本章

***

**下一节**: [3.1 记忆的认知模型](/agentic_ai_guide/di-yi-bu-fen-dan-ti-zhi-neng-jia-gou/03_memory/3.1_memory_models.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://yeasy.gitbook.io/agentic_ai_guide/di-yi-bu-fen-dan-ti-zhi-neng-jia-gou/03_memory.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
