Your Agent Memory Probably Needs an Ontology -Just Not the One You Think
From the publisher’s feed, collected in the ZeroLabs newsroom.
A practical split between lightweight extraction schemas and full semantic infrastructure for teams building agent memory.Two teams asked me the same question recently: “Do we need an ontology for agent memory?”The problem was they were asking completely different questions.One team meant: should we give the LLM a constrained vocabulary so it extracts Supplier, Contract, ApprovalStatus, and RiskSignal consistently?The other meant: do we need OWL, SHACL, a triple store, a reasoner, and a formal semantic governance process?Same word. Two very different architectural decisions.This confusion is showing up everywhere as teams build agent memory systems. Some over-engineer the memory layer with full semantic infrastructure before they have a single production workflow running. Others reject “ontology” entirely, skip even a lightweight extraction schema, and end up with an entity graph full of Vendor, Supplier, supplier_org, Counterparty, and external_party all meaning roughly the same thing.Both teams are making the same mistake. Ontology is not one decision. It is two.The Two OntologiesThe two ontologies: As extraction schema and as semantic infrastructureOntology-as-extraction-schema is a constrained vocabulary you feed into the LLM prompt or function call to keep extraction consistent. Entity classes, relation types, canonical aliases. It tells the model: when you see a supplier being evaluated, call it a Supplier, not a Vendor or a Party. When you see an evaluation outcome, call it SHORTLISTED or REJECTED, not a free-text description.This is cheap. It lives in a YAML file or a Pydantic schema. No infrastructure implications, no triple store, no SPARQL endpoint required. It is the difference between an episodic memory graph you can actually query and one that is a soup of near-duplicate nodes with inconsistent labels.Ontology-as-semantic-infrastructure is what your architecture review board pictures when the word “ontology” comes up: OWL class hierarchies, SHACL constraint documents, triple stores, reasoners. Shared meaning that travels across system and organizational boundaries. Portable validation that an external auditor or a partner system can run without calling your API and trusting your interpretation.This is expensive. It requires specialized skills to build and maintain. And it is genuinely worth it when meaning must be shared, validated, or inferred across boundaries you do not control.A concrete example to make this tangible:Take Approved Supplier. Is it an extraction-schema class? Yes, always. You want the LLM to consistently tag supplier entities with an approval status rather than burying it in free-form text. Is it a validated semantic entity requiring cross-system agreement via OWL and SHACL? Only if the definition of "approved" needs to be reconciled across your ERP, your contract management system, your risk platform, and a procurement agent that none of those systems built.LLM Extraction with and without schemaSame entity. Two different questions. In a single-platform deployment, the extraction schema is enough. In a multi-system procurement workflow where four systems each have their own approved_flag with subtly different meanings, you eventually need the semantic infrastructure.The practical test is simple: if a concept only needs to make extraction and retrieval consistent, use an extraction schema. If its meaning is contested across systems and that disagreement causes production failures, promote it into semantic infrastructure.Where Each One Lives in the Memory StackWhere Ontology lives in memory stackRun the three memory types through this lens and the picture becomes clear.Procedural and working memory usually do not need ontology in the strong sense. Procedural memory can benefit from task labels or outcome categories, but a lightweight tagging mechanism is sufficient for that. Tag a task as sourcing or exception-approval, mark an outcome as succeeded or escalated, and you have enough structure to retrieve and learn from patterns without building a formal domain ontology. Working memory is just the current context window. The ontology debate belongs in episodic and semantic memory.Episodic and semantic memory is the only contested tier. Worth splitting further:Episodic KG captures what happened: who decided what, which tool was called, what the outcome was. It is schema-emergent, shaped by what real transactions reveal over time. Schema-emergent is not the same as schema-agnostic. The extraction schema is doing real work from day one. What emerges over time is the full shape of the domain graph, not the vocabulary itself. You do not know upfront what entities and relations your extraction pipeline will surface. A constrained extraction vocabulary keeps the graph navigable as it grows. Imposing a full OWL class hierarchy on episodic memory is almost always premature. It encodes assumptions about what will matter before you have seen what actually matters.Semantic contract layer is where the infrastructure investment pays off. These are the validated facts that need to cross system or organizational boundaries. But this layer is not the whole memory stack. It is a promoted subset: the fraction of episodic facts that turn out to be contested, shared, or regulation-relevant enough to require a formal semantic contract.The failure mode for most teams is treating the entire episodic layer as though it were the semantic contract layer, and either over-engineering it from day one, or under-engineering it because the full infrastructure felt unjustified.Load-Bearing NounsLoad-bearing nouns: The promotion decisionMost entities and relations extracted into episodic memory stay there forever. They are episodic facts: useful in context, queryable for retrieval, but never contested across system boundaries. The supplier evaluation from last quarter, the exception granted for a specific vendor, the cost category an agent assigned to a requisition.A small subset turn out to be load-bearing. These are the nouns that appear in multiple systems, where systems disagree on the canonical definition, and where an agent making a wrong assumption causes a downstream failure. Approved Supplier. Tier 1 Capital. Preferred Vendor. Procurement Category. These are the entities that need to graduate from episodic memory to the validated semantic layer.The architecture that works in practice looks like a funnel:The memory funnel: from extraction to semantic layerThe extraction schema governs everything above the gate. Cheap, always worth doing, no infrastructure required. The semantic infrastructure governs only what passes through the gate. Expensive, conditionally worth it, proportionate to how many facts actually need cross-boundary validation.The gate is the critical design element. In a well-run procurement organization, a category manager or a data steward makes the promotion call: “this entity definition is now canonical and needs to be enforced across systems.” SHACL documents that decision in a machine-readable form any system can validate. OWL gives it a formal home. But the gate means 95% of what flows through the extraction pipeline never reaches the infrastructure layer. That is correct.The one-line test: is this entity contested by more than one system, and does the disagreement cause a production failure? If yes, promote. If no, leave it in episodic.Two Anti-Patterns to AvoidAnti-pattern 1: Ontologizing the Whole Extraction OutputA team builds a full OWL class hierarchy for every entity type the LLM might produce. Every supplier attribute gets a domain/range constraint. Every relation type gets a formal definition. The ontology document hits 800 lines before a single agent touches production data.What happens next: the ontology becomes a maintenance burden nobody has authority to update. Extraction breaks every time a new entity type appears that does not fit the predefined hierarchy. The agents that were supposed to benefit from the schema end up with custom parsing logic to work around the mismatch.The fix is the funnel. Build a lightweight extraction schema covering the 20 entity classes and 15 relation types that matter for consistent retrieval. Let the promotion gate decide which ones need to graduate to formal OWL definitions. Build the infrastructure only for what actually passes the gate.Anti-pattern 2: No Schema At AllThe opposite failure. A team building an episodic memory layer for a multi-agent procurement workflow decides a schema is premature overhead. “We’ll let the structure emerge from the data.” They cite the markdown-is-enough argument, which is correct for a single writer and a single reader. They apply it to a system with six agents writing in parallel.Six weeks in, the entity graph has Vendor, vendor, Supplier, supplier_org, SupplierEntity, and external_party all referring to the same class of real-world objects. Queries return partial results. Cross-agent retrieval fails silently. Deduplication becomes its own project.The markdown-is-enough argument holds for single-writer systems. It breaks the moment multiple agents are writing to the same episodic store without a shared vocabulary. An extraction schema is the minimum coordination layer that makes the store queryable. The cost is a YAML file and a prompt instruction. The cost of skipping it is a graph you cannot trust.The Five-Dimension Framework Applied to MemoryI covered this framework in the RDF/OWL piece. Here it applies with memory-specific precision:Scope: Is the knowledge crossing system or organizational boundaries? If episodic facts stay within a single agent system, an extraction schema is sufficient. If validated facts need to travel to partner systems or external auditors, the semantic layer earns its cost.Reasoning: Does the memory layer need to infer facts not explicitly stored? Episodic KGs almost never need a reasoner. You are storing what happened. The semantic layer may need one if class hierarchy implications must propagate automatically across a large ontology.Governance: Who approves a promoted fact? What is the expiry model for a fact that was true under a previous policy? The promotion gate needs an owner. Without one, the semantic layer accumulates stale definitions that agents trust but should not.Agent architecture: How many agents write to this store, and from how many independent systems? Single-writer systems can often get away without an extraction schema. Multi-writer, multi-system stores require one. Cross-platform coordination requires the semantic layer.Investment horizon: The extraction schema pays off in the first week of a new episodic store. The semantic infrastructure pays off over 12 to 24 months, proportionate to how many systems are consuming the validated definitions.The Honest SummaryThe extraction schema is cheap and almost always worth doing. It is the difference between an episodic memory graph you can query and one that requires constant repair. Build it before you store the first fact.The semantic infrastructure is expensive and conditionally worth it. It earns its cost when facts cross boundaries, require formal inference, or need portable validation that external parties can execute. The five-dimension framework tells you when you are in that territory.Most agent memory systems need an extraction schema. Few need full semantic infrastructure on day one. The mistake is treating those as the same decision.Build the funnel. Staff the gate. Promote only what earns it.Where I’m Still UncertainA few places I would genuinely like pushback from practitioners:Where has extraction-schema-only failed for you? The funnel model assumes a clean signal at the promotion gate. In practice, teams often do not discover that a fact is load-bearing until after a cross-system failure. If you have been burned by this, I want to know whether the failure was a gate design problem or whether the extraction schema itself needed to carry more semantic weight from the start.Is the load-bearing nouns framing too optimistic? The model assumes a minority of extracted facts need cross-boundary validation. If you are building in an environment where most extracted entities touch multiple systems from day one, the funnel inverts and the infrastructure investment probably makes sense much earlier. Counter-examples welcome. Financial instruments in a multi-custodian setup would be the obvious candidate.Is the promotion gate still manual in practice? I have not seen a team that has automated this well. If you are running an episodic KG at scale and you have a reliable signal for “this fact needs to graduate,” whether rule-based or annotation-based, I want to know what it looks like.The longer question on enterprise customization: Some will argue this whole framework breaks down for large enterprises, which heavily customize their ontologies per tenant, per line of business, per region. It is a fair challenge, and my answer is that it actually makes the argument stronger, not weaker. Enterprise customization is precisely why frontier models will not render extraction schemas obsolete. No model will internalize that this customer classifies a $50K non-catalog purchase as an “exception requisition” with a four-step approval chain unique to their organization. The more enterprise the deployment, the more the extraction schema is load-bearing, regardless of model capability. The debate does not become moot as AI improves. For enterprise use cases, it becomes more important.This is the third piece in a series on semantic infrastructure for enterprise AI. The first covered when to use RDF/OWL vs. property graphs. The second covered why multi-agent systems fail in production. If any of the above is wrong in your experience, the comments are the right place. The goal is a framework that holds up against real deployments, not one that only survives in controlled conditions.Your Agent Memory Probably Needs an Ontology -Just Not the One You Think was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.