Part 3: 上下文与记忆

Agent的"大脑":如何管理有限的上下文窗口和构建长期记忆

章节列表

章节标题核心问题
07上下文窗口管理如何在有限Token内保留最重要的信息?
08记忆架构如何让Agent拥有短期和长期记忆?
09多轮对话设计如何设计高质量的会话持久化?

学习目标

完成本Part后,你将能够:

  • 实现智能上下文截断策略
  • 设计分层记忆架构 (短期/长期)
  • 使用向量数据库进行语义检索
  • 处理多轮对话的去重和压缩

Shannon代码导读

Shannon/
├── docs/memory-system-architecture.md  # 记忆系统设计
├── python/llm-service/                 # Qdrant集成
└── go/orchestrator/                    # Session管理

关键概念

  • 滑动窗口: Token-aware的上下文管理
  • 语义去重: 95%相似度阈值
  • 层级记忆: 近期消息 + 向量检索

前置知识

  • Part 1-2 完成
  • 向量数据库基础 (Embedding概念)
引用本文 / Cite
Zhang, W. (2026). Part 3: 上下文与记忆. In AI Agent 架构:从单体到企业级多智能体. https://waylandz.com/ai-agent-book/Part3概述
@incollection{zhang2026aiagent_Part3概述,
  author = {Zhang, Wayland},
  title = {Part 3: 上下文与记忆},
  booktitle = {AI Agent 架构:从单体到企业级多智能体},
  year = {2026},
  url = {https://waylandz.com/ai-agent-book/Part3概述}
}