记忆
一句话总结让 agent “记住”超出当前上下文窗口的信息:短期(会话内)、长期(跨会话)、以及基于向量检索的语义记忆。记忆的核心三动作是写入、检索、遗忘。
它解决什么问题
上下文窗口是易失的、有限的。记忆提供持久化与按需召回,使 agent 能跨轮次、跨会话保持一致,并从过去经验中受益。
设计维度 / 实现谱系
- 时效:短期(消息缓冲)↔ 长期(持久存储)
- 检索方式:全量 ↔ 关键词 ↔ 向量语义检索(embedding + 向量库)↔ 混合
- 结构:原始对话 ↔ 摘要 ↔ 实体/知识图 ↔ 经验/技能(自改进,ACE)
- 写入策略:全部存 ↔ 重要性筛选 ↔ 反思后提炼
- 遗忘/更新:TTL、容量上限、去重、冲突消解
关键要点
关联
各框架实现对比
下表汇总 45 个实现了「记忆」的框架(源码级阅读结论)。网站上以可展开 + 源码节选呈现。
| 框架 | 实现方式 |
|---|---|
| Aeon | Git 仓库即长期记忆:memory/MEMORY.md(索引)+ topics/ + logs/YYYY-MM-DD.md + cron-state.json(运行指标)+ issues/(工单)。无向量库;检索靠 grep/读文件。CLAUDE.md 强制每任务前读 MEMORY、任务后追加日志 |
| AG2 | 短期=每个对话方一条消息列表 _oai_messages(defaultdict(list));长期/向量=Teachability capability 用 ChromaDB 存”教导”记忆,经 process_last_received_message hook 召回(recall_threshold 距离阈值);RAG 见下 |
| Agency Swarm | 短期=ThreadManager 维护的扁平消息列表(MessageStore,按 agent/callerAgent 元数据过滤检索对话对);长期=由用户的 save/load_threads_callback 落盘;向量记忆=经 files_folder+OpenAI Vector Store 的 FileSearchTool(RAG),非内置语义记忆 |
| Agent-LLM (AGiXT) | 短期=数据库里的 Conversation/Message;长期=向量记忆,Memory 表 embedding = Column(Vector)(Postgres 走 pgvector),余弦相似度检索;embedding 用本地 ONNX 模型(onnx/model.onnx)离线生成,无需外部 embedding API |
| AgentDock | 四层记忆:Working/Episodic/Semantic/Procedural(memory/types/),由 MemoryManager 统管;写入经 PRIME 抽取器(LLM generateObject 按重要度分类落库,2-tier 选模);召回 RecallService 支持 hybrid(关键词+向量);含 LazyDecay 衰减、连接图谱、巩固 |
| AgentField | 控制平面托管的分布式记忆,四作用域 global / session / actor / workflow(run),读时按 workflow→session→actor→global 由窄到宽回退;KV + 向量检索(/memory/vector set/search,余弦 top_k,含 metadata filter),零外部依赖(内建于控制平面,无需 Redis) |
| Agentic Context Engine (ACE) | 长期记忆=Skillbook(跨会话持久化的策略库,JSON + .embeddings.npz sidecar);可选向量=dedup 用 sentence-transformers 给 skill 算 embedding;检索=BM25(lexical)+dense 的 RRF 融合 top-k |
| Agentset | 短期=多轮 messages(>1 轮时 CONDENSE_ prompt 把历史压成独立 query,chat/route.ts:87);长期=向量库即记忆(Pinecone/Turbopuffer,按 namespace/tenant 持久);无对话级长期记忆模块 |
| AgentVerse | BaseMemory 注册表多实现:ChatHistoryMemory(短期对话历史)、SummaryMemory(摘要压缩)、VectorStoreMemory(向量记忆,OpenAI embedding 存 content)、SdeTeamMemory;agent 默认 ChatHistoryMemory(agents/base.py:25) |
| Ailoy | 短期=调用方自持的 Vec |
| Astron Agent | 短期=chat_history 直接拼进 user prompt(RunnerBase.create_history_prompt)+ Scratchpad 累积步骤;长期=独立 memory 微服务(DB 化会话存储,暴露 create/ddl/dml/drop 等 DB 操作 API,前缀 /xingchen-db/v1);向量记忆走 knowledge/RAG 服务 |
| AutoGen | 短期=ChatCompletionContext(消息历史);长期=Memory 抽象基类(query/add/update_context 在推理前把检索内容注入 context),内置 ListMemory;向量/语义检索由 autogen-ext(如 ChromaDB)实现,core 内 N/A |
| Botpress | 短期=transcript(对话历史)+ 跨迭代持久的 variables/Object properties;长期/向量记忆非内核职责,靠 Botpress File API(RAG 示例中 client 上传+语义检索)。框架本身无内置向量库=N/A |
| ConnectOnion | 短期=current_session[‘messages’](多轮持久);长期=Memory 工具,markdown 文件 KV,超阈值自动拆目录(非向量检索,regex 搜索);向量记忆 N/A |
| Cordum | 非 agent 记忆。Context Engine(可选 gRPC 服务)做指针化上下文/记忆存储,写入时强制治理校验(policy/trust/directive 类写入必须带审批引用);向量检索 N/A |
| Cortex Memory | 核心。短期=会话消息时间线(session/manager.rs,session/timeline.rs);长期=LLM 提取的结构化记忆(preferences/entities/events/cases/personal_info/work_history/relationships/goals 八类,带 confidence 评分);向量=Qdrant 三层(L0/L1/L2)语义索引 |
| CrewAI | 统一 Memory:保存时用 LLM 抽取记忆并推断 scope/category/importance,按 recency+semantic+importance 加权检索;默认 LanceDB 向量存储(亦支持 Qdrant);crew.memory=True 启用 |
| Dust | 短期=对话消息(Postgres 持久)+ 自动 compaction 摘要;长期=agent_memory MCP server(AgentMemoryResource);向量记忆=core 的 data_sources + Qdrant(用于 RAG 而非 agent 自记忆) |
| Haystack | 短期=Agent State(按 state_schema 定义的 KV,messages 默认用 merge_lists handler 累积多轮);长期/向量=DocumentStore + Retriever(InMemory/外部向量库),即 RAG 充当语义记忆;另有 components/caching 缓存 |
| Hermes Agent | 短期=SQLite 会话消息(多轮持久);长期=memory 工具写 MEMORY.md(agent 自记) + USER.md(对用户的画像),§ 分隔、字符上限、session 启动时冻结快照注入 system prompt 保护 prefix cache;可插拔后端(内置/Honcho/Mem0);向量检索 N/A(走 FTS5 而非 embedding) |
| Hive | 短期=session 级 shared buffer(KV,按节点声明 read/write key 强制边界);长期=role-based / queen memory(agents/queen/queen_memory_v2.py + recall_selector.py 召回);上下文超限自动 compaction。向量检索=待确认(未见专用 vector store) |
| Lagent | 短期=按 session_id 分桶的 Memory(一个 List[AgentMessage]),MemoryManager 管理多会话;recent_n 截断 + filter_func 过滤;可 save()/load() 序列化。无长期/向量记忆 |
| LangChain | 短期=AgentState[“messages”](add_messages reducer 累积,middleware/types.py:356),由 checkpointer 按 thread 持久化为多轮记忆;长期/跨线程=LangGraph BaseStore(store= 参数);向量记忆经 core vectorstores/retrievers 抽象但非 agent 内建 |
| Llama Agentic System (llama-stack-apps) | 短期=服务端 session(enable_session_persistence,create_session/create_turn 维持多轮);长期/向量=builtin::rag + VectorIO API,vector_dbs.register 建库、tool_runtime.rag_tool.insert 灌库(all-MiniLM-L6-v2/384 维);agent_store 还有 “live memory bank” 动态写入 |
| LlamaIndex | 短期=ChatMemoryBuffer(token 截断);统一 Memory 类聚合 memory blocks:StaticMemoryBlock/FactExtractionMemoryBlock(LLM 抽取事实)/VectorMemoryBlock(向量长期记忆),token 超限自动 flush 到 block;底层走 SQLAlchemyChatStore |
| llm-agents | 仅”短期”=本次 run 的 previous_responses 列表(每轮把 generated+Observation 追加,整段塞回 prompt);无跨会话/长期/向量记忆 |
| LoongFlow | 两类:① 会话记忆 GradeMemory——STM/MTM/LTM 三级,超 token_threshold(默认 65536) 用 LLM 压缩器自动压缩(auto_compress);② 进化记忆 EvolveMemory——多岛 + MAP-Elites 网格 + 精英归档 + 岛间迁移,存 Solution(代码/分数/计划/总结/父子链)。非语义向量检索(多样性用长度/行数/字符集差分启发) |
| Maestro | 短期=两个列表 task_exchanges/haiku_tasks 累积历史,作为 previous_results 喂回 orchestrator、作为 system_message 喂回 sub-agent;无长期/向量记忆 |
| Mastra | 抽象基类 MastraMemory(@mastra/memory 提供实现):短期=线程对话历史(storage 持久化);长期=working memory(tool-call 模式更新的结构化 markdown/schema);向量=semantic recall(需配 vector store + embedder,相似度召回历史消息);另有 observational memory |
| MetaGPT | 短期=Memory(list 存储 + index[cause_by] 倒排索引,get_by_actions 按 Action 检索);长期=LongTermMemory/MemoryStorage 走 FAISS 向量检索(search_similar 余弦阈值过滤);RoleZeroMemory 用 Chroma RAG + LLMRanker 做超长记忆召回 |
| Modus | 短期=agent 实例的结构体字段(active instance 私有);长期=GetState/SetState 序列化字符串由 Runtime 自动落库(Postgres 或内置 modusDB);向量=独立 vectors 工具包(余弦/点积等数学运算,非托管向量存储) |
| nanobot | 短期=Session 历史(JSONL,token 预算回放);长期=MEMORY.md/SOUL.md/USER.md 文件;Dream 两阶段巩固把溢出消息 LLM 摘要进 history.jsonl(原子写+fsync,cursor 增量);按 token 预算触发 Consolidator。非向量检索 |
| Open Multi-Agent | 短期=AgentRunner 内 conversationMessages(单次 run) + Agent.messageHistory(跨 prompt() 多轮);团队共享=SharedMemory 命名空间 KV( |
| OpenClaw | 短期=session JSONL transcript(harness/session/jsonl-storage.ts);中期=会话压缩摘要(compaction);长期=/new·/reset 时把会话存为带日期 slug 的 markdown 记忆文件(session-memory hook)+ 工作区根 memory 文件;向量记忆=可选 memory-lancedb 插件(memory_store/memory_recall/memory_forget,LanceDB 向量+自动召回) |
| Pipecat | 短期=LLMContext 累积对话消息(add_message/get_messages);长期/向量=可选 Mem0MemoryService(FrameProcessor,接 mem0ai 向量记忆,extra mem0);亦有 persistent-context 示例做会话落盘 |
| PraisonAI | memory=True 启用 Memory(StorageMixin+SearchMixin+MemoryCoreMixin):默认 provider rag→ChromaDB 本地向量;可切 mem0(含 Neo4j/Memgraph graph memory)或 mongodb;短期 short_term.db + 长期 long_term.db + 实体/用户记忆;零依赖 file-based 模式 |
| Semantic Kernel | 短期=ChatHistory/AgentThread(多轮消息);上下文压缩=ChatHistorySummarizationReducer / ChatHistoryTruncationReducer;向量长期记忆=独立 VectorData. 连接器(AzureAISearch/Chroma/Qdrant/Redis/PgVector/Pinecone/Milvus/Weaviate…)+ 旧 ISemanticTextMemory(已弱化) |
| smolagents | 短期=AgentMemory.steps(TaskStep/ActionStep/PlanningStep 列表)每步 write_memory_to_messages() 重放为 chat 消息;无内建长期/向量记忆(N/A,可经 callback/外部工具自接) |
| Strands Agents | 短期=agent.messages 列表(多轮);上下文窗口由 ConversationManager 管:滑窗 SlidingWindowConversationManager(默认)/ 摘要 SummarizingConversationManager(:54,LLM 摘要旧消息)/ NullConversationManager;无内置向量记忆/RAG |
| SwarmClaw | 三层:working / durable / archive(按 category+metadata 分层);SQLite memory-db + embeddings 向量检索 + MMR 重排;“dream cycles” 在 idle 时做记忆巩固/去重(supersededBy 标记) |
| Swarms | 短期=Conversation(默认 in-memory 消息列表,conversation.py:52);长期=v12 persistent_memory 把 MEMORY.md 作为 system 前导注入并逐轮追加(conversation.py:281,420);compact() 摘要+归档(conversation.py:314);无内建向量记忆 → N/A |
| Transformers Agents | 会话内 agent memory(步骤日志);无长期/向量记忆 |
| Upsonic | Memory 三种保存+三种加载开关:full_session_memory(对话历史)/summary_memory(会话摘要)/user_analysis_memory(用户画像,支持 user_profile_schema);持久化走 storage 后端;向量记忆经 mem0/supermemory extra |
| vectara-agentic | 短期=LlamaIndex Memory.from_defaults(session_id=…, token_limit=65536)(agent.py:175),workflow 内部管理、结束后从 ctx.store.get(“memory”) 回写(agent.py:739);chat_history 可初始化(agent.py:178)。长期/向量记忆 N/A(向量检索属于 Vectara 语料层,不是 agent memory) |
| VoltAgent | Memory 门面三件套:StorageAdapter(消息/会话/working memory)、VectorAdapter+EmbeddingAdapter(向量语义检索);getMessagesWithSemanticSearch 把最近消息+语义召回拼接;searchSimilar 做向量检索;WorkingMemory 做结构化长期记忆 |
各框架实现对比 · 源码级
Aeon yaml Git 仓库即长期记忆:memory/MEMORY.md(索引)+ topics/ + logs/YYYY-MM-DD.md + cron-state.json(运行指标)+ issues/(工单)。无向量库;检索靠 grep/读文件。CLAUDE.md 强制每任务前读 MEMORY、任务后追加日志
Git 仓库即长期记忆:memory/MEMORY.md(索引)+ topics/ + logs/YYYY-MM-DD.md + cron-state.json(运行指标)+ issues/(工单)。无向量库;检索靠 grep/读文件。CLAUDE.md 强制每任务前读 MEMORY、任务后追加日志
查看 Aeon 完整笔记 →AG2 python 短期=每个对话方一条消息列表 _oai_messages(defaultdict(list));长期/向量=Teachability capability 用 ChromaDB 存"教导"记忆,经 process_last_received_message hook 召回(recall_threshold 距离阈值);RAG 见下
短期=每个对话方一条消息列表 _oai_messages(defaultdict(list));长期/向量=Teachability capability 用 ChromaDB 存"教导"记忆,经 process_last_received_message hook 召回(recall_threshold 距离阈值);RAG 见下
conversable_agent.py:272agentchat/contrib/capabilities/teachability.py:23
# a dictionary of conversations, default value is list
if chat_messages is None:
self._oai_messages = defaultdict(list)
else:
self._oai_messages = chat_messages
self._oai_system_message = [{"content": system_message, "role": "system"}]
self._description = description if description is not None else system_message
self._is_termination_msg = (
is_termination_msg
if is_termination_msg is not None
else (lambda x: content_str(x.get("content")) == "TERMINATE") Agency Swarm python 短期=ThreadManager 维护的扁平消息列表(MessageStore,按 agent/callerAgent 元数据过滤检索对话对);长期=由用户的 save/load_threads_callback 落盘;向量记忆=经 files_folder+OpenAI Vector Store 的 FileSearchTool(RAG),非内置语义记忆
短期=ThreadManager 维护的扁平消息列表(MessageStore,按 agent/callerAgent 元数据过滤检索对话对);长期=由用户的 save/load_threads_callback 落盘;向量记忆=经 files_folder+OpenAI Vector Store 的 FileSearchTool(RAG),非内置语义记忆
utils/thread.py:12utils/thread.py:121
@dataclass
class MessageStore:
"""Flat storage for all messages across all agents.
This class stores all messages in a single flat list with agent/callerAgent
metadata embedded in each message, replacing the previous thread-based structure.
Attributes:
messages (list[TResponseInputItem]): Flat list of all messages
metadata (dict[str, Any]): Optional metadata for the entire message store
""" Agent-LLM (AGiXT) python 短期=数据库里的 Conversation/Message;长期=向量记忆,Memory 表 embedding = Column(Vector)(Postgres 走 pgvector),余弦相似度检索;embedding 用本地 ONNX 模型(onnx/model.onnx)离线生成,无需外部 embedding API
短期=数据库里的 Conversation/Message;长期=向量记忆,Memory 表 embedding = Column(Vector)(Postgres 走 pgvector),余弦相似度检索;embedding 用本地 ONNX 模型(onnx/model.onnx)离线生成,无需外部 embedding API
DB.py:2725DB.py:2775Memories.py:64Memories.py:73 )
class Memory(Base):
__tablename__ = "memory"
id = Column(
UUID(as_uuid=True) if DATABASE_TYPE != "sqlite" else String,
primary_key=True,
default=get_new_id if DATABASE_TYPE == "sqlite" else uuid.uuid4,
)
agent_id = Column(
UUID(as_uuid=True) if DATABASE_TYPE != "sqlite" else String,
ForeignKey("agent.id"), AgentDock typescript 四层记忆:Working/Episodic/Semantic/Procedural(memory/types/),由 MemoryManager 统管;写入经 PRIME 抽取器(LLM generateObject 按重要度分类落库,2-tier 选模);召回 RecallService 支持 hybrid(关键词+向量);含 LazyDecay 衰减、连接图谱、巩固
四层记忆:Working/Episodic/Semantic/Procedural(memory/types/),由 MemoryManager 统管;写入经 PRIME 抽取器(LLM generateObject 按重要度分类落库,2-tier 选模);召回 RecallService 支持 hybrid(关键词+向量);含 LazyDecay 衰减、连接图谱、巩固
memory/extraction/PRIMEExtractor.ts:39}
// PRIME extraction schema for generateObject validation
const PRIMEExtractionSchema = z.object({
memories: z.array(
z.object({
content: z.string(),
type: z.enum(['working', 'episodic', 'semantic', 'procedural']),
importance: z.number().min(0).max(1),
reasoning: z.string().optional()
})
)
}); AgentField go 控制平面托管的分布式记忆,四作用域 global / session / actor / workflow(run),读时按 workflow→session→actor→global 由窄到宽回退;KV + 向量检索(/memory/vector set/search,余弦 top_k,含 metadata filter),零外部依赖(内建于控制平面,无需 Redis)
控制平面托管的分布式记忆,四作用域 global / session / actor / workflow(run),读时按 workflow→session→actor→global 由窄到宽回退;KV + 向量检索(/memory/vector set/search,余弦 top_k,含 metadata filter),零外部依赖(内建于控制平面,无需 Redis)
sdk/python/agentfield/memory.py:1control-plane/internal/handlers/vector_memory.go:31"""
Cross-Agent Persistent Memory Client for AgentField SDK.
Memory Scope Hierarchy
======================
AgentField provides four memory scopes for storing agent data:
Global Scope
------------ Agentic Context Engine (ACE) python 长期记忆=Skillbook(跨会话持久化的策略库,JSON + .embeddings.npz sidecar);可选向量=dedup 用 sentence-transformers 给 skill 算 embedding;检索=BM25(lexical)+dense 的 RRF 融合 top-k
长期记忆=Skillbook(跨会话持久化的策略库,JSON + .embeddings.npz sidecar);可选向量=dedup 用 sentence-transformers 给 skill 算 embedding;检索=BM25(lexical)+dense 的 RRF 融合 top-k
ace/core/skillbook.py:348ace/implementations/skill_rendering.py:129# ---------------------------------------------------------------------------
class Skillbook:
"""Structured context store as defined by ACE."""
def __init__(self) -> None:
self._skills: Dict[str, Skill] = {}
self._sections: Dict[str, List[str]] = {}
self._next_id = 0
self._similarity_decisions: Dict[FrozenSet[str], SimilarityDecision] = {}
self._lock = threading.RLock() Agentset typescript 短期=多轮 messages(>1 轮时 CONDENSE_ prompt 把历史压成独立 query,chat/route.ts:87);长期=向量库即记忆(Pinecone/Turbopuffer,按 namespace/tenant 持久);无对话级长期记忆模块
短期=多轮 messages(>1 轮时 CONDENSE_ prompt 把历史压成独立 query,chat/route.ts:87);长期=向量库即记忆(Pinecone/Turbopuffer,按 namespace/tenant 持久);无对话级长期记忆模块
chat/route.ts:87prompts.ts:26vector-store/index.ts:6 query = lastMessage;
} else {
// limit messagesWithoutQuery to the last 10 messages
const messagesToCondense = messagesWithoutQuery.slice(-10);
// we need to condense the messages + last message into a single query
query = (
await generateText({
model: languageModel,
prompt: CONDENSE_SYSTEM_PROMPT.compile({
question: lastMessage,
chatHistory: CONDENSE_USER_PROMPT.compile({
query: lastMessage, AgentVerse python BaseMemory 注册表多实现:ChatHistoryMemory(短期对话历史)、SummaryMemory(摘要压缩)、VectorStoreMemory(向量记忆,OpenAI embedding 存 content)、SdeTeamMemory;agent 默认 ChatHistoryMemory(agents/base.py:25)
BaseMemory 注册表多实现:ChatHistoryMemory(短期对话历史)、SummaryMemory(摘要压缩)、VectorStoreMemory(向量记忆,OpenAI embedding 存 content)、SdeTeamMemory;agent 默认 ChatHistoryMemory(agents/base.py:25)
memory/vectorstore.py:16
@memory_registry.register("vectorstore")
class VectorStoreMemory(BaseMemory):
"""
The main difference of this class with chat_history is that this class treat memory as a dict
treat message.content as memory
Attributes:
messages (List[Message]) : used to store messages, message.content is the key of embeddings. Ailoy rust 短期=调用方自持的 Vec<Message> 历史(每轮把 assistant/tool 消息 push 回 messages,src/agent/base.rs:246);本地推理侧有 KV-cache 的 LCP 前缀复用(非语义记忆,src/model/local/inferencer.rs:561);长期/向量"记忆"经 RAG knowledge 实现,框架本身不存对话
短期=调用方自持的 Vec<Message> 历史(每轮把 assistant/tool 消息 push 回 messages,src/agent/base.rs:246);本地推理侧有 KV-cache 的 LCP 前缀复用(非语义记忆,src/model/local/inferencer.rs:561);长期/向量"记忆"经 RAG knowledge 实现,框架本身不存对话
src/agent/base.rs:206src/model/local/inferencer.rs:551 Ok(tool_resps)
}
pub fn run_delta<'a>(
&'a mut self,
mut messages: Vec<Message>,
config: Option<AgentConfig>,
) -> BoxStream<'a, anyhow::Result<MessageDeltaOutput>> {
let knowledge = self.knowledge.clone();
let tools = self.tools.clone();
let AgentConfig {
inference: inference_config,
knowledge: knowledge_config, Astron Agent python 短期=chat_history 直接拼进 user prompt(RunnerBase.create_history_prompt)+ Scratchpad 累积步骤;长期=独立 memory 微服务(DB 化会话存储,暴露 create/ddl/dml/drop 等 DB 操作 API,前缀 /xingchen-db/v1);向量记忆走 knowledge/RAG 服务
短期=chat_history 直接拼进 user prompt(RunnerBase.create_history_prompt)+ Scratchpad 累积步骤;长期=独立 memory 微服务(DB 化会话存储,暴露 create/ddl/dml/drop 等 DB 操作 API,前缀 /xingchen-db/v1);向量记忆走 knowledge/RAG 服务
engine/nodes/base.py:28core/memory/database/api/router.py:15 now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
return now
async def create_history_prompt(self) -> str:
history_lines = [
f"{history.role.title()}: {history.content}"
for history in self.chat_history
]
return "\n".join(history_lines) or "无"
async def model_general_stream(
self, messages: list, span: Span, node_trace_log: NodeTraceLog AutoGen python 短期=ChatCompletionContext(消息历史);长期=Memory 抽象基类(query/add/update_context 在推理前把检索内容注入 context),内置 ListMemory;向量/语义检索由 autogen-ext(如 ChromaDB)实现,core 内 N/A
短期=ChatCompletionContext(消息历史);长期=Memory 抽象基类(query/add/update_context 在推理前把检索内容注入 context),内置 ListMemory;向量/语义检索由 autogen-ext(如 ChromaDB)实现,core 内 N/A
autogen-core/src/autogen_core/memory/_base_memory.py:60_assistant_agent.py:1027 memories: MemoryQueryResult
class Memory(ABC, ComponentBase[BaseModel]):
"""Protocol defining the interface for memory implementations.
A memory is the storage for data that can be used to enrich or modify the model context.
A memory implementation can use any storage mechanism, such as a list, a database, or a file system.
It can also use any retrieval mechanism, such as vector search or text search.
It is up to the implementation to decide how to store and retrieve data.
It is also a memory implementation's responsibility to update the model context Botpress typescript 短期=transcript(对话历史)+ 跨迭代持久的 variables/Object properties;长期/向量记忆非内核职责,靠 Botpress File API(RAG 示例中 client 上传+语义检索)。框架本身无内置向量库=N/A
短期=transcript(对话历史)+ 跨迭代持久的 variables/Object properties;长期/向量记忆非内核职责,靠 Botpress File API(RAG 示例中 client 上传+语义检索)。框架本身无内置向量库=N/A
packages/llmz/src/context.ts:388packages/llmz/examples/20_chat_rag/index.ts:50 public messages: LLMzPrompts.Message[]
public code?: string
public traces: HookedArray<Trace>
public variables: Record<string, any>
public started_ts: number
public ended_ts?: number
public status: IterationStatus
private _mutations: Map<string, ObjectMutation>
public get mutations() { ConnectOnion python 短期=current_session['messages'](多轮持久);长期=Memory 工具,markdown 文件 KV,超阈值自动拆目录(非向量检索,regex 搜索);向量记忆 N/A
短期=current_session['messages'](多轮持久);长期=Memory 工具,markdown 文件 KV,超阈值自动拆目录(非向量检索,regex 搜索);向量记忆 N/A
core/agent.py:259useful_tools/memory.py:44 self.logger.start_session(self.system_prompt, session_id=session.get('session_id'))
elif self.current_session is None:
# Initialize new session
self.current_session = {
'messages': [{"role": "system", "content": self.system_prompt}],
'trace': [],
'turn': 0 # Track conversation turns
}
# Start YAML session logging
self.logger.start_session(self.system_prompt)
# Save uploaded files to .co/uploads/ and build file path references
saved_files = [] Cordum go 非 agent 记忆。Context Engine(可选 gRPC 服务)做指针化上下文/记忆存储,写入时强制治理校验(policy/trust/directive 类写入必须带审批引用);向量检索 N/A
非 agent 记忆。Context Engine(可选 gRPC 服务)做指针化上下文/记忆存储,写入时强制治理校验(policy/trust/directive 类写入必须带审批引用);向量检索 N/A
core/contextwindow/engine/governance_write.go:54//
// Returns nil when the write is governance-compliant (or
// backward-compatible). Returns a typed sentinel for tests.
func validateGovernanceWrite(req *pb.UpdateMemoryRequest) error {
if req == nil {
return nil
}
wk := req.GetWriteKind()
mutates := req.GetPolicyStateMutation() || isSharedWriteKind(wk)
if !mutates {
return nil
}
if strings.TrimSpace(req.GetWriterAgentId()) == "" { Cortex Memory rust 核心。短期=会话消息时间线(session/manager.rs,session/timeline.rs);长期=LLM 提取的结构化记忆(preferences/entities/events/cases/personal_info/work_history/relationships/goals 八类,带 confidence 评分);向量=Qdrant 三层(L0/L1/L2)语义索引
核心。短期=会话消息时间线(session/manager.rs,session/timeline.rs);长期=LLM 提取的结构化记忆(preferences/entities/events/cases/personal_info/work_history/relationships/goals 八类,带 confidence 评分);向量=Qdrant 三层(L0/L1/L2)语义索引
session/extraction.rs:170session/extraction.rs:15layers/generator.rs:24search/vector_engine.rs:353 }
/// Extract memories from session messages using LLM
pub async fn extract(&self, messages: &[String]) -> Result<ExtractedMemories> {
if messages.is_empty() {
return Ok(ExtractedMemories::default());
}
tracing::info!(
"Starting memory extraction from {} messages",
messages.len()
); CrewAI python 统一 Memory:保存时用 LLM 抽取记忆并推断 scope/category/importance,按 recency+semantic+importance 加权检索;默认 LanceDB 向量存储(亦支持 Qdrant);crew.memory=True 启用
统一 Memory:保存时用 LLM 抽取记忆并推断 scope/category/importance,按 recency+semantic+importance 加权检索;默认 LanceDB 向量存储(亦支持 Qdrant);crew.memory=True 启用
crewai/memory/unified_memory.py:56crewai/crew.py:653 return build_embedder(spec)
class Memory(BaseModel):
"""Unified memory: standalone, LLM-analyzed, with intelligent recall flow.
Works without agent/crew. Uses LLM to infer scope, categories, importance on save.
Uses RecallFlow for adaptive-depth recall. Supports scope/slice views and
pluggable storage (LanceDB default).
"""
model_config = ConfigDict(arbitrary_types_allowed=True) Dust typescript 短期=对话消息(Postgres 持久)+ 自动 compaction 摘要;长期=agent_memory MCP server(AgentMemoryResource);向量记忆=core 的 data_sources + Qdrant(用于 RAG 而非 agent 自记忆)
短期=对话消息(Postgres 持久)+ 自动 compaction 摘要;长期=agent_memory MCP server(AgentMemoryResource);向量记忆=core 的 data_sources + Qdrant(用于 RAG 而非 agent 自记忆)
查看 Dust 完整笔记 →Haystack python 短期=Agent State(按 state_schema 定义的 KV,messages 默认用 merge_lists handler 累积多轮);长期/向量=DocumentStore + Retriever(InMemory/外部向量库),即 RAG 充当语义记忆;另有 components/caching 缓存
短期=Agent State(按 state_schema 定义的 KV,messages 默认用 merge_lists handler 累积多轮);长期/向量=DocumentStore + Retriever(InMemory/外部向量库),即 RAG 充当语义记忆;另有 components/caching 缓存
components/agents/state/state.py:56agent.py:289components/retrievers/in_memory/embedding_retriever.py:13document_stores/types/protocol.py:11 return deserialized_schema
def _validate_schema(schema: dict[str, Any]) -> None:
"""
Validate that a schema dictionary meets all required constraints.
Checks that each parameter definition has a valid type field and that any handler
specified is a callable function.
:param schema: Dictionary mapping parameter names to their type and handler configs
:raises ValueError: If schema validation fails due to missing or invalid fields
""" Hermes Agent python 短期=SQLite 会话消息(多轮持久);长期=memory 工具写 MEMORY.md(agent 自记) + USER.md(对用户的画像),§ 分隔、字符上限、session 启动时冻结快照注入 system prompt 保护 prefix cache;可插拔后端(内置/Honcho/Mem0);向量检索 N/A(走 FTS5 而非 embedding)
短期=SQLite 会话消息(多轮持久);长期=memory 工具写 MEMORY.md(agent 自记) + USER.md(对用户的画像),§ 分隔、字符上限、session 启动时冻结快照注入 system prompt 保护 prefix cache;可插拔后端(内置/Honcho/Mem0);向量检索 N/A(走 FTS5 而非 embedding)
tools/memory_tool.py:1agent/memory_manager.py:1#!/usr/bin/env python3
"""
Memory Tool Module - Persistent Curated Memory
Provides bounded, file-backed memory that persists across sessions. Two stores:
- MEMORY.md: agent's personal notes and observations (environment facts, project
conventions, tool quirks, things learned)
- USER.md: what the agent knows about the user (preferences, communication style,
expectations, workflow habits) Hive python 短期=session 级 shared buffer(KV,按节点声明 read/write key 强制边界);长期=role-based / queen memory(agents/queen/queen_memory_v2.py + recall_selector.py 召回);上下文超限自动 compaction。向量检索=待确认(未见专用 vector store)
短期=session 级 shared buffer(KV,按节点声明 read/write key 强制边界);长期=role-based / queen memory(agents/queen/queen_memory_v2.py + recall_selector.py 召回);上下文超限自动 compaction。向量检索=待确认(未见专用 vector store)
orchestrator/node.py:85 return None
class NodeSpec(BaseModel):
"""
Specification for a node in the graph.
This is the declarative definition of a node - what it does,
what it needs, and what it produces. The actual implementation
is separate (NodeProtocol).
Example:
NodeSpec( Lagent python 短期=按 session_id 分桶的 Memory(一个 List[AgentMessage]),MemoryManager 管理多会话;recent_n 截断 + filter_func 过滤;可 save()/load() 序列化。无长期/向量记忆
短期=按 session_id 分桶的 Memory(一个 List[AgentMessage]),MemoryManager 管理多会话;recent_n 截断 + filter_func 过滤;可 save()/load() 序列化。无长期/向量记忆
memory/base_memory.py:7memory/manager.py:7agents/agent.py:63from lagent.utils import load_class_from_string
class Memory:
def __init__(self, recent_n=None) -> None:
self.memory: List[AgentMessage] = []
self.recent_n = recent_n
def get_memory(
self,
recent_n: Optional[int] = None,
filter_func: Optional[Callable[[int, dict], bool]] = None, LangChain python 短期=AgentState["messages"](add_messages reducer 累积,middleware/types.py:356),由 checkpointer 按 thread 持久化为多轮记忆;长期/跨线程=LangGraph BaseStore(store= 参数);向量记忆经 core vectorstores/retrievers 抽象但非 agent 内建
短期=AgentState["messages"](add_messages reducer 累积,middleware/types.py:356),由 checkpointer 按 thread 持久化为多轮记忆;长期/跨线程=LangGraph BaseStore(store= 参数);向量记忆经 core vectorstores/retrievers 抽象但非 agent 内建
agents/middleware/types.py:353factory.py:707factory.py:706"""Annotation used to mark state attributes as purely internal for a given middleware."""
class AgentState(TypedDict, Generic[ResponseT]):
"""State schema for the agent."""
messages: Required[Annotated[list[AnyMessage], add_messages]]
jump_to: NotRequired[Annotated[JumpTo | None, EphemeralValue, PrivateStateAttr]]
structured_response: NotRequired[Annotated[ResponseT, OmitFromInput]]
class _InputAgentState(TypedDict): # noqa: PYI049
"""Input state schema for the agent.""" Llama Agentic System (llama-stack-apps) python 短期=服务端 session(enable_session_persistence,create_session/create_turn 维持多轮);长期/向量=builtin::rag + VectorIO API,vector_dbs.register 建库、tool_runtime.rag_tool.insert 灌库(all-MiniLM-L6-v2/384 维);agent_store 还有 "live memory bank" 动态写入
短期=服务端 session(enable_session_persistence,create_session/create_turn 维持多轮);长期/向量=builtin::rag + VectorIO API,vector_dbs.register 建库、tool_runtime.rag_tool.insert 灌库(all-MiniLM-L6-v2/384 维);agent_store 还有 "live memory bank" 动态写入
examples/agents/rag_agent.py:63examples/agent_store/api.py:67
# Create a vector database
vector_db_id = f"test_vector_db_{uuid4()}"
client.vector_dbs.register(
vector_db_id=vector_db_id,
embedding_model="all-MiniLM-L6-v2",
embedding_dimension=384,
provider_id=selected_vector_provider.provider_id,
)
# Insert documents using the RAG tool
start_time = time.time()
client.tool_runtime.rag_tool.insert( LlamaIndex python 短期=ChatMemoryBuffer(token 截断);统一 Memory 类聚合 memory blocks:StaticMemoryBlock/FactExtractionMemoryBlock(LLM 抽取事实)/VectorMemoryBlock(向量长期记忆),token 超限自动 flush 到 block;底层走 SQLAlchemyChatStore
短期=ChatMemoryBuffer(token 截断);统一 Memory 类聚合 memory blocks:StaticMemoryBlock/FactExtractionMemoryBlock(LLM 抽取事实)/VectorMemoryBlock(向量长期记忆),token 超限自动 flush 到 block;底层走 SQLAlchemyChatStore
memory/memory.py:187memory/memory_blocks/vector.py:29memory/memory_blocks/fact.py:66 return None
class Memory(BaseMemory):
"""
A memory module that waterfalls into memory blocks.
Works by orchestrating around
- a FIFO queue of messages
- a list of memory blocks
- various parameters (pressure size, token limit, etc.)
When the FIFO queue reaches the token limit, the oldest messages within the pressure size are ejected from the FIFO queue. llm-agents python 仅"短期"=本次 run 的 previous_responses 列表(每轮把 generated+Observation 追加,整段塞回 prompt);无跨会话/长期/向量记忆
仅"短期"=本次 run 的 previous_responses 列表(每轮把 generated+Observation 追加,整段塞回 prompt);无跨会话/长期/向量记忆
agent.py:57 return {tool.name: tool for tool in self.tools}
def run(self, question: str):
previous_responses = []
num_loops = 0
prompt = self.prompt_template.format(
today = datetime.date.today(),
tool_description=self.tool_description,
tool_names=self.tool_names,
question=question,
previous_responses='{previous_responses}'
)
print(prompt.format(previous_responses='')) LoongFlow python 两类:① 会话记忆 GradeMemory——STM/MTM/LTM 三级,超 token_threshold(默认 65536) 用 LLM 压缩器自动压缩(auto_compress);② 进化记忆 EvolveMemory——多岛 + MAP-Elites 网格 + 精英归档 + 岛间迁移,存 Solution(代码/分数/计划/总结/父子链)。非语义向量检索(多样性用长度/行数/字符集差分启发)
两类:① 会话记忆 GradeMemory——STM/MTM/LTM 三级,超 token_threshold(默认 65536) 用 LLM 压缩器自动压缩(auto_compress);② 进化记忆 EvolveMemory——多岛 + MAP-Elites 网格 + 精英归档 + 岛间迁移,存 Solution(代码/分数/计划/总结/父子链)。非语义向量检索(多样性用长度/行数/字符集差分启发)
agentsdk/memory/grade/memory.py:32agentsdk/memory/evolution/in_memory.py:23 auto_compress: bool = True
class GradeMemory:
"""Grade Memory"""
def __init__(
self,
stm: ShortTermMemory,
mtm: MediumTermMemory,
ltm: LongTermMemory,
token_counter: TokenCounter,
config: MemoryConfig, Maestro python 短期=两个列表 task_exchanges/haiku_tasks 累积历史,作为 previous_results 喂回 orchestrator、作为 system_message 喂回 sub-agent;无长期/向量记忆
短期=两个列表 task_exchanges/haiku_tasks 累积历史,作为 previous_results 喂回 orchestrator、作为 system_message 喂回 sub-agent;无长期/向量记忆
maestro.py:223maestro.py:94# Ask the user if they want to use search
use_search = input("Do you want to use search? (y/n): ").lower() == 'y'
task_exchanges = []
haiku_tasks = []
while True:
# Call Orchestrator to break down the objective into the next sub-task or provide the final output
previous_results = [result for _, result in task_exchanges]
if not task_exchanges:
# Pass the file content only in the first iteration if available
opus_result, file_content_for_haiku, search_query = opus_orchestrator(objective, file_content, previous_results, use_search)
else: Mastra typescript 抽象基类 MastraMemory(@mastra/memory 提供实现):短期=线程对话历史(storage 持久化);长期=working memory(tool-call 模式更新的结构化 markdown/schema);向量=semantic recall(需配 vector store + embedder,相似度召回历史消息);另有 observational memory
抽象基类 MastraMemory(@mastra/memory 提供实现):短期=线程对话历史(storage 持久化);长期=working memory(tool-call 模式更新的结构化 markdown/schema);向量=semantic recall(需配 vector store + embedder,相似度召回历史消息);另有 observational memory
memory/memory.ts:114 * - Working memory templates for structured conversation state
* - Handles memory processors to manipulate messages before they are sent to the LLM
*/
export abstract class MastraMemory extends MastraBase {
/**
* Unique identifier for the memory instance.
* If not provided, defaults to a static name 'default-memory'.
*/
readonly id: string;
MAX_CONTEXT_TOKENS?: number;
protected _storage?: MastraCompositeStore; MetaGPT python 短期=Memory(list 存储 + index[cause_by] 倒排索引,get_by_actions 按 Action 检索);长期=LongTermMemory/MemoryStorage 走 FAISS 向量检索(search_similar 余弦阈值过滤);RoleZeroMemory 用 Chroma RAG + LLMRanker 做超长记忆召回
短期=Memory(list 存储 + index[cause_by] 倒排索引,get_by_actions 按 Action 检索);长期=LongTermMemory/MemoryStorage 走 FAISS 向量检索(search_similar 余弦阈值过滤);RoleZeroMemory 用 Chroma RAG + LLMRanker 做超长记忆召回
metagpt/memory/memory.py:20metagpt/memory/longterm_memory.py:18metagpt/memory/memory_storage.py:56metagpt/memory/role_zero_memory.py:71from metagpt.utils.exceptions import handle_exception
class Memory(BaseModel):
"""The most basic memory: super-memory"""
storage: list[SerializeAsAny[Message]] = []
index: DefaultDict[str, list[SerializeAsAny[Message]]] = Field(default_factory=lambda: defaultdict(list))
ignore_id: bool = False
def add(self, message: Message):
"""Add a new message to storage, while updating the index"""
if self.ignore_id: Modus go 短期=agent 实例的结构体字段(active instance 私有);长期=GetState/SetState 序列化字符串由 Runtime 自动落库(Postgres 或内置 modusDB);向量=独立 vectors 工具包(余弦/点积等数学运算,非托管向量存储)
短期=agent 实例的结构体字段(active instance 私有);长期=GetState/SetState 序列化字符串由 Runtime 自动落库(Postgres 或内置 modusDB);向量=独立 vectors 工具包(余弦/点积等数学运算,非托管向量存储)
sdk/go/examples/agents/counterAgent.go:46runtime/db/agentstate.go:24
// This method should return the current state of the agent as a string.
// Any format is fine, but it should be consistent and easy to parse.
func (a *CounterAgent) GetState() *string {
s := strconv.Itoa(a.count)
return &s
}
// This method should set the state of the agent from a string.
// The string should be in the same format as the one returned by GetState.
// Be sure to consider data compatibility when changing the format of the state.
func (a *CounterAgent) SetState(data *string) {
if data == nil { nanobot python 短期=Session 历史(JSONL,token 预算回放);长期=MEMORY.md/SOUL.md/USER.md 文件;Dream 两阶段巩固把溢出消息 LLM 摘要进 history.jsonl(原子写+fsync,cursor 增量);按 token 预算触发 Consolidator。非向量检索
短期=Session 历史(JSONL,token 预算回放);长期=MEMORY.md/SOUL.md/USER.md 文件;Dream 两阶段巩固把溢出消息 LLM 摘要进 history.jsonl(原子写+fsync,cursor 增量);按 token 预算触发 Consolidator。非向量检索
agent/memory.py:40agent/memory.py:555agent/memory.py:781# MemoryStore — pure file I/O layer
# ---------------------------------------------------------------------------
class MemoryStore:
"""Pure file I/O for memory files: MEMORY.md, history.jsonl, SOUL.md, USER.md."""
_DEFAULT_MAX_HISTORY = 1000
_LEGACY_ENTRY_START_RE = re.compile(r"^\[(\d{4}-\d{2}-\d{2}[^\]]*)\]\s*")
_LEGACY_TIMESTAMP_RE = re.compile(r"^\[(\d{4}-\d{2}-\d{2} \d{2}:\d{2})\]\s*")
_LEGACY_RAW_MESSAGE_RE = re.compile(
r"^\[\d{4}-\d{2}-\d{2}[^\]]*\]\s+[A-Z][A-Z0-9_]*(?:\s+\[tools:\s*[^\]]+\])?:"
) Open Multi-Agent typescript 短期=AgentRunner 内 conversationMessages(单次 run) + Agent.messageHistory(跨 prompt() 多轮);团队共享=SharedMemory 命名空间 KV(<agentName>/<key>),可选 ttlTurns 过期、getSummary() 生成 markdown 注入;可插拔 MemoryStore(默认 InMemoryStore,可换 Redis/PG)。无向量检索
短期=AgentRunner 内 conversationMessages(单次 run) + Agent.messageHistory(跨 prompt() 多轮);团队共享=SharedMemory 命名空间 KV(<agentName>/<key>),可选 ttlTurns 过期、getSummary() 生成 markdown 注入;可插拔 MemoryStore(默认 InMemoryStore,可换 Redis/PG)。无向量检索
src/agent/agent.ts:103src/memory/shared.ts:64src/memory/shared.ts:266 private state: AgentState
private readonly _toolRegistry: ToolRegistry
private readonly _toolExecutor: ToolExecutor
private messageHistory: LLMMessage[] = []
/**
* @param config - Static configuration for this agent.
* @param toolRegistry - Registry used to resolve and manage tools.
* @param toolExecutor - Executor that dispatches tool calls.
*
* `toolRegistry` and `toolExecutor` are injected rather than instantiated
* internally so that teams of agents can share a single registry.
*/ OpenClaw typescript 短期=session JSONL transcript(harness/session/jsonl-storage.ts);中期=会话压缩摘要(compaction);长期=/new·/reset 时把会话存为带日期 slug 的 markdown 记忆文件(session-memory hook)+ 工作区根 memory 文件;向量记忆=可选 memory-lancedb 插件(memory_store/memory_recall/memory_forget,LanceDB 向量+自动召回)
短期=session JSONL transcript(harness/session/jsonl-storage.ts);中期=会话压缩摘要(compaction);长期=/new·/reset 时把会话存为带日期 slug 的 markdown 记忆文件(session-memory hook)+ 工作区根 memory 文件;向量记忆=可选 memory-lancedb 插件(memory_store/memory_recall/memory_forget,LanceDB 向量+自动召回)
src/hooks/bundled/session-memory/handler.ts:1extensions/memory-lancedb/README.md:16/**
* Session memory hook handler
*
* Saves session context to memory when /new or /reset command is triggered
* Creates a new dated memory file with a timestamp slug by default
*/
import fs from "node:fs/promises";
import os from "node:os";
import path from "node:path"; Pipecat python 短期=LLMContext 累积对话消息(add_message/get_messages);长期/向量=可选 Mem0MemoryService(FrameProcessor,接 mem0ai 向量记忆,extra mem0);亦有 persistent-context 示例做会话落盘
短期=LLMContext 累积对话消息(add_message/get_messages);长期/向量=可选 Mem0MemoryService(FrameProcessor,接 mem0ai 向量记忆,extra mem0);亦有 persistent-context 示例做会话落盘
processors/aggregators/llm_context.py:93services/mem0/memory.py:35LLMContextMessage: TypeAlias = LLMStandardMessage | LLMSpecificMessage
class LLMContext:
"""Manages conversation context for LLM interactions.
Handles message history, tool definitions, tool choices, and multimedia
content for LLM conversations. Provides methods for message manipulation,
and content formatting.
"""
def __init__(
self, PraisonAI python memory=True 启用 Memory(StorageMixin+SearchMixin+MemoryCoreMixin):默认 provider rag→ChromaDB 本地向量;可切 mem0(含 Neo4j/Memgraph graph memory)或 mongodb;短期 short_term.db + 长期 long_term.db + 实体/用户记忆;零依赖 file-based 模式
memory=True 启用 Memory(StorageMixin+SearchMixin+MemoryCoreMixin):默认 provider rag→ChromaDB 本地向量;可切 mem0(含 Neo4j/Memgraph graph memory)或 mongodb;短期 short_term.db + 长期 long_term.db + 实体/用户记忆;零依赖 file-based 模式
memory/memory.py:34
class Memory(StorageMixin, SearchMixin, MemoryCoreMixin):
"""
A single-file memory manager covering:
- Short-term memory (STM) for ephemeral context
- Long-term memory (LTM) for persistent knowledge
- Entity memory (structured data about named entities)
- User memory (preferences/history for each user)
- Quality score logic for deciding which data to store in LTM
- Context building from multiple memory sources
- Graph memory support for complex relationship storage (via Mem0) Semantic Kernel csharp 短期=ChatHistory/AgentThread(多轮消息);上下文压缩=ChatHistorySummarizationReducer / ChatHistoryTruncationReducer;向量长期记忆=独立 VectorData. 连接器(AzureAISearch/Chroma/Qdrant/Redis/PgVector/Pinecone/Milvus/Weaviate…)+ 旧 ISemanticTextMemory(已弱化)
短期=ChatHistory/AgentThread(多轮消息);上下文压缩=ChatHistorySummarizationReducer / ChatHistoryTruncationReducer;向量长期记忆=独立 VectorData. 连接器(AzureAISearch/Chroma/Qdrant/Redis/PgVector/Pinecone/Milvus/Weaviate…)+ 旧 ISemanticTextMemory(已弱化)
dotnet/src/SemanticKernel.Core/AI/ChatCompletion/ChatHistorySummarizationReducer.cs:20/// is provided (recommended), reduction will scan within the threshold window in an attempt to
/// avoid orphaning a user message from an assistant response.
/// </remarks>
public class ChatHistorySummarizationReducer : IChatHistoryReducer
{
/// <summary>
/// Metadata key to indicate a summary message.
/// </summary>
public const string SummaryMetadataKey = "__summary__";
/// <summary>
/// The default summarization system instructions.
/// </summary> smolagents python 短期=AgentMemory.steps(TaskStep/ActionStep/PlanningStep 列表)每步 write_memory_to_messages() 重放为 chat 消息;无内建长期/向量记忆(N/A,可经 callback/外部工具自接)
短期=AgentMemory.steps(TaskStep/ActionStep/PlanningStep 列表)每步 write_memory_to_messages() 重放为 chat 消息;无内建长期/向量记忆(N/A,可经 callback/外部工具自接)
memory.py:214agents.py:758memory.py:50 output: Any
class AgentMemory:
"""Memory for the agent, containing the system prompt and all steps taken by the agent.
This class is used to store the agent's steps, including tasks, actions, and planning steps.
It allows for resetting the memory, retrieving succinct or full step information, and replaying the agent's steps.
Args:
system_prompt (`str`): System prompt for the agent, which sets the context and instructions for the agent's behavior.
**Attributes**: Strands Agents python 短期=agent.messages 列表(多轮);上下文窗口由 ConversationManager 管:滑窗 SlidingWindowConversationManager(默认)/ 摘要 SummarizingConversationManager(:54,LLM 摘要旧消息)/ NullConversationManager;无内置向量记忆/RAG
短期=agent.messages 列表(多轮);上下文窗口由 ConversationManager 管:滑窗 SlidingWindowConversationManager(默认)/ 摘要 SummarizingConversationManager(:54,LLM 摘要旧消息)/ NullConversationManager;无内置向量记忆/RAG
summarizing_conversation_manager.py:54* Tool X: Result Y"""
class SummarizingConversationManager(ConversationManager):
"""Implements a summarizing window manager.
This manager provides a configurable option to summarize older context instead of
simply trimming it, helping preserve important information while staying within
context limits.
"""
def __init__(
self, SwarmClaw typescript 三层:working / durable / archive(按 category+metadata 分层);SQLite memory-db + embeddings 向量检索 + MMR 重排;"dream cycles" 在 idle 时做记忆巩固/去重(supersededBy 标记)
三层:working / durable / archive(按 category+metadata 分层);SQLite memory-db + embeddings 向量检索 + MMR 重排;"dream cycles" 在 idle 时做记忆巩固/去重(supersededBy 标记)
memory/memory-tiers.ts:3import type { MemoryEntry } from '@/types'
export type MemoryTier = 'working' | 'durable' | 'archive'
const WORKING_CATEGORIES = new Set(['execution', 'working', 'scratch', 'breadcrumb'])
const ARCHIVE_CATEGORIES = new Set(['session_archive'])
export function getMemoryTierForCategory(category: unknown): MemoryTier {
const normalized = typeof category === 'string' ? category.trim().toLowerCase() : ''
if (ARCHIVE_CATEGORIES.has(normalized)) return 'archive'
if (normalized.startsWith('session_archive/')) return 'archive'
if (normalized === 'operations/execution' || normalized.startsWith('operations/execution/')) return 'working' Swarms python 短期=Conversation(默认 in-memory 消息列表,conversation.py:52);长期=v12 persistent_memory 把 MEMORY.md 作为 system 前导注入并逐轮追加(conversation.py:281,420);compact() 摘要+归档(conversation.py:314);无内建向量记忆 → N/A
短期=Conversation(默认 in-memory 消息列表,conversation.py:52);长期=v12 persistent_memory 把 MEMORY.md 作为 system 前导注入并逐轮追加(conversation.py:281,420);compact() 摘要+归档(conversation.py:314);无内建向量记忆 → N/A
structs/conversation.py:52agent.py:522conversation.py:314 return conversation_dir
class Conversation:
"""
A class to manage a conversation history, allowing for the addition, deletion,
and retrieval of messages, as well as saving and loading the conversation
history in various formats.
The Conversation class uses in-memory storage for conversation history.
Attributes:
system_prompt (Optional[str]): The system prompt for the conversation. Transformers Agents python 会话内 agent memory(步骤日志);无长期/向量记忆
会话内 agent memory(步骤日志);无长期/向量记忆
查看 Transformers Agents 完整笔记 →Upsonic python Memory 三种保存+三种加载开关:full_session_memory(对话历史)/summary_memory(会话摘要)/user_analysis_memory(用户画像,支持 user_profile_schema);持久化走 storage 后端;向量记忆经 mem0/supermemory extra
Memory 三种保存+三种加载开关:full_session_memory(对话历史)/summary_memory(会话摘要)/user_analysis_memory(用户画像,支持 user_profile_schema);持久化走 storage 后端;向量记忆经 mem0/supermemory extra
src/upsonic/storage/memory/memory.py:27steps.py:749)
class Memory:
"""Orchestrator for session and user memory with runtime session type selection.
This class serves as the central coordinator for memory operations:
- Session memory: Chat history, summaries, session metadata
- User memory: User profiles and traits extracted from conversations
**Save vs Load flag separation:**
Save flags control what is persisted to storage: vectara-agentic python 短期=LlamaIndex Memory.from_defaults(session_id=..., token_limit=65536)(agent.py:175),workflow 内部管理、结束后从 ctx.store.get("memory") 回写(agent.py:739);chat_history 可初始化(agent.py:178)。长期/向量记忆 N/A(向量检索属于 Vectara 语料层,不是 agent memory)
短期=LlamaIndex Memory.from_defaults(session_id=..., token_limit=65536)(agent.py:175),workflow 内部管理、结束后从 ctx.store.get("memory") 回写(agent.py:739);chat_history 可初始化(agent.py:178)。长期/向量记忆 N/A(向量检索属于 Vectara 语料层,不是 agent memory)
agent.py:175agent.py:739agent.py:259 or f"{topic}:{date.today().isoformat()}"
)
self.memory = Memory.from_defaults(
session_id=self.session_id, token_limit=65536
)
if chat_history:
msgs = []
for u, a in chat_history:
msgs.append(ChatMessage.from_str(u, role=MessageRole.USER))
msgs.append(ChatMessage.from_str(a, role=MessageRole.ASSISTANT))
self.memory.put_messages(msgs) VoltAgent typescript Memory 门面三件套:StorageAdapter(消息/会话/working memory)、VectorAdapter+EmbeddingAdapter(向量语义检索);getMessagesWithSemanticSearch 把最近消息+语义召回拼接;searchSimilar 做向量检索;WorkingMemory 做结构化长期记忆
Memory 门面三件套:StorageAdapter(消息/会话/working memory)、VectorAdapter+EmbeddingAdapter(向量语义检索);getMessagesWithSemanticSearch 把最近消息+语义召回拼接;searchSimilar 做向量检索;WorkingMemory 做结构化长期记忆
memory/index.ts:76memory/index.ts:321memory/index.ts:487memory/index.ts:698 * Memory Class
* Handles conversation memory with optional vector search capabilities
*/
export class Memory {
private readonly storage: StorageAdapter;
private readonly embedding?: EmbeddingAdapter;
private readonly vector?: VectorAdapter;
private embeddingCache?: BatchEmbeddingCache;
private readonly workingMemoryConfig?: WorkingMemoryConfig;
private readonly titleGenerationConfig?: MemoryConfig["generateTitle"];
// Internal properties for Agent integration
private resourceId?: string;