Engineering·
What Is an Ontology for AI Agents?
By Mac Anderson
- Ontology
- AI Agents
- Knowledge Graph
- Agent Infrastructure
- MCP
- Neo4j
An ontology for AI agents is a typed, workspace-scoped knowledge graph that an agent queries for structural and semantic retrieval. The agent reads and writes the graph over an API (most often MCP), and the graph carries the entities, relationships, and types the agent reasons about. This guide defines what that means concretely, shows why agents need one, and lays out what a production ontology actually looks like — so developers evaluating whether to build or buy can make the call with open eyes.
The phrase "ontology" carries academic baggage that is not useful here. In philosophy, an ontology is a formal account of what exists. In information systems, it has been used to mean everything from "a taxonomy" to "a full first-order-logic model of a domain." For the purposes of agent infrastructure, we mean something narrower and more practical: a typed graph where entities have identities, relationships have meanings, and both can be queried deterministically. That's the working definition throughout this piece.
The working definition
An ontology for AI agents has four essential pieces. If any of them is missing, what you have is not an ontology — it might be a vector store, a document graph, or a typed database, but none of those do the job an agent ontology does.
-
Typed entities. Every node has an entity type (
Person,Organization,Document,Deal,Service) and an identity that persists across references. When "Sarah," "Sarah Chen," and "schen@acme.com" all refer to the same person, they resolve to the same entity node. -
Typed relationships. Edges between entities carry meaning. A
works_atedge is different from areports_toedge is different from amentionsedge. The agent can traverse by type, filter by type, and reason about the shape of the graph. -
Workspace scope. Every node and edge belongs to exactly one workspace. Queries filter on workspace; retrievals never cross tenants. This is not a feature — it's the constraint that makes ontologies usable for multi-tenant agents.
-
Provenance. Every fact points to its source. When a user or auditor asks "why does the agent believe this?", the answer is a graph path back to the document, email, or extraction event that produced the fact.
With those four pieces in place, the agent gets capabilities a flat vector store cannot provide: multi-hop traversal, time-bounded queries, constrained lookups, auditable answers, and workspace-isolated retrieval. Everything downstream — hybrid retrieval patterns, deterministic answers, compliance posture — builds on this foundation.
What an ontology gives an agent that embeddings alone don't
The honest framing is not "ontology vs. embeddings." Embeddings are great at what they're great at — finding chunks that feel similar to a query. An ontology is great at a different class of question: structural retrieval.
Structural recall. "Which of Sarah's direct reports worked on projects that the payments team was also involved in?" This is a three-hop traversal across two relationship types. No amount of embedding similarity can reconstruct it — the best a vector store can do is surface chunks that mention several of those nouns. Structural queries require structure.
Multi-hop traversal. Agents naturally generate queries that cross multiple entity boundaries. "What's the status of the deal my report mentioned in this morning's standup?" has four hops. In an ontology, this resolves to a single graph query that returns a deterministic answer. In a vector store, it decomposes into a sequence of lookups that compound similarity error at every step.
Temporal correctness. "Who managed the infrastructure team in Q1 2026?" depends on when you're asking. Edges in a typed ontology carry valid_from and valid_to — the traversal filter becomes a WHERE clause. Vector stores store the most-recent-seeming fact and drift when the answer changes over time.
Auditability. Every fact traces to a source. When a fact is wrong, you know which document introduced it. When a fact was updated, you see the history. For enterprise agents — where a CIO can and will ask "where did this answer come from?" — the traceability is not a nice-to-have; it's the entry price for deployment.
Deterministic answers. The same query against the same graph state returns the same result. That property sounds obvious until you realize vector retrieval does not have it — tweak the embedding model, rerank, or change the top-k threshold and yesterday's answer changes. Determinism matters for regression testing, incident response, and the kind of reproducibility that makes agents serviceable at scale.
Anatomy of a production ontology
The schema below is deliberately minimal. It's what actually ships. Teams that want to go deeper on design patterns — entity resolution strategies, temporal-edge semantics, the exact Cypher patterns for hybrid queries — should read Knowledge Graphs for Agent Memory: Design Patterns after this piece.
Nodes
Every node has:
- An ID. UUIDs scoped to the workspace. Global uniqueness is not required; workspace uniqueness is.
- A structural label.
Entity,Observation, orSource— three labels total. Fine-grained typing (person, organization, deal) lives as a property, not a label. - An entity type property. Drawn from a controlled vocabulary configured per workspace.
- A workspace id. Non-negotiable.
- Audit properties. Created-at, updated-at, confidence, soft-delete markers.
Nodes come in three kinds:
- Entities are the nouns the agent reasons about. People, companies, documents, services, accounts, deals.
- Observations are the facts the agent has extracted. "Sarah is VP of Engineering." "The deployment failed at 14:02." Observations carry embeddings for semantic retrieval and temporal properties for time-bounded queries.
- Sources are the origins. An email, a meeting transcript, a tool-call response, an API integration. Sources exist so provenance has a target.
Edges
Edges carry a relationship type as a property (works_at, mentions, depends_on, discussed), along with temporal validity (valid_from, valid_to), confidence, and a pointer to the source that produced the edge. Using a single structural edge label with typed properties — rather than N named edge types — keeps the schema stable as the extraction pipeline discovers new relationships.
Vocabulary
Entity types and relationship types come from a workspace-scoped configuration, not from free-text extraction. The extraction pipeline maps raw text to the vocabulary; if it cannot, it falls back to a generic type and flags the observation for review. This prevents type explosion — the most common slow-moving failure mode in agent ontologies that eventually makes queries impossible to compose.
When an agent needs an ontology
Not every agent does. The honest test is three questions:
-
Does the agent accumulate state? A stateless tool-caller that retrieves from a static corpus on every request is doing RAG, not memory. Ontologies model accumulated state; if the agent doesn't accumulate, there's nothing for the graph to model.
-
Do queries cross multiple entity boundaries? If every question the agent is asked is a single-entity lookup — "summarize this document," "what's the latest email from Alex?" — vector retrieval is sufficient. If questions traverse relationships — "show me every deal connected to a customer who escalated last quarter" — you need the graph.
-
Is auditability a requirement? For consumer agents, probably not. For any agent sold into enterprise, yes — and auditability is a property of the data model, not something you can bolt on later.
If two of the three are true, an ontology is earning its keep. If all three are true, an ontology is table stakes. If none of the three are true, pgvector and a good embedding model will take you further than you expect.
For the honest comparison of when each retrieval shape is right: Knowledge Graphs vs. RAG for AI Agents: When to Use Which.
Build vs. buy
Most teams considering building their own ontology infrastructure discover one of two things over the course of three to six months: either the scope of "graph infra" expands well beyond what they planned for (query-planner tuning, entity resolution throughput, workspace-isolation guarantees, backup and migration strategy), or the graph ends up being the part of the product that differentiates them and they realize they've spent six months re-implementing something they could have bought.
A useful decision framework:
- Build it yourself if graph infrastructure is the product — you are a graph-database vendor, an analytics platform, a knowledge-management company whose value proposition is the graph itself.
- Buy it if your product is the agent, and the graph is infrastructure the agent sits on.
Buying does not mean using a hosted service and giving up control. Production agent teams increasingly want ontologies with deployment flexibility: hosted for fast iteration, dedicated instances for enterprise customers, BYOC for customers with data-residency or compliance requirements. These are table-stakes asks from the CIO side of the buying committee now, not future requirements.
The engineering budget question is blunt: if you are not a graph-database company, how do you want your team spending the next six months? Writing migrations or shipping the agent?
For the set of mistakes that tend to show up when teams build ontologies without this discipline: 7 Mistakes Developers Make Building Ontologies for AI Agents.
MCP-native ontology and why it matters
The Model Context Protocol (MCP) is the emerging standard for how agents connect to data sources and tools. An MCP-native ontology exposes the typed graph as a first-class MCP data source: the agent queries entities, relationships, and traversals through the same protocol it uses for every other tool.
This matters for three practical reasons:
-
Installation is one command. Coding agents like Cursor, Claude Code, VS Code, Windsurf, and Codex install MCP servers from a single CLI invocation. If your ontology requires a custom SDK integration, you have just added a day of onboarding friction for every agent team evaluating it.
-
Typed responses flow through. MCP carries structured responses, not just text. The agent sees typed entities with their relationships, not a vector-ranked blob of chunks. The agent's reasoning improves when the retrieval layer speaks the domain's vocabulary.
-
Permission scoping composes. MCP supports scoped credentials — an agent can be given access to one workspace, or a subset of the graph, without custom ACL code on your end. Multi-tenant isolation becomes a protocol guarantee, not a query-builder invariant.
An ontology that is not MCP-native forces every agent builder to write glue code. One that is MCP-native is plug-and-play with the agent runtime they're already using.
What changes when the ontology is in place
Teams that ship an ontology-backed agent see four concrete shifts:
- Answers are deterministic. Running the same query twice returns the same result. Regression testing becomes possible. Incident response becomes tractable.
- Answers are explainable. Every claim traces to a source. "Why does the agent believe X?" resolves in under a minute instead of an hour.
- Multi-hop queries work. Questions that were previously punted ("can't do that reliably") become one-line traversals that return in under 100ms.
- Workspace isolation is a property of the data model. The agent cannot accidentally surface data from a different tenant because the retrieval layer physically cannot traverse out of scope.
Those four shifts are not UX improvements — they are the baseline an enterprise buyer is checking for before signing. Agents without them struggle to exit the prototype stage.
The short version
- An ontology for AI agents is a typed, workspace-scoped knowledge graph — entities, typed relationships, and provenance — that an agent queries for structural and semantic retrieval.
- Ontologies give agents capabilities embeddings alone cannot: multi-hop traversal, temporal correctness, auditability, deterministic answers, workspace isolation.
- Most production agents run a hybrid — structural retrieval from the graph, semantic retrieval from vector indexes on the same data.
- The build-vs-buy question resolves to whether graph infrastructure is your product. If it isn't, buy it and spend your budget on the parts that differentiate the agent.
- MCP-native matters because it makes installation one command, typed responses flow through, and multi-tenant scoping is a protocol guarantee.
Oxagen is the ontology layer for AI agents — a typed, Neo4j-backed, workspace-scoped, MCP-native knowledge graph with hybrid retrieval and first-class provenance. Read the docs to get API access and install the MCP server, or book a demo to see the patterns above running in production.
FAQ
What is an ontology in the context of AI agents?
An ontology for AI agents is a typed, workspace-scoped knowledge graph — entities with types, relationships with types, and first-class provenance — that an agent queries for structural and semantic retrieval. Unlike a flat vector index, it supports multi-hop traversal, deterministic lookups by entity ID, time-bounded queries, and auditable provenance on every fact.
How is an ontology different from RAG or a vector database?
RAG retrieves unstructured chunks by semantic similarity. An ontology retrieves typed entities and traversable relationships. RAG is great for open-ended semantic questions; ontologies are great for multi-hop, constrained, temporal, and audited queries. Most production agents need both, composed into hybrid retrieval patterns.
Does every AI agent need an ontology?
No. Stateless tool-calling agents, single-entity lookups, and consumer-scale prototypes typically don't. Agents that accumulate state, traverse relationships between entities, or need auditable answers for enterprise deployment do. The honest test: does the agent answer multi-hop questions, track time-varying facts, or need to explain where answers came from? If yes, an ontology is earning its keep.
Should I build my own ontology infrastructure or buy it?
Build it if graph infrastructure is your product (you're a database vendor, analytics platform, or knowledge-management company). Buy it if your product is the agent. Graph infrastructure is a real engineering investment — query planning, entity resolution, workspace isolation, migrations — and unless that's your value proposition, the engineering budget is better spent on the agent itself.
What does MCP-native ontology mean, and why does it matter?
MCP-native means the ontology is exposed to agents through the Model Context Protocol as a first-class data source, not through a custom SDK. Coding agents (Cursor, Claude Code, VS Code, Windsurf, Codex) install MCP servers with one command. Typed responses flow through the protocol, so the agent sees entities and relationships, not text blobs. Permission scoping composes cleanly, so multi-tenant isolation becomes a protocol guarantee.
What's the minimum ontology schema an agent needs?
Three node types — Entity, Observation, Source — and one edge type with a relationship-type property. Every node and edge carries a workspace id. Observations carry embeddings for semantic retrieval and temporal properties (valid_from, valid_to) for time-bounded queries. Every fact points to a source for provenance. This covers the essential capabilities; everything else is an optimization or a domain specialization.
Further reading
- Knowledge Graphs vs. RAG for AI Agents: When to Use Which — the decision framework for picking between retrieval shapes
- Knowledge Graphs for Agent Memory: Design Patterns — concrete schema patterns, entity resolution, traversal techniques
- 7 Mistakes Developers Make Building Ontologies for AI Agents — observable failure modes and their fixes
- Memory Architectures for AI Agents: Vector, Graph, Hybrid — the architectural comparison
- Self-Improving AI Agents: A Technical Overview — where the ontology fits in the broader agent architecture