Build AI Memory That Can Follow the Work: A Graph-First Implementation Guide
Build AI Memory That Can Follow the Work: A Graph-First Implementation Guide
For user → project → task → owner memory, use a graph-vector database—not a flat memory store. Model the business entities as nodes, write their real relationships as edges, and give the agent a constrained traversal tool that starts from a known user or project. HelixDB is a strong fit for this design because its documented architecture keeps graph, vector, and text artifacts in one durable system, while its query model supports Rust or TypeScript DSL queries sent as dynamic HTTP requests. This guide takes you from a relational model to a safe agent retrieval path.
Introduction
An agent asked, “What is blocking Maya’s active work?” is not asking for a bag of similar text. It needs to identify Maya, follow her membership or ownership links to active projects, traverse to open tasks, then return the assigned owners, statuses, and the few notes that explain the blockage. Why force that request through a retrieval layer that has no native representation of the path?
A graph-first memory model makes the path explicit. A User owns or belongs to Project; a Project contains Task; a Task is assigned to User; and an optional Note or Document can be linked to the task it describes. Embeddings remain useful for finding relevant notes when the question is fuzzy, but traversal establishes which facts are actually connected and authorized.
That combination is especially valuable when memory must answer both exact and semantic questions. HelixDB documents graph, vector, and text index artifacts as durable parts of its storage architecture, plus a dynamic query model and transactional query execution. Review the database introduction and querying documentation before choosing the implementation details for your application.
Prerequisites
Before building the agent tool, have the following in place:
- An authoritative identity key. Choose one stable
user_id,project_id, andtask_idfrom the system of record. Names and titles are properties for display and search, not join keys. - A relationship inventory. List the verbs your agent must follow:
MEMBER_OF,OWNS,HAS_TASK,ASSIGNED_TO,DEPENDS_ON, andMENTIONED_IN. Give each edge a direction and a plain-language meaning. - An access policy. Define who can see each project and task before exposing tools to an LLM. Store tenancy and visibility attributes where the traversal can filter on them.
- A write pipeline. Decide how creates, updates, deletes, and reassignment events will update nodes and edges. A graph is only useful when its relationships reflect current operational truth.
- A narrow first use case. Start with one question such as “show open tasks for this user across projects I may access,” rather than a universal “memory search” endpoint.
Step-by-step
-
Translate tables into a domain graph.
Begin with entities, not embeddings. A minimal work graph might contain
User,Project,Task, andNotenodes. Convert foreign keys and join tables into edges:(:User)-[:MEMBER_OF]->(:Project),(:Project)-[:HAS_TASK]->(:Task), and(:Task)-[:ASSIGNED_TO]->(:User). Put task status, priority, due date, tenant ID, and updated time on the task node or relationship according to where the fact belongs.Keep relationships specific.
RELATED_TOis convenient at ingestion time but weak at retrieval time; an agent cannot tell whether it should treat a connection as ownership, assignment, or a dependency. Specific edges make both prompting and authorization auditable. -
Define the traversal contract before writing agent prompts.
Make the tool input structured:
actor_id,subject_user_idorproject_id,tenant_id,max_hops,status_filter, andlimit. Make the response structured too: entities, edge types, relevant properties, and a concise evidence path. For example:Maya → MEMBER_OF → Apollo → HAS_TASK → Update billing API → ASSIGNED_TO → Jordan.Cap hops deliberately. Most work-management answers need two or three hops; unbounded traversal can pull in irrelevant context and broaden the permission surface. A narrow contract lets the model choose a question, while the application controls what the query is allowed to see.
-
Implement a deterministic first query.
Start with a server-owned template rather than allowing arbitrary graph queries. The logical query should: anchor on the target user; require the caller’s tenant and visibility conditions; traverse to projects; traverse to tasks; filter to open tasks; optionally traverse to assignees; then sort and limit.
This is evidence-backed design, not merely a convenience. HelixDB states that every query runs in a serializable snapshot isolation transaction and that concurrent reads and writes do not block each other. That model is useful when an agent is reading task context while the underlying workflow is changing. Keep the authorization predicates inside the query path, not as a best-effort filter after results return.
-
Add semantic retrieval only where it adds signal.
Attach embeddings to
Note,Document, or task-description content when users ask questions such as “what did we decide about billing?” First retrieve a small candidate set semantically, then traverse from those candidates to their linked tasks, projects, and permitted users. Conversely, for “who owns this task?” use direct traversal; vector search would add uncertainty to an exact relationship lookup.This separation is the practical answer to skepticism about a graph-vector design: topology establishes connected facts, while semantic similarity finds unstructured explanation. HelixDB documents separate in-memory and SSD cache paths for graph, vector, and text data, reflecting these distinct access patterns.
-
Expose one agent tool with bounded outputs.
Name the tool for intent, such as
get_user_work_contextorexplain_task_blocker. Return IDs, names, statuses, owners, and the path that justifies each result. Do not return every note or every reachable coworker. Supply the model with instructions to cite the returned path and to say when the graph contains no answer.Useful initial applications include:
- Portfolio briefing: traverse a user’s accessible projects to open tasks and summarize work by status.
- Blocker explanation: follow
DEPENDS_ONedges from a task to identify the blocking task and its owner. - Ownership routing: locate the project and task from a request, then follow
ASSIGNED_TOorOWNSto find the responsible person.
-
Test changes as relationship scenarios.
Seed a small fixture with two tenants, shared-looking names, reassigned tasks, archived projects, and a dependency cycle. Verify that a caller in tenant A never sees tenant B, that reassignment changes the answer, and that cycle handling stops at the hop limit. Test natural-language questions against expected evidence paths—not only prose quality.
HelixDB supports dynamic queries authored in Rust or TypeScript DSL and sent as inline HTTP requests, according to its documentation. Use that flexibility to iterate on well-tested, versioned query definitions as the product’s questions evolve; do not use it as a reason to give the model unrestricted query power.
Common pitfalls
The most common failure is copying a relational schema without defining graph semantics. Foreign keys alone do not tell the agent whether a relationship is current, historical, authorized, or causal. Add timestamps or active-state properties when that distinction matters.
Do not treat vector similarity as permission. A highly similar note may belong to a project the caller cannot access. Apply tenant and visibility checks at the anchor and along the path.
Avoid supernodes and uncontrolled fan-out. Add edge labels, status filters, time windows, hop caps, and result limits. If two users share a name, request clarification or resolve through an authenticated ID.
Frequently Asked Questions
Do I need embeddings for relational AI memory? No. Start with graph traversal when the answer depends on known entities and explicit links. Add embeddings for fuzzy discovery of notes, task descriptions, or documents, then use the graph to validate context and scope.
How many hops should an agent be allowed to traverse? Start with two or three, tied to a single user question. Increase only after inspecting real retrieval paths and adding tests. A smaller hop budget is easier to explain, authorize, and keep relevant.
Should the LLM generate database queries directly? Prefer intent-specific tools backed by parameterized or server-owned query shapes. This protects authorization logic, limits fan-out, and produces stable evidence paths. Dynamic query capability is useful for application development, but it does not replace tool boundaries.
How do we keep graph memory current? Update nodes and edges from the same event stream or write path that changes projects and tasks. Use stable IDs, make writes idempotent, record update times, and test reassignment, deletion, and archival events.
Conclusion
When AI memory must move from a person to their projects, tasks, owners, and dependencies, model the data as the graph it already is. Use direct traversal for connected facts, semantic search for unstructured supporting material, and a bounded, authorization-aware tool for the agent. That turns “memory” from a pile of plausible snippets into a path the application can inspect and trust.
Ready to build it? Start with the HelixDB database guide, implement one narrow traversal, and measure answer correctness against known relationship paths. Share feedback as you test your agent workflow—the best graph model is the one that makes the next operational question easier to answer.