Jev在Agent记忆系统中的应用与Graphiti架构解析
Jev for Agent Memory, clearly explained:
Agent开发必读,清晰拆解了记忆系统的分层架构,Jev做语义决策、Graphiti做持久化的模式可直接复用。
Jev for Agent Memory, clearly explained:
Jev 对 Agent Memory 的解读,解释得很清楚:
An agent-memory system often passes conversations, tool results, and task outcomes through an extractor.
一个 agent-memory 系统通常通过提取器来处理对话、工具结果和任务输出。
The extractor identifies possible memories such as user preferences, facts, and procedures.
提取器会识别出可能的记忆内容,例如用户偏好、事实和操作流程。
Consider a travel assistant. The user says:
以一个旅行助手为例。用户说:
- I usually prefer an aisle seat. - For this flight, book a window seat. - The flight is delayed by 25 minutes.
- 我通常更喜欢靠过道的座位。 - 对于这次航班,预订靠窗的座位。 - 航班延误了 25 分钟。
These statements should not receive identical treatment.
这些陈述不应受到相同的处理。
The aisle-seat preference could help with future bookings. The window-seat request applies to one flight. The delay becomes useless once the flight is over.
靠过道座位的偏好可能有助于未来的预订。靠窗座位的请求仅适用于一次航班。一旦航班结束,延误信息就失效了。
A capable memory system may already handle this distinction.
一个成熟的记忆系统可能已经能够处理这种区分。
Graphiti, for example, records where a fact came from, resolves it against existing facts, and tracks when it becomes valid or invalid. If the source contains enough context, it can keep the window-seat request specific to one trip.
例如,Graphiti 会记录事实的来源,将其与现有事实进行比对,并追踪其何时变为有效或无效。如果来源包含足够的上下文,它可以使靠窗座位的请求仅限于某次行程。
So Jev should not be added to recreate logic the memory system already provides.
因此,Jev 不应被添加进来去重新实现记忆系统已经提供的逻辑。
It becomes useful when the application has its own rules for what may enter long-term memory.
当应用程序拥有自己的规则来决定哪些内容可以进入长期记忆时,它才变得有用。
A travel application might require that:
一个旅行应用程序可能会要求:
- Only preferences stated or confirmed by the user become account-level memories. - Preferences inferred from one booking remain attached to that trip. - Passport numbers and payment details never enter general memory. - Ambiguous candidates remain in the session until the user confirms them.
- 只有用户明确声明或确认的偏好才会成为账户级别的记忆。 - 从单次预订中推断出的偏好仍与该行程绑定。 - 护照号码和支付详情永远不会进入通用记忆。 - 模糊的候选项保留在会话中,直到用户确认它们。
These rules require semantic judgment. Once the info has been classified, ordinary code can enforce the policy.
这些规则需要语义判断。一旦信息被分类,普通代码就可以执行策略。
The challenge here is deciding whether a sentence describes a lasting preference, a one-time instruction, or weak evidence for an inferred preference.
这里的挑战在于判断一个句子描述的是持久的偏好、一次性指令,还是用于推断偏好的微弱证据。
Jev can make that decision before the app even invokes Graphiti.
Jev 可以在应用程序甚至调用 Graphiti 之前做出该决定。
For each candidate, the application sends Jev the proposed fact, its source evidence, and the current user, trip, and session state.
对于每个候选项,应用程序向 Jev 发送拟议的事实、其来源证据以及当前的用户、行程和会话状态。
It can ask typed questions such as:
它可以提出类型化的问题,例如:
- Did the user state this preference explicitly? - Does it apply beyond the current trip? - Which retention scope fits it? - Would reusing it on another booking create a meaningful risk?
- 用户是否明确声明了这一偏好? - 它是否适用于当前行程之外? - 哪种保留范围适合它? - 在其他预订中重用它会带来有意义的风险吗?
Jev returns choices, scores, and probabilities. Application code applies the thresholds:
Jev 返回选项、评分和概率。应用程序代码应用阈值:
↳ Save the aisle-seat preference for the user. ↳ Keep the window-seat request with this trip. ↳ Leave the delay in the active session. ↳ Reject sensitive fields before they reach general memory.
↳ 为用户保存靠过道座位的偏好。 ↳ 将靠窗座位的请求与该行程保留在一起。 ↳ 将延误信息留在活跃会话中。 ↳ 在敏感字段到达通用记忆之前拒绝它们。
Several questions can share the same state in one Jev request.
多个问题可以在单个 Jev 请求中共享相同的状态。
- Approved candidates are then sent to Graphiti as episodes. - From there, Graphiti handles extraction, entity resolution, provenance, temporal updates, and retrieval.
- 审核通过的候选者随后作为事件(episodes)发送至 Graphiti。 - 此后,Graphiti 负责提取、实体解析、溯源、时间更新和检索。
GitHub repo: https://github.com/getzep/graphiti
GitHub 仓库:https://github.com/getzep/graphiti
(don't forget to star it ⭐)
(别忘了给它点个星 ⭐)
Note that if Graphiti's existing ingestion behavior meets your application's requirements, the Jev gate is unnecessary.
请注意,如果 Graphiti 现有的数据摄入行为已满足你的应用需求,则无需使用 Jev gate。
Add Jev when you need to check product-specific rules, such as whether a preference was explicitly confirmed or whether a fact is safe to store, before sending it to Graphiti.
当需要在将数据发送至 Graphiti 之前检查特定产品的规则时(例如,是否明确确认了某项偏好,或某个事实是否安全可存储),请添加 Jev。
If you want to dive deeper, I have also written a hands-on guide showing how to build a Jev-style model with open models, entirely locally.
如果你想深入了解,我还撰写了一份实操指南,展示如何完全在本地使用开源模型构建 Jev 风格的模型。
Read it below.
请在下方阅读。
更进一步:量化金融体系
看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力