Back to KB
Difficulty
Intermediate
Read Time
8 min

Zep AI's Graphiti: Agent Memory Without Schema Is Just Storage

By Codcompass Team··8 min read

Structured Agent Memory: Enforcing Ontologies in Temporal Knowledge Graphs

Current Situation Analysis

Autonomous agents require persistent, queryable memory to maintain context across sessions, tools, and multi-step workflows. The industry standard for building this memory has converged on a simple pattern: feed raw interaction logs or tool outputs into an LLM, ask it to extract entities and relationships, and store the results in a vector database or naive graph structure. This approach prioritizes retrieval speed over structural integrity, treating memory as a storage problem rather than a modeling problem.

The flaw is semantic drift. When an LLM is given unrestricted freedom to invent entity types and relationship labels, it defaults to high-abstraction, low-specificity outputs. Instead of AUTHORED_BY, SUPERSEDES, or DEPENDS_ON, you receive RELATED_TO. Instead of DeploymentConfig, SprintBacklogItem, or APIEndpoint, you receive Object or Concept. The resulting graph contains data, but lacks queryable structure. Engineers quickly discover that vector similarity search cannot compensate for a collapsed ontology. You cannot filter, traverse, or reason over a graph where every node is Thing and every edge is CONNECTED.

This problem is routinely overlooked because the AI engineering community has heavily optimized for embedding quality, chunking strategies, and retrieval-augmented generation (RAG) pipelines. Structural constraints are treated as optional metadata rather than foundational architecture. The consequence is a memory layer that grows linearly in size but decays quadratically in utility. Stale facts persist, contradictions go undetected, and downstream agents spend excessive tokens re-inferring context that should have been explicitly modeled.

The fix mirrors a pattern already proven across the broader AI stack: constrain the output space before generation, not after. By enforcing a strict ontology at extraction time, you transform agent memory from a generic storage bucket into a precise, queryable domain model.

WOW Moment: Key Findings

Constraining LLM extraction with a formal schema fundamentally changes how memory behaves in production. The following comparison illustrates the operational difference between unconstrained extraction and a schema-enforced temporal graph approach.

ApproachQuery PrecisionRelationship GranularityTemporal DriftSchema Maintenance Cost
Unconstrained LLM ExtractionLow (semantic overlap dominates)Generic (RELATES_TO, HAS_PROPERTY)High (stale edges persist indefinitely)Low initially, high long-term (manual cleanup)
Schema-Constrained Temporal GraphHigh (exact type/edge matching)Domain-specific (SUPERSEDES, DEPLOYED_TO)Low (automatic invalidation & history preservation)Moderate upfront, near-zero long-term

Why this matters: Precision in agent memory directly correlates with token efficiency and decision accuracy. When relationships are explicitly typed and temporally bounded, agents can traverse memory instead of re-reading it. The schema-constrained approach eliminates the need for post-hoc filtering, reduces hallucination rates during context assembly, and enables deterministic queries like Find all configurations superseded after 2024-03-15 without relying on probabilistic embedding matches.

Core Solution

Graphiti, an open-source temporal knowledge graph library from Zep AI, operationalizes schema-constrained memory through three structural primitives: typed entities, constrained edges, and automatic temporal resolution

🎉 Mid-Year Sale — Unlock Full Article

Base plan from just $4.99/mo or $49/yr

Sign in to read the full article and unlock all 635+ tutorials.

Sign In / Register — Start Free Trial

7-day free trial · Cancel anytime · 30-day money-back