helix-memory-system
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseHelix Memory System
Helix内存系统
Build a durable, per-tenant agent memory platform on Helix that combines graph relationships, vector similarity, and BM25 full-text in one database. This skill covers the whole memory lifecycle: raw context ingestion, extraction, memory generation, deduplication, updating/versioning, deletion/forgetting, categorisation, profile maintenance, and hybrid retrieval.
Helix is the storage and retrieval engine. A complete memory product also needs application workers for extraction, chunking, embeddings, relationship classification, reranking, connector sync, and profile summarisation.
在Helix上构建一个持久化的、按租户隔离的Agent内存平台,该平台在单一数据库中整合了graph relationships、vector similarity和BM25 full-text三种能力。本技能覆盖完整的内存生命周期:原始上下文导入、提取、内存生成、去重、更新/版本控制、删除/遗忘、分类、画像维护以及混合检索。
Helix是存储与检索引擎。一个完整的内存产品还需要应用层处理程序来完成提取、分块、嵌入、关系分类、重排序、连接器同步和画像总结等工作。
When To Use
使用场景
Use this skill when the task is to:
- design the data model for agent memory, long-term memory, user profiles, document/chunk RAG, or a "remember what the user told me" feature
- write queries that create, deduplicate, reinforce, consolidate, version, correct, expire, forget, categorise, or retrieve memories
- decide which Helix capability (property index, graph edge, vector index, BM25 text index) a given memory operation should use
- build hybrid recall that fuses semantic + keyword + graph + profile context
- implement advanced memory components such as source documents, chunks, connectors, extracted facts, evolving profiles, relationship-aware recall, and forgetting
Do not use this skill for generic query syntax questions. For builder/method details defer to (the default DSL), , or . This skill assumes those and focuses on the memory architecture on top of Helix.
helix-query-typescripthelix-query-rusthelix-query-json-dynamic当你需要完成以下任务时,可使用本技能:
- 为Agent内存、长期记忆、用户画像、文档/片段RAG或“记住用户所说内容”功能设计数据模型
- 编写用于创建、去重、强化、合并、版本化、修正、过期、遗忘、分类或检索记忆的查询语句
- 确定给定的内存操作应使用Helix的哪种能力(属性索引、图边、向量索引、BM25文本索引)
- 构建融合语义+关键词+图+画像上下文的混合回忆系统
- 实现高级内存组件,如源文档、片段、连接器、提取的事实、动态演化的用户画像、感知关系的回忆功能以及遗忘机制
请勿将本技能用于通用查询语法问题。如需了解构建器/方法细节,请参考(默认DSL)、或。本技能假设你已掌握这些内容,重点聚焦于Helix之上的内存架构。
helix-query-typescripthelix-query-rusthelix-query-json-dynamicFirst Steps
初始步骤
- Inspect the target repo for existing labels, edges, properties, indexes, and route style. Reuse exact casing if present.
- Default to the TypeScript DSL () so the app can keep query generation near service code. Use
@helix-db/helix-dbonly if the runtime is Rust or the team explicitly ships Rust queries.EXAMPLES.rust.md - Decide the tenancy boundary before modeling anything. The canonical tenant property is because tenant-partitioned Helix text indexes currently require that name. Attach
tenant_idto every tenant-owned node and edge.tenant_id - Decide the memory visibility boundary separately from tenancy. In most apps, partitions indexes while
tenant_id,userId,containerId, or an app ACL decides which memories can be recalled. Default examples useprojectIdas the second-level scope.userId - Reuse the canonical model below before inventing labels. Adapt names, not the shape.
- Confirm how embeddings are produced. Default to OpenAI for production and benchmarkable memory systems:
text-embedding-3-smalldimensions, stored as1536arrays. The application computes embeddings client-side and passes numeric arrays (F32). Helix does not embed text on the dynamic-query path; there is noparam.array(param.f32())/Embed()in the current DSL. Keep embedding model and dimension fixed for each vector index. Deterministic hash embeddings are acceptable only for local UI demos or smoke tests, not for quality benchmarks.SearchV - Identify the application workers outside Helix: extractor, chunker, embedder, memory writer, relationship classifier, decay/expiry sweeper, profile summariser, optional query rewriter, optional reranker, and connector sync jobs.
- 检查目标仓库中现有的标签、边、属性、索引和路由风格。如果存在,复用完全一致的大小写格式。
- 优先使用TypeScript DSL(),以便应用程序将查询生成逻辑放在服务代码附近。仅当运行环境为Rust或团队明确要求使用Rust查询时,才使用
@helix-db/helix-db中的示例。EXAMPLES.rust.md - 在建模之前确定租户边界。标准的租户属性为****,因为按租户分区的Helix文本索引目前要求使用该名称。将
tenant_id附加到每个租户拥有的节点和边上。tenant_id - 单独确定内存可见性边界,与租户边界区分开。在大多数应用中,用于分区索引,而
tenant_id、userId、containerId或应用ACL决定哪些内存可以被召回。默认示例使用projectId作为二级范围。userId - 在创建新标签之前,先复用标准模型。仅调整名称,不要修改结构。
- 确认嵌入向量的生成方式。生产环境和可基准测试的内存系统默认使用OpenAI :1536维度,存储为
text-embedding-3-small数组。应用程序在客户端计算嵌入向量,并传递数值数组(F32)。Helix在动态查询路径上不执行文本嵌入操作;当前DSL中没有param.array(param.f32())/Embed()方法。为每个向量索引固定嵌入模型和维度。确定性哈希嵌入仅适用于本地UI演示或冒烟测试,不适用于质量基准测试。SearchV - 识别Helix之外的应用层处理程序:提取器、分块器、嵌入生成器、内存写入器、关系分类器、过期/衰减清理程序、画像总结器、可选的查询重写器、可选的重排序器以及连接器同步任务。
The Memory Model At A Glance
内存模型概览
Core labels: , , , , , , , , , optional and .
TenantUserUserProfileSourceDocumentChunkMemoryCategoryEntitySessionConnectorIngestionJobCore edges: (Tenant/User→Memory), (User→UserProfile), (SourceDocument→Chunk), (Memory→Chunk or SourceDocument), (Memory→Category), (Memory→Entity), (new Memory→old Memory), (Memory→Memory enrichment), (inferred Memory→supporting Memory), (Memory→Memory association), (Memory→Session), optional (Category→Category).
OWNSHAS_PROFILEHAS_CHUNKEXTRACTED_FROMIN_CATEGORYMENTIONSUPDATESEXTENDSDERIVESRELATES_TODERIVED_FROMPARENT_OFFast and safe fields:
- on every tenant-owned node and edge, with equality indexes where used as an anchor
tenant_id - or an equivalent scope key on user/container-specific memories, source documents, and chunks; only intentionally shared records should be tenant-wide
userId - stable IDs such as ,
memoryId,documentId,chunkId,categoryKey,entityKey, andsessionIdprofileId - ,
Memory.isLatest,validFrom,validTo, andexpiresAtfor record lifecycle filteringdeletedAt - optional real-world temporal fields such as ,
observedAt,eventStartAt,eventEndAt, andtemporalTextwhen the memory is about a dated event or facttimezone - tenant-partitioned vector/text indexes on /
Memory.embeddingand optionallyMemory.content/Chunk.embedding, all partitioned byChunk.contenttenant_id
Full spec, types, and index bootstrap are in .
REFERENCE.md核心标签:、、、、、、、、,可选标签**和**。
TenantUserUserProfileSourceDocumentChunkMemoryCategoryEntitySessionConnectorIngestionJob核心边:(Tenant/User→Memory)、(User→UserProfile)、(SourceDocument→Chunk)、(Memory→Chunk或SourceDocument)、(Memory→Category)、(Memory→Entity)、(新Memory→旧Memory)、(Memory→Memory补充)、(推断Memory→支撑Memory)、(Memory→Memory关联)、(Memory→Session),可选边****(Category→Category)。
OWNSHAS_PROFILEHAS_CHUNKEXTRACTED_FROMIN_CATEGORYMENTIONSUPDATESEXTENDSDERIVESRELATES_TODERIVED_FROMPARENT_OF高效且安全的字段:
- 每个租户拥有的节点和边上都带有,在用作锚点的位置创建等值索引
tenant_id - 用户/容器专属内存、源文档和片段上带有或等效范围键;只有明确共享的记录才应设为租户级全局可见
userId - 稳定ID,如、
memoryId、documentId、chunkId、categoryKey、entityKey和sessionIdprofileId - 、
Memory.isLatest、validFrom、validTo和expiresAt,用于记录生命周期过滤deletedAt - 当内存涉及日期事件或事实时,可选的现实时间字段,如、
observedAt、eventStartAt、eventEndAt和temporalTexttimezone - 按租户分区的向量/文本索引,基于/
Memory.embedding,可选基于Memory.content/Chunk.embedding,所有索引均按Chunk.content分区tenant_id
完整规范、类型和索引初始化内容见。
REFERENCE.mdModality Decision Rules
模态决策规则
Pick the mechanism by the question you are answering, and combine them deliberately:
| Need | Use | Why |
|---|---|---|
Tenant isolation ( | Properties + equality/range index | Narrow anchors and safe filters. Tenant scope is non-negotiable. |
| Categorisation, entities, provenance, profile ownership, updates/extensions/derivations, association clusters, taxonomy | Graph edges | These are relationships; traverse and aggregate over them. |
| Deduplication, paraphrase recall, memories like this, chunks like this | Vector search | Semantic similarity; tolerant of rewording. |
| Exact names, ids, rare tokens, commands, file paths, product terms | BM25 text search | Embeddings blur exact tokens; BM25 preserves them. |
| Broad user context the model should always know | UserProfile node + summariser worker | Avoid multiple searches for stable identity/preferences/recent focus. |
| Raw documents and citations | SourceDocument + Chunk nodes | Memory facts are not a replacement for source-grounded RAG. |
Rule of thumb: never collapse a memory system to vector-only. Vectors miss exact names and have no notion of ownership, recency, contradiction, provenance, profile state, or category.
Always scope vector/BM25 searches with . Tenant scope is necessary but not always sufficient: default user-memory recall must also filter by or the app's equivalent container/ACL unless the record is explicitly shared tenant-wide. Every recall path must filter out forgotten/stale records: , , , and absent or in the future. If a route cannot express one of those filters inside Helix, over-fetch and apply the remaining policy in application code before returning context.
tenantValue = tenant_iduserIddeletedAt IsNullisLatest = truevalidTo IsNullexpiresAt根据你要解决的问题选择对应机制,并有意地组合使用:
| 需求 | 使用方式 | 原因 |
|---|---|---|
租户隔离( | 属性 + 等值/范围索引 | 精准锚定和安全过滤。租户范围是不可协商的要求。 |
| 分类、实体、来源、画像归属、更新/补充/推导、关联集群、分类体系 | 图边 | 这些是关系型数据;可通过遍历和聚合操作处理。 |
| 去重、复述回忆、相似内存、相似片段 | 向量检索 | 语义相似度;对改写内容具有容错性。 |
| 精确名称、ID、稀有令牌、命令、文件路径、产品术语 | BM25文本检索 | 嵌入向量会模糊精确令牌;BM25可保留这些信息。 |
| 模型应始终知晓的广泛用户上下文 | UserProfile节点 + 总结处理程序 | 避免为获取稳定身份/偏好/近期关注点而执行多次检索。 |
| 原始文档和引用 | SourceDocument + Chunk节点 | 内存事实无法替代基于源文件的RAG。 |
经验法则:永远不要将内存系统简化为仅依赖向量检索。向量检索会遗漏精确名称,且无法处理归属、时效性、矛盾、来源、画像状态或分类等概念。
始终使用限定向量/BM25检索范围。租户范围是必要条件,但并非总是充分条件:默认的用户内存回忆还必须通过或应用等效的容器/ACL进行过滤,除非记录明确设为租户级全局共享。每个回忆路径必须过滤掉已遗忘/过期的记录:、、,且不存在或在未来。如果路由无法在Helix内部表达其中某些过滤条件,则先超额获取数据,再在应用代码中应用剩余策略后返回上下文。
tenantValue = tenant_iduserIddeletedAt IsNullisLatest = truevalidTo IsNullexpiresAtProduct Layers
产品层
Helix gives you graph + search primitives. A full intelligent memory system also needs:
| Layer | Responsibility |
|---|---|
| Ingestion API | Accept text, chats, files, URLs, connector events, and direct memory writes. |
| Extractors | Convert PDFs, docs, HTML, images/OCR, audio/video transcripts, code, and structured data into text. |
| Chunkers | Split raw context by semantic sections, message turns, document headings, code AST boundaries, or transcript segments. |
| Embedding worker | Generate |
| Memory generator | Extract atomic, entity-centric candidate facts from conversations/documents using the current turn plus recent context, active entities, recalled memories, and current date. |
| Relationship classifier | Decide whether each candidate |
| Profile summariser | Maintain |
| Forgetting jobs | Run expiry, decay, stale-profile, and connector deletion sweeps. |
| Retrieval service | Rewrite queries, run vector + BM25 over memories/chunks, fuse, rerank, graph-expand, and pack context with citations. |
| Evaluation | Measure recall quality, stale-memory suppression, tenant isolation, latency, and token efficiency. |
Do not imply Helix automatically does extraction, chunking, embedding, relationship classification, profile generation, connector sync, reranking, or TTL. Those are application responsibilities unless the user has a managed service that provides them.
Helix提供图+检索原语。一个完整的智能内存系统还需要以下层:
| 层 | 职责 |
|---|---|
| 导入API | 接收文本、聊天记录、文件、URL、连接器事件和直接内存写入请求。 |
| 提取器 | 将PDF、文档、HTML、图像/OCR、音频/视频转录文本、代码和结构化数据转换为文本格式。 |
| 分块器 | 按语义段落、消息轮次、文档标题、代码AST边界或转录片段拆分原始上下文。 |
| 嵌入处理程序 | 在写入Helix之前,为内存和片段生成 |
| 内存生成器 | 使用当前对话轮次+近期上下文、活跃实体、召回的内存和当前日期,从对话/文档中提取原子化、以实体为中心的候选事实。 |
| 关系分类器 | 判断每个候选事实是 |
| 画像总结器 | 根据最新内存维护 |
| 遗忘任务 | 执行过期、衰减、过期画像和连接器删除清理操作。 |
| 检索服务 | 重写查询,对内存/片段执行向量+BM25检索,融合结果、重排序、图扩展,并附带引用信息打包上下文。 |
| 评估 | 衡量回忆质量、过期内存抑制效果、租户隔离性、延迟和令牌效率。 |
请勿暗示Helix会自动执行提取、分块、嵌入、关系分类、画像生成、连接器同步、重排序或TTL任务。这些都是应用层的职责,除非用户使用的托管服务提供了这些功能。
The Memory Lifecycle
内存生命周期
Each step links to complete examples in (TypeScript) and (Rust).
EXAMPLES.mdEXAMPLES.rust.md每个步骤都链接到(TypeScript)和(Rust)中的完整示例。
EXAMPLES.mdEXAMPLES.rust.md1. Ingestion & Generation
1. 导入与生成
- Accept raw context as a , conversation/session, direct memory write, or connector update.
SourceDocument - Extract and chunk app-side when the input is not already an atomic memory.
- Embed each candidate memory/chunk app-side with OpenAI by default. Store/pass a 1536-length
text-embedding-3-smallvector.F32 - Extract atomic, self-contained candidate memories. Prefer entity-centric facts: "Alex prefers morning meetings" rather than "prefers morning meetings".
- Classify candidate kind: ,
fact,preference,episode, or app-specific equivalents.procedure - Deduplicate before writing. A similarity threshold cannot be a batch condition, so use read-then-write for semantic dedup and idempotent upsert for exact repeats.
- Write with
Memory,tenant_id,memoryId,content,embedding,kind,salience, and lifecycle timestamps; link ownership and provenance edges.isLatest: true - Categorise and entity-link immediately.
- 接收原始上下文,格式可为、对话/会话、直接内存写入或连接器更新。
SourceDocument - 当输入不是原子化内存时,在应用层进行提取和分块。
- 默认情况下,在应用层使用OpenAI 为每个候选内存/片段生成嵌入向量。存储/传递1536长度的
text-embedding-3-small向量。F32 - 提取原子化、自包含的候选内存。优先选择以实体为中心的事实:例如“Alex偏好上午会议”而非“偏好上午会议”。
- 分类候选内存类型:、
fact、preference、episode或应用特定的等效类型。procedure - 写入前去重。相似度阈值无法作为批量条件,因此语义去重使用“先读取再写入”方式,精确重复记录使用幂等更新。
- 写入,包含
Memory、tenant_id、memoryId、content、embedding、kind、salience和生命周期时间戳;关联归属和来源边。isLatest: true - 立即进行分类和实体链接。
Contextual Extraction Rules
上下文提取规则
Do not extract from the latest user message in isolation. The extraction worker should receive:
- the current user message
- the previous assistant message, because it often defines what a short answer means
- a bounded recent conversation window
- recalled active memories and active entities
- the current date/time for relative time phrases
- the memory scope (plus
tenant_id,userId,containerId, or ACL context)projectId
Resolve pronouns, ellipsis, and short follow-up answers before deciding whether to store a memory. If the assistant asks a memory-bearing follow-up question and the user answers briefly, convert the answer into a self-contained memory.
Extractor output should be structured enough for deterministic writes: , self-contained , , , , , pointers, , optional temporal fields, and a relationship decision (, , , , or ). Do not let a single vector-distance threshold decide updates; retrieve candidates with vector + BM25 and adjudicate exact duplicate vs update vs extension in application code.
shouldStorecontentkindconfidencesalienceentitiessourcescopenewduplicateEXTENDSUPDATESDERIVESExample:
text
Existing memory: User is planning a trip to Japan with Maya.
Assistant: When are you going?
User: next April
Extract: User is planning a trip to Japan with Maya next April.
Relationship: EXTENDS the existing Japan trip memory; MENTIONS Maya and Japan.
Assistant: What do you want to do there?
User: mostly food, temples, and trains
Extract: User wants their Japan trip with Maya to focus on food, temples, and trains.
Relationship: EXTENDS the existing Japan trip memory; categorise as travel/preferences.
User later: actually we're going in May instead
Extract: User is planning a trip to Japan with Maya in May.
Relationship: UPDATES the previous next-April timing memory and invalidates the older version.不要仅从最新用户消息中提取信息。提取处理程序应接收以下内容:
- 当前用户消息
- 上一条助手消息,因为它通常定义了简短回答的含义
- 有限的近期对话窗口
- 召回的活跃内存和活跃实体
- 当前日期/时间,用于解析相对时间短语
- 内存范围(加上
tenant_id、userId、containerId或ACL上下文)projectId
在决定是否存储内存之前,解析代词、省略语和简短跟进回答。如果助手提出一个涉及记忆的跟进问题,用户给出简短回答,则将该回答转换为自包含的内存。
提取器的输出应足够结构化,以支持确定性写入:、自包含的、、、、、指针、、可选时间字段,以及关系决策(、、、或)。不要仅通过向量距离阈值决定更新;使用向量+BM25检索候选记录,并在应用层代码中判断是精确重复、更新还是补充。
shouldStorecontentkindconfidencesalienceentitiessourcescopenewduplicateEXTENDSUPDATESDERIVES示例:
text
现有内存:用户正计划与Maya一起去日本旅行。
助手:你们什么时候去?
用户:明年四月
提取结果:用户正计划与Maya一起在明年四月去日本旅行。
关系:EXTENDS现有的日本旅行内存;MENTIONS Maya和Japan。
助手:你们想在那里做什么?
用户:主要是美食、寺庙和火车
提取结果:用户希望与Maya的日本旅行重点放在美食、寺庙和火车上。
关系:EXTENDS现有的日本旅行内存;分类为travel/preferences。
用户稍后:实际上我们改在五月去了
提取结果:用户正计划与Maya一起在五月去日本旅行。
关系:UPDATES之前的四月出行时间内存,并使旧版本失效。2. Updating & Versioning
2. 更新与版本控制
- Reinforce on access: bump ,
accessCount, and boundedlastAccessedAt.salience - Update/correct: create a new memory, link , set old
new -UPDATES-> oldandisLatest = false, and optionally setvalidToif it should disappear from normal recall.deletedAt - Extend: link when the new fact enriches but does not replace the old fact.
new -EXTENDS-> existing - Derive: link inferred facts with edges to supporting memories and mark them as inferred with confidence metadata.
DERIVES - If changes, re-embed and update
contentin the same write. Content and vector must never drift.embedding - Keep lifecycle validity (,
validFrom,validTo) separate from real-world event time (deletedAt,eventStartAt,eventEndAt). Updating a memory because a fact changed should invalidate the old record even if both facts refer to future or past dates.temporalText
- 访问时强化:增加、更新
accessCount和有限范围的lastAccessedAt。salience - 更新/修正:创建新内存,建立链接,将旧内存的
new -UPDATES-> old设为isLatest并设置false,如果需要从正常回忆中隐藏,可选择性设置validTo。deletedAt - 补充:当新事实丰富但不替换旧事实时,建立链接。
new -EXTENDS-> existing - 推导:使用边将推断事实与支撑内存关联,并标记为推断事实,附带置信度元数据。
DERIVES - 如果发生变化,在同一次写入操作中重新生成嵌入向量并更新
content。内容与向量必须始终保持一致。embedding - 将生命周期有效性(、
validFrom、validTo)与现实事件时间(deletedAt、eventStartAt)分开。当事实发生变化而更新内存时,即使两个事实都涉及未来或过去日期,也应使旧记录失效。eventEndAt
3. Deletion / Forgetting
3. 删除 / 遗忘
Helix has no native TTL or decay. Forgetting is explicit write queries the app runs.
- Soft-delete (preferred): set and filter it from reads. Reversible and audit-friendly.
deletedAt = Expr.datetime() - Version invalidation: set and
isLatest = falsewhen a memory is superseded.validTo = Expr.datetime() - Expiry sweep: hide or hard-delete memories where .
expiresAt < now - Decay sweep: hide weak, stale, rarely accessed episodic memories.
- Hard delete: use only when policy requires physical deletion.
drop()removes the node and incident edges; usedrop()for surgical edge cleanup on multigraph-sensitive paths.dropEdgeById
Helix没有原生TTL或衰减机制。遗忘是应用程序执行的显式写入查询。
- 软删除(推荐):设置,并在读取时过滤掉该记录。可恢复且便于审计。
deletedAt = Expr.datetime() - 版本失效:当内存被取代时,设置和
isLatest = false。validTo = Expr.datetime() - 过期清理:隐藏或硬删除的内存。
expiresAt < now - 衰减清理:隐藏弱关联、过期、很少访问的场景化内存。
- 硬删除:仅当策略要求物理删除时使用。
drop()会删除节点及其关联边;在对多图敏感的路径上,使用drop()进行精准的边清理。dropEdgeById
4. Categorisation & Entity Linking
4. 分类与实体链接
- Store display categories as nodes scoped by
Categoryand a uniquetenant_idsuch ascategoryKey.${tenant_id}:${normalisedName} - Store entities as nodes scoped by
Entityand a uniquetenant_idsuch asentityKey.${tenant_id}:${normalisedName} - Prefer edges over arrays when you will traverse, aggregate, or recall by the tag/entity.
- Use nested object metadata for display/audit fields that do not need graph expansion. Keep frequently filtered fields top-level, and prefer edges when you will traverse, aggregate, or recall by the tag/entity.
- 将显示类别存储为节点,按
Category和唯一的tenant_id(如categoryKey)限定范围。${tenant_id}:${normalisedName} - 将实体存储为节点,按
Entity和唯一的tenant_id(如entityKey)限定范围。${tenant_id}:${normalisedName} - 当需要遍历、聚合或按标签/实体召回时,优先使用边而非数组。
- 对于不需要图扩展的显示/审计字段,使用嵌套对象元数据。将频繁过滤的字段放在顶层,当需要遍历、聚合或按标签/实体召回时,优先使用边。
5. Profile Maintenance
5. 画像维护
- Maintain one per user/container with
UserProfile,profileId,tenant_id,userId,staticSummary, anddynamicSummary.updatedAt - Static profile: identity, stable preferences, long-lived background.
- Dynamic profile: current projects, recent context, temporary goals, unresolved tasks.
- Update profiles asynchronously after memory writes and deletions; keep profile generation deterministic enough to test.
- 为每个用户/容器维护一个,包含
UserProfile、profileId、tenant_id、userId、staticSummary和dynamicSummary。updatedAt - 静态画像:身份信息、稳定偏好、长期背景。
- 动态画像:当前项目、近期上下文、临时目标、未解决任务。
- 在内存写入和删除后异步更新画像;确保画像生成具有足够的确定性以便测试。
Retrieval
检索
Run multiple recall paths and fuse app-side:
- Fetch the for always-on context.
UserProfile - Run vector and BM25 over current nodes, tenant-scoped, user/container-scoped, and freshness-filtered.
Memory - Optionally run vector and BM25 over nodes for source-grounded RAG and citations, with the same owner/scope policy unless documents are intentionally shared.
Chunk - Fuse app-side with RRF, then re-rank by salience, recency, relationship type, and optional cross-encoder score.
- Expand top memories through ,
MENTIONS,IN_CATEGORY,EXTENDS, andUPDATES, bounded by depth and tenant filters.RELATES_TO - Pack context without embeddings and include source/citation metadata when available.
运行多条回忆路径并在应用层融合结果:
- 获取作为始终可用的上下文。
UserProfile - 对当前节点执行向量和BM25检索,限定租户范围、用户/容器范围,并进行新鲜度过滤。
Memory - 可选地对节点执行向量和BM25检索,用于基于源文件的RAG和引用,除非文档明确共享,否则使用相同的所有者/范围策略。
Chunk - 在应用层使用RRF融合结果,然后按重要性、时效性、关系类型和可选的交叉编码器分数进行重排序。
- 通过、
MENTIONS、IN_CATEGORY、EXTENDS和UPDATES扩展顶级内存,按深度和租户过滤进行限制。RELATES_TO - 打包上下文时不包含嵌入向量,若有可用的源/引用元数据则一并包含。
Anti-Patterns
反模式
Do not:
- use the deprecated dialect (
.hx,Embed(),SearchV,SearchBM25) for new dynamic/TS/Rust DSL workAddV - use as the text-index tenant property; use
userIdfor tenant-partitioned text/vector indexestenant_id - assume alone is a safe recall boundary for org/team tenants; filter by
tenant_id,userId, project ACLs, or an explicit shared-memory flagcontainerId - attach only to
tenant_id; every tenant-owned node and edge needs itMemory - mutate, delete, categorise, or reinforce by without also checking
memoryIdtenant_id - return superseded/forgotten/expired memories because recall only checked
deletedAt - mix lifecycle timestamps (,
validTo) with real-world event dates; use separate temporal fields for memories about trips, deadlines, appointments, or historical factsdeletedAt - build a vector-only store and call it memory
- use a toy hash embedding for production recall or benchmark claims; default to unless the app has a better standard model
text-embedding-3-small - decide dedup/update/extension by vector threshold alone; use exact checks, BM25 candidates, vector candidates, and app/LLM adjudication
- extract memories from only the latest user message and miss contextual follow-ups such as "next April" or "mostly food, temples, and trains"
- drop short follow-up answers because they are not self-contained before context resolution
- write user-specific chunks/documents without an owner or scope field, then recall them tenant-wide
- expect Helix to extract files, chunk documents, generate embeddings, classify updates, build profiles, rerank, sync connectors, or run TTL jobs automatically
- read after an
$distance/out/instep; project it immediately after searchboth - try to express a similarity-threshold dedup as a ; it can only test variable emptiness/size
BatchCondition - update without re-embedding
content - return arrays in API responses unless explicitly required
embedding - make or
Categoryglobal by display name in a multi-tenant memory appEntity
请勿:
- 在新的动态/TS/Rust DSL工作中使用已弃用的方言(
.hx、Embed()、SearchV、SearchBM25)AddV - 使用作为文本索引的租户属性;对按租户分区的文本/向量索引使用
userIdtenant_id - 假设本身是组织/团队租户的安全回忆边界;使用
tenant_id、userId、项目ACL或显式共享内存标记进行过滤containerId - 仅在上附加
Memory;每个租户拥有的节点和边都需要该属性tenant_id - 在不检查的情况下,按
tenant_id进行修改、删除、分类或强化操作memoryId - 因回忆仅检查而返回已被取代/遗忘/过期的内存
deletedAt - 将生命周期时间戳(、
validTo)与现实事件日期混用;对于涉及旅行、截止日期、预约或历史事实的内存,使用单独的时间字段deletedAt - 构建仅依赖向量的存储并称之为内存系统
- 在生产环境回忆或基准测试声明中使用玩具哈希嵌入;默认使用,除非应用程序有更好的标准模型
text-embedding-3-small - 仅通过向量阈值决定去重/更新/补充;使用精确检查、BM25候选记录、向量候选记录以及应用/LLM判断
- 仅从最新用户消息中提取内存,而遗漏“明年四月”或“主要是美食、寺庙和火车”等上下文跟进内容
- 在解析上下文之前,因简短跟进回答不自包含而丢弃它们
- 写入用户专属片段/文档时不添加所有者或范围字段,然后在租户级全局召回这些内容
- 期望Helix自动执行文件提取、文档分块、嵌入生成、更新分类、画像构建、重排序、连接器同步或TTL任务
- 在/
out/in步骤后读取both;在检索后立即投影该值$distance - 尝试将相似度阈值去重表示为;它只能测试变量是否为空/大小
BatchCondition - 更新而不重新生成嵌入向量
content - 在API响应中返回数组,除非明确要求
embedding - 在多租户内存应用中,按显示名称将或
Category设为全局可见Entity
Validation Checklist
验证清单
Before finishing:
- vs
readBatch()is correctwriteBatch() - every tenant-owned node and edge has
tenant_id - vector/text indexes use , and searches pass
tenant_property = "tenant_id"tenantValue = tenant_id - every memory read filters , user/container visibility,
tenant_id, current/latest state, and expiry validitydeletedAt IsNull - every write route accepts and filters by
tenant_id - IDs used for upsert are either globally unique or tenant-qualified (,
categoryKey, etc.)entityKey - user/container-specific documents and chunks carry the same owner/scope fields used by recall, or are explicitly marked/shared through app policy
- lifecycle validity fields are not overloaded as event-time fields; dated facts use ,
observedAt,eventStartAt,eventEndAt, or app equivalentstemporalText - embedding model is and every vector is 1536-dim
openai:text-embedding-3-small, unless the app explicitly standardises on another fixed model/dimensionF32 - content edits re-embed in the same write
- generation deduplicates semantically and exact repeats are idempotent
- extraction sees the previous assistant turn, recent conversation window, recalled active memories/entities, and current date before deciding what to store
- extraction emits a structured relationship/scope/source/temporal decision that can be tested deterministically
- source documents/chunks exist if the feature promises citations or RAG over raw context
- user profile update jobs exist if the feature promises always-on personalization
- evaluation covers tenant isolation, user/container isolation, stale-memory suppression, contextual follow-up extraction, exact-token recall, temporal corrections, deletion, profile rebuilds, latency, and token budget
- timestamps use one consistent convention; this skill uses typed DateTime via and
Expr.datetime()param.dateTime() - no projected output includes unless explicitly required
embedding - labels/edges/properties match existing repo casing
完成前请检查:
- 与
readBatch()的使用是否正确writeBatch() - 每个租户拥有的节点和边都带有
tenant_id - 向量/文本索引使用,且检索时传递
tenant_property = "tenant_id"tenantValue = tenant_id - 每次内存读取都过滤、用户/容器可见性、
tenant_id、当前/最新状态和过期有效性deletedAt IsNull - 每个写入路由都接收并过滤
tenant_id - 用于更新的ID要么是全局唯一的,要么是租户限定的(如、
categoryKey等)entityKey - 用户/容器专属文档和片段带有与回忆使用的相同所有者/范围字段,或通过应用策略明确标记为共享
- 生命周期有效性字段未被用作事件时间字段;带日期的事实使用、
observedAt、eventStartAt、eventEndAt或应用等效字段temporalText - 嵌入模型为,且每个向量都是1536维
openai:text-embedding-3-small,除非应用程序明确采用其他固定模型/维度F32 - 内容编辑时在同一次写入中重新生成嵌入向量
- 生成过程中进行语义去重,精确重复记录采用幂等更新
- 提取处理程序在决定存储内容之前,会查看上一条助手消息、近期对话窗口、召回的活跃内存/实体和当前日期
- 提取器输出结构化的关系/范围/来源/时间决策,可进行确定性测试
- 如果功能承诺提供引用或基于原始上下文的RAG,则存在源文档/片段
- 如果功能承诺提供始终可用的个性化服务,则存在用户画像更新任务
- 评估涵盖租户隔离、用户/容器隔离、过期内存抑制、上下文跟进提取、精确令牌回忆、时间修正、删除、画像重建、延迟和令牌预算
- 时间戳使用一致的约定;本技能通过和
Expr.datetime()使用类型化DateTimeparam.dateTime() - 除非明确要求,否则投影输出不包含
embedding - 标签/边/属性与现有仓库的大小写格式匹配
Reference Files
参考文件
- — full data-model spec, tenant rules, indexes, modality cheat-sheet, embedding guidance, fusion/re-ranking formula, and TypeScript ↔ Rust API mapping.
REFERENCE.md - — lifecycle scenarios as
EXAMPLES.mdTypeScript snippets. Default.@helix-db/helix-db - — the same scenarios in the Rust DSL.
EXAMPLES.rust.md - Adjacent skills: ,
helix-query-typescript,helix-query-rust,helix-query-json-dynamic.helix-query-optimize
- — 完整的数据模型规范、租户规则、索引、模态速查表、嵌入指南、融合/重排序公式以及TypeScript ↔ Rust API映射。
REFERENCE.md - — 生命周期场景的
EXAMPLES.mdTypeScript代码片段。默认参考。@helix-db/helix-db - — 相同场景的Rust DSL代码片段。
EXAMPLES.rust.md - 相关技能:、
helix-query-typescript、helix-query-rust、helix-query-json-dynamic。helix-query-optimize