上下文管理 - 混合检索记忆
Architecture
多模态检索模式,结合语义搜索、精确/关键词搜索和近期搜索并行运行。结果合并并重新排序为单一上下文集。召回率高得多,因为智能体可以找到模糊引用和精确实体。对于全面的知识检索至关重要。
完整 FlowZap 代码
User {
n1: circle label="Ask mixed query"
n2: rectangle label="See answer"
n1.handle(right) -> Agent.n3.handle(left)
Agent.n18.handle(right) -> n2.handle(left)
}
Agent {
n3: rectangle label="Plan retrieval strategy"
n4: rectangle label="Trigger semantic search"
n5: rectangle label="Trigger keyword search"
n6: rectangle label="Trigger recent-history search"
n7: rectangle label="Merge and rerank"
n8: rectangle label="Build prompt with hybrid context"
n9: rectangle label="Call LLM"
n18: rectangle label="Return answer"
n3.handle(bottom) -> n4.handle(top) [label="Semantic"]
n3.handle(right) -> n5.handle(left) [label="Keyword"]
n3.handle(left) -> n6.handle(right) [label="Recent"]
n7.handle(right) -> n8.handle(left)
n8.handle(right) -> n9.handle(left)
n9.handle(right) -> LLM.n19.handle(left)
}
Semantic {
n10: rectangle label="Vector search"
n11: rectangle label="Return semantic matches"
Agent.n4.handle(right) -> n10.handle(left)
n10.handle(right) -> n11.handle(left)
n11.handle(bottom) -> Agent.n7.handle(top) [label="Semantic"]
}
Keyword {
n12: rectangle label="Exact/ID search"
n13: rectangle label="Return exact matches"
Agent.n5.handle(right) -> n12.handle(left)
n12.handle(right) -> n13.handle(left)
n13.handle(bottom) -> Agent.n7.handle(top) [label="Keyword"]
}
Recent {
n14: rectangle label="Scan recent messages"
n15: rectangle label="Return recent matches"
Agent.n6.handle(right) -> n14.handle(left)
n14.handle(right) -> n15.handle(left)
n15.handle(bottom) -> Agent.n7.handle(top) [label="Recent"]
}
LLM {
n19: rectangle label="Reason over hybrid context"
n19.handle(right) -> Agent.n18.handle(left)
}
相关模板
上下文管理 - 档案记忆
Architecture
身份风格记忆模式,其中档案数据在会话开始时加载。每个提示结合系统角色、用户档案和当前消息。新事实可以写回档案记忆。开销小且可预测,但UX提升大——智能体记住你的名字、技术栈、语气和约束。
上下文管理 - 语义记忆
Architecture
基于向量的记忆模式,其中文本被分块、嵌入并存储在向量数据库中。查询时,问题被嵌入,运行向量搜索,重新排序候选,并将顶部结果注入提示。智能体感觉像记住一切而不会产生幻觉的地方。
上下文管理 - 情景记忆
Architecture
从经验中学习模式,其中每次任务运行成为一个情景,包含输入、动作和结果。在处理新任务之前,智能体获取类似情景并将其用作提示。随着时间的推移,智能体感觉像在学习和成长,而不是重复相同的失败计划。
上下文管理 - 共享记忆
Architecture
多智能体协调模式,其中编排器将工作分解为子任务,专业智能体从共享状态存储中拉取和推送,编排器从该共享状态组合最终答案。多智能体设置感觉连贯,而不是每个助手都有自己的不一致记忆。