--- title: "Context Management(上下文管理)" created: 2026-05-23 updated: 2026-05-23 type: concept tags: [agent, context, memory, prompt] sources: [raw/papers/agent-harness-engineering-survey-2026.md] confidence: high --- # Context & Memory Management(C 层) > ETCLOVG 的 C 层:控制模型在短期、会话级和持久视野中能看到什么。从 Prompt Engineering 演进而来。 ## 三层视野 - **短期(Active Context Window)**:compaction、tool-result clearing、prompt-cache-aware ordering - **中期(Session State)**:跨运行持久化、会话状态管理 - **长期(Persistent Memory)**:向量存储、知识图谱、写入-管理-读取循环 ## 核心挑战:上下文漂移(Context Drift) 最深的上下文问题不是装更多 token,而是保持 Agent 的**工作状态与真实任务状态对齐**。 每次压缩、检索、遗忘操作都可能删除约束、扭曲优先级或保留过时假设。 ## 重新框架:上下文作为状态估计 Zhang et al. (2025) 和 Du (2026) 将 Agent 记忆形式化为**写入-管理-读取循环**。未来系统需要: - 不确定性感知摘要 - 事实溯源(provenance) - 矛盾处理 - 显式陈旧标记 - 从持久化产物重建状态的恢复程序 ## 相关概念 - [[context-state-estimation]] — 上下文作为状态估计 - [[reliable-state-long-running-agents]] — 长期状态维护 - [[prompt-to-harness-evolution]] — 从 Prompt 到 Context 的演进 - [[agent-harness-engineering-survey]]