E2E Testing for Chat, Voice, Phone and Video AI Agents

Run Thousands of Test Scenarios against Your Agent and Catch Hallucinations, Bias, and Toxicity Before Users Do.

Ontology in AI: Definition, Examples and How to Test Grounded Agents

Ontology in AI defines business terms, relationships and rules so agents query data correctly. See examples, NVIDIA Auto Ontology, and how to test agents.

Published

Summarise with AI

An ontology in AI is a formal, machine-readable model of a domain: its entities, how they relate to each other and the rules that always hold. AI agents use an ontology to translate a natural language question into the correct query. A good ontology increases the likelihood of a correct answer and you can test whether the answer is in fact correct.

Key facts (checked 29 Nov 2026)

  • An ontology has classes, instances, properties, relationships and axioms (rules).
  • The W3C standards used with ontologies are RDF and OWL 2, and SHACL for data validation. SKOS is for taxonomies and thesauri.
  • NVIDIA has open-sourced Auto Ontology (a Python framework under the Apache-2.0 license) which has 17.1k stars on GitHub.
  • Auto Ontology provides business definitions to agents via MCP (a CLI and a REST API).
  • An agent can return valid SQL with the wrong number of columns. A check against a trusted source will catch that. A catalog check won't.

TL;DR

An ontology in AI is a formal, machine-readable model of a domain: its classes, instances, relationships and rules, plus the metric definitions and column mappings a data agent needs. Agents use it to translate a business question into the right query, and you still test each answer against a trusted system of record.

Is a Knowledge Graph the Same as an Ontology?

  • Knowledge graph vs ontology: A knowledge graph stores facts about real entities as nodes and edges, such as Brightline GmbH having invoice INV-88231. The ontology is the blueprint those facts follow, so knowledge graphs in AI systems are usually shaped by one.
  • Ontologies and taxonomies: A taxonomy orders categories in a parent-child tree, such as Region, EMEA, DACH and Germany. An ontology adds typed relationships and rules, such as a refund reversing an invoice and test accounts never counting as customers.
  • Ontology vs semantic layer: A semantic layer defines metrics and dimensions that compile to SQL for BI tools and agents. A full ontological model also covers the relationships between entities and the rules that hold across systems.

Does an Ontology Stop AI Hallucinations?

  • Data ontologies for agents: Business ontologies map each term to warehouse columns, so a text-to-SQL agent stops guessing what "revenue" means. Without an ontology, valid SQL can still return the wrong figure, such as an illustrative $4.82M against the $4.31M Finance reports.
  • Ontology examples: A finance ontology that defines net revenue as invoiced amount minus refunds and credits, by service period, in USD, with test accounts excluded, is a private example. The Gene Ontology and the schema.org vocabulary are public ones.
  • Testing grounded answers: Stale mappings, conflicting definitions and out-of-scope questions still produce confident wrong figures. TestMu AI's Agent Testing checks the facts a chat or data agent states against your own API and returns a Green, Yellow or Red go-live verdict.

What Is an Ontology in AI?

An ontology in AI is essentially a rulebook that the software can read. It defines what a term like 'revenue', 'active customer', or 'EMEA' means in your organization, where the data for that term is stored and what the rules are that always apply.

The term comes from philosophy (ontology being the study of what exists) and has been adopted by library science and computer science in the context of vocabularies. Salesforce's design team defines an ontology as "a system for organizing information so computers can understand and use that data". For AI and data teams, the definition is a little more restricted: an ontology is the layer that maps business language to data.

An ontology models the meaning and is entirely separate from the data. The data resides in Snowflake, Postgres or BigQuery. The ontology is the thing that describes what the tables mean.

What Are the Components of an Ontology?

An ontology has the five standard parts: classes, instances, properties, relationships and axioms. Data teams building for agents will typically add in metric definitions and mappings to physical tables as well.

The table is based on one fictional company throughout the article. Halvard is a fictitious B2B software company. All of the names, tables and figures are illustrative.

ComponentWhat it isHalvard example
ClassA type of thingCustomer, Invoice, Refund, Region, Segment
Instance (individual)One real member of a classAccount 1042, "Brightline GmbH"
Property (attribute)A value a thing carriesInvoice.amount, Invoice.currency, Invoice.service_period
RelationshipHow two things connectCustomer hasInvoice Invoice; Refund reverses Invoice; Region partOf Region
Axiom (rule)A statement that must always holdEvery invoice belongs to exactly one customer. Test accounts never count as customers.
Metric definitionA business formula with an ownerNet revenue = invoiced amount minus refunds and credits, by service period, in USD. Owner: Finance.
MappingWhere each term lives in the warehouseInvoice.amount → billing.invoices.amount_cents / 100; test account → crm.accounts.is_test
Synonyms and exclusionsWords people use, and words that mean something else"Sales" and "top line" → net revenue. "Bookings" is a separate metric and never a synonym.

The last three rows are where most of the agent errors occur. A class list with no metric definition leaves the agent to work out what 'revenue' is. Each of those guesses results in some SQL being run.

Salesforce's article goes through the identical elements with a healthcare example: John Doe is an instance of the class Patient, Patient is a subclass of Person, and one of its axioms states that each patient has at most one primary physician. Halvard's axioms do the same thing in the finance domain.

Ontology graph for an illustrative company showing Customer, Invoice, Refund and Region classes and the net revenue rule

Ontology vs Taxonomy vs Knowledge Graph vs Semantic Layer

An ontology defines the meaning and the rules. A taxonomy is about the hierarchy of things. A knowledge graph is the actual graph of facts.

A semantic layer is the layer that defines the metrics for BI and the query tools. A database schema is the way the tables in the database are structured to store the data.

ConceptWhat it modelsStructureWho uses itHalvard example
OntologyMeaning: classes, relationships, rules, metric definitionsGraph of concepts plus logical axiomsData architects, AI agents, knowledge engineers"A refund reverses an invoice. Test accounts are excluded from net revenue."
TaxonomyCategories and parent-child orderTree (hierarchy)Content, catalog and search teamsRegion → EMEA → DACH → Germany
Knowledge graphReal facts about real entitiesNodes and edges, often shaped by an ontologySearch, recommendation and RAG systems"Brightline GmbH is located in Germany and has invoice INV-88231."
Semantic layerMetrics and dimensions for queriesMetric and dimension definitions compiled to SQLAnalytics engineers, BI tools, AI agentsnet_revenue metric in a tool such as dbt Semantic Layer or Cube
Database schemaStorage: tables, columns, types, keysTables and foreign keysDatabase engineers, applicationsbilling.invoices(id, account_id, amount_cents, currency, invoice_date)

A knowledge graph is typically governed by an ontology (the ontology is the blueprint and the graph is the building). Property graph teams often don't go through the formality of defining an ontology.

A semantic layer is essentially an ontology on metrics. An ontology also defines the relationships between entities and the rules that cross systems.

Salesforce's article takes knowledge systems from picklist through to taxonomy, to thesaurus and on to ontology. Each stage brings a layer of richer relationships. The W3C has published SKOS (2009) for the taxonomy and thesaurus end of that range.

Comparison of taxonomy, ontology, knowledge graph, semantic layer and database schema using one revenue example

How Do Ontologies Enable AI to Reason?

Ontologies allow AI to reason through encoding rules that a reasoner can then apply to derive facts that nobody has actually stored. Two of the more common OWL constructs are subclass rules and transitive properties.

Halvard's ontology makes partOf a transitive relation. There are two facts in the data: Germany is part of DACH and DACH is part of EMEA. The reasoner then concludes that Germany is part of EMEA.

If you ask for EMEA revenue, you get the Brightline GmbH invoices in there even though there's no fact that says Brightline is in EMEA. The Salesforce healthcare example is the same: the machine works out that John Doe, a patient, is also a person.

A plain text-to-SQL agent gets no inference at all. If crm.accounts.region is "DACH", then a filter on region = 'EMEA' will silently exclude Germany. To avoid that, you need the ontology, the mapping or a region hierarchy table to contain the rule.

Ontology reasoning example where Germany is inferred to be part of EMEA through a transitive partOf rule

Why Do AI Agents Need an Ontology?

AI agents need an ontology because a database schema only tells you where the data is. The schema tells you nothing about what the data means.

A text-to-SQL agent will simply pick the columns that look right. The SQL will execute, and the number will be wrong.

Text-to-SQL is still well short of human accuracy on the public benchmarks. As of 28 Nov 2026, the top execution accuracy entry on the BIRD leaderboard (the overall leaderboard) achieved 83.40% on the test set compared to 92.96% for human performance. Your warehouse will have its own definitions, so a benchmark score doesn't necessarily tell you how the agent will perform on your own data.

A syntax error is picked up immediately. A query that runs and returns a figure that is at least plausible can make it to a board deck. The catalog check will pass the query as all the tables and columns it references do exist.

A Worked Example: Valid SQL, Wrong Number

A Halvard finance manager asks the company's data agent a question. All names and numbers below are illustrative.

What was net revenue from EMEA enterprise customers in Q3 2026?

Without an ontology, the agent finds columns named amount_cents and invoice_date and writes:

-- Illustrative: runs without error, and the answer is wrong
SELECT SUM(i.amount_cents) / 100.0 AS net_revenue
FROM billing.invoices i
JOIN crm.accounts a ON a.id = i.account_id
WHERE a.region = 'EMEA'
  AND a.segment = 'Enterprise'
  AND i.invoice_date BETWEEN '2026-07-01' AND '2026-09-30';

The query returns $4.82M, and Finance reports $4.31M. The query has five faults, and none is a syntax error:

  • Refunded invoices still count, as they're not taken into account by the query at all (the query ignores billing.refunds).
  • Test accounts are included because nothing says is_test = true rows are excluded.
  • The date filter is invoice date; Finance is using service period to calculate revenue.
  • Mixed currencies are simply added up as if they were all in USD.
  • Accounts stored under 'DACH' drop out as the region hierarchy isn't applied.
Valid SQL that returns the wrong net revenue because it ignores refunds, test accounts, service period, currency and region hierarchy

With an ontology, "net revenue" maps to Finance's definition. That definition includes the refund join, the test account rule, the service period date, the currency conversion and the region hierarchy. The agent now has a genuine opportunity to return $4.31M.

This example also illustrates where an ontology draws the line. Suppose the mapping for service_period points to a column that was renamed in the last sprint. The agent will still respond with confidence.

You only get to know whether the answer is actually correct by checking it against a source of truth external to the agent (e.g., Agent Testing, which checks the facts that the agent is stating against your own API).

Note

Note: Can you ship a data agent or a chat agent? Book an Agent Testing demo to validate the figures your agent cites in conversation against your own API prior to the customer seeing them.

What Ontology Means for Agent Experience Design

Salesforce positions ontology as a design issue for agentic products (Madonnalisa Chan, Salesforce, Apr 2025)[3]. The agent needs information that is consistently labeled and linked in a machine-readable form.

Salesforce refers to this layer as being invisible but absolutely critical. Spotify's genre/artist relationships and Netflix's genre/actor/producer relationships are the basis of their recommendations.

For a data agent, the design choice is manifested in one behavior. If the ontology has two definitions of revenue, the well-designed agent will ask which one you mean, or will name the one it has used, and your test suite should be checking for that behavior.

When Several Agents Share One Ontology

Several agents can share one ontology. A finance agent and a support agent would both mean 'active customer', for example. A single definition change would impact all agents at once, so of course it would need approval of all the agent owners.

How Does an Ontology-Grounded Agent Work?

An ontology-grounded agent will look up the business term prior to forming the query. It will resolve each term to a definition and a mapping, generate the SQL from that, do the checks and return the answer with the SQL and the steps that it took to get there. NVIDIA Auto Ontology is a good example of this in the open-source world (17.1k stars as of 29 Nov 2026).

NVIDIA Auto Ontology, Described From Its README

The Auto Ontology repository calls the project "a Python framework for building semantic, graph-based reasoning layers over data." The framework is licensed under Apache-2.0 and had 1.5k forks on 29 Nov 2026. The README groups its features into five steps:

StepWhat the README says it does
DiscoverGenerates enterprise ontologies from metadata, connects existing ontologies and semantic models, and builds knowledge graphs
GroundGives agents business meaning for metrics, entities and relationships, and reconciles inconsistent definitions across systems
ValidateTests a draft with real questions before experts certify it, checks generated queries against the catalog, and returns SQL and steps with each answer
ExposeServes context to agent harnesses through MCP, a CLI and an API
LearnFolds certified corrections and usage back into the ontology

As per the README, experts certify the names, descriptions and attributes and certified elements are marked as reviewed. The MCP server is read-only, and every call is run under the permissions of the signed-in user. The tools available are check_readiness, search_terms, get_term, describe_table, check_answerable ("does the ontology cover this question") and ask_question.

The README states that ask_question returns the answer, the SQL and the rows. There is a REST endpoint (POST /api/chat/completions) which streams the answers as server-sent events. The README shows the way to start the MCP server up as follows (with the AUTO_ONTOLOGY_API_URL variable set first in that example):

uvx --from "git+https://github.com/NVIDIA/auto-ontology.git#subdirectory=mcp" auto-ontology-mcp

The README lists eleven engines: PostgreSQL, MySQL, Databricks, Snowflake, ClickHouse, Trino, Google BigQuery, Apache Kyuubi, HeavyDB, DuckDB and SQLite.

The README also states that Auto Ontology "leads on" the BIRD-Interact and BEAVER text-to-SQL benchmarks. The page shows "#1" badges but no scores, so treat the ranking as NVIDIA's own assertion until the scores are published.

There's a separate auto-ontology-eval repo which runs the same reasoning model both with and without the ontology on NeMo Gym. The scores for both are determined by deterministic execution match against the benchmark answers.

What the Built-In Checks Cover, and What Testing Adds

Auto Ontology deals with a number of failure modes prior to any answer being returned. Expert certification ensures that each definition is correct when it's approved.

There's a check_answerable flag which will flag up any questions that fall outside the scope of the ontology. The catalog check will catch any SQL that's pointing at tables or columns that don't exist. It returns the SQL and the steps so that every answer is fully auditable.

Those checks are against the ontology's own view of the business. Certification happens once when a definition is approved. The data, the mappings and the definitions are all going to be changing after that point so independent testing is done on every release against a trusted system of record to catch any drift that the certification itself can't see.

How Do You Build and Govern an Ontology for AI Agents?

Build an ontology from the questions your agents need to answer and start small. Govern it like code: each definition has an owner, a version, a review and a test.

  • Collect the real questions. Pull 50 to 200 questions from Slack, BI requests and support tickets. Those become your test set.
  • Pick the terms that those questions use. Start with 20 to 40 metrics and entities (e.g., revenue, active customer, churn).
  • Write each definition with its owner. Finance owns net revenue, and Sales owns pipeline. If there's a dispute between the two, record both as separate terms.
  • Map the terms to the physical columns. Generate the draft from the metadata using something like Auto Ontology. A human then goes through and reviews and certifies every mapping.
  • Add the rules. Exclusions (test accounts), cardinality (a single primary owner per account), hierarchies (DACH part of EMEA), units and calendars.
  • Choose a format. For teams who need formal logic, you'd use the W3C standards: RDF 1.1 (2014) for the statements, OWL 2 (2012) for the classes and axioms and SHACL (2017) to validate the data against shapes. Many data teams will just use YAML in a semantic layer tool.
  • Version and review it. Changes go via pull requests, and each merge will re-run the question set.
  • Lock down access. Agents should be querying with the user's permissions (i.e., exactly as the Auto Ontology MCP server does). Watch data egress too, as the README makes it clear that optional KumoRFM predictions will upload connected tables to a hosted service.

How to Choose an Approach

Pick the lightest approach that will cover your agents' questions.

ApproachFits when you needLimits
Schema docs and a data dictionaryOne team, a few dozen tables, simple metricsAgents get descriptions with no enforced rules or hierarchy
Semantic layer (dbt Semantic Layer, Cube, AtScale)Metric consistency across BI and agentsStrong on metrics, weaker on entity relationships and cross-system rules
Formal ontology (OWL/RDF, SHACL)Reasoning, cross-system integration, regulated domainsNeeds modeling skills and tooling
Generated ontology (NVIDIA Auto Ontology)Large estates where hand-modeling every term is too slowDrafts still need expert certification and ongoing tests

How Do Ontologies Fail in Production?

Ontologies fail when the definitions, mappings and permissions are out of step with the real business and the agent is still going on with confidence. The table below lists the common failure modes and how to detect each one prior to release.

Failure modeWhat goes wrongHow to detect it before release
Definition driftFinance changes "active customer" from 30 to 90 days. The ontology still says 30, so counts come out too high.Re-run the question set on every definition change, and compare answers with the owning team's current report or API
Conflicting definitionsSales and Finance both define "revenue". The agent picks one or blends them.Ask the same question phrased the way each team asks it. Expect the agent to ask which one, or to name the definition it used.
Stale mappingsA renamed column leaves the mapping pointing at an old table that still exists. The SQL runs on stale data.Compare answers with live values from the system of record. A query that runs proves little.
Synonym collision"Bookings" is mapped as a synonym for revenue, so a bookings question gets a revenue answerAdd negative tests where the right answer is a different metric
Unanswerable question answered anywayNo definition exists for "gross margin", so the agent invents oneAuto Ontology's check_answerable is designed for this case. Still test out-of-scope questions end-to-end: a pass is a refusal or a clarifying question, never a number.
Missing hierarchyregion = 'EMEA' drops accounts stored as "DACH"Pin known-answer questions at each level of the hierarchy
Permission leakA service account returns rows the user can't see, or identity headers are trusted without verificationRun the same question as users with different roles and compare the rows. Auto Ontology's README warns that its backend trusts the forwarded identity header and that its ingestion endpoints have no authentication of their own. Keep those ports private.
Calendar or unit mismatchFiscal Q3 is confused with calendar Q3, or cents with dollarsPin known-answer questions that cross a fiscal boundary or a currency

How Do You Test an Ontology-Grounded Agent Prior to Release?

Test an ontology-grounded agent the way you'd audit a financial report. Ask it questions that have known answers and then cross-check the answers it gives against a source of truth that it didn't generate.

TestMu AI is of the view that no model should be checking its own work and that every judgment needs to be backed up by evidence. Agent Testing is the application of that principle to chat, voice and phone agents.

To use it with a data agent, you need the agent to be answering via a chat interface or an HTTP endpoint, and you need an API that returns the 'trusted' figure (e.g., a finance reporting API). Here's a pre-release checklist for ontology-grounded agents, mapped to the features documented on 28th November 2026:

  • Load the definitions as ground truth. Upload your metric definitions and data dictionary to the project knowledge base. TestMu AI's chat agent docs state that the knowledge base is "used as the ground truth" for scenario generation, conversations and evaluation.
  • Check the stated facts against your API. Data Validation checks the facts that an agent states during a conversation against your own API and gives each fact a Pass, Fail or Cannot verify verdict. The docs examples are prices, order statuses and delivery dates. For a data agent, you'd want to make sure your API returns the same figure as the one that's defined in the ontology.
  • Re-run on every definition change. Re-run the same scenarios after any change to a definition, mapping or synonym and compare scores run by run.
  • Add ontology-specific questions. Include the conflicting definition, synonym, hierarchy and out-of-scope questions from the failure table. Agent Testing will also generate scenarios across behavioral categories.
  • Score hallucination on every run. Hallucination Detection is one of the nine quality metrics on chat and voice runs and will detect any false, fabricated or unsupported information.
  • Push it to invent. Red teaming includes a 'hallucination' attack as one of its attack types.
  • Gate the release. The results will roll up into a Green, Yellow or Red go-live verdict, and each verdict will link back to the conversation turns behind it. For full release criteria, see AI agent validation before release.
TestMu AI Agent Testing evaluation result for a chat scenario showing the pass status, overall score, quality metrics including Hallucination Detection, and the conversation turns

Agents That Call Other Agents

When another agent calls the ontology's MCP tools, no human looks at the answer before it's used. TestMu AI's Agent Assurance (by Rook) covers that agent-to-agent scenario. Rook queries both local and remote MCP servers to establish what tools are available and then derives a test suite from your code or spec.

The Agent Assurance page states, "Each verdict quotes the evidence it rests on". Rook assesses the change that the agent made to the target system and reports anything it can't verify as unverifiable. Rook runs in CI with a JSON report.

Where TestMu AI Fits, and Where It Doesn't

TestMu AI doesn't build ontologies, model data, or run a semantic layer. For that sort of thing, you want to look at NVIDIA Auto Ontology, data catalogs (Atlan, for example), semantic layers (dbt Semantic Layer, Cube, AtScale), graph platforms (Neo4j) or Palantir Foundry's Ontology. TestMu AI has no partnership or integration with NVIDIA or Salesforce.

Agent Testing doesn't in any way replace evals. Offline evals and benchmarks (e.g., BIRD) assess model and prompt quality across a dataset. Agent Testing is the thing that decides whether one version of your agent on your data is ready to go.

For the split, see our guide on the difference between AI evals and agent tests. If your agent is pulling its answers from documents rather than a warehouse, then you'd use chatbot testing to check that the answers are in fact in the documents. For the wider practice, see our complete guide to AI agent testing.

Conclusion

Start with the 50 to 200 real questions your agents already get, and write down the trusted answer for each one before you model a single term. Build the ontology for the terms those questions use, then re-run the same set on every definition, mapping or synonym change and compare each figure with the owning team's system of record.

Ready to test your data or chat agent before release? Book an Agent Testing demo and get a Green, Yellow or Red go-live verdict, with the facts your agent states checked against your own API.

Testing an AI agent? TestMu AI's Agent Testing validates chat, voice and IVR agents before your customers talk to them.

To run your first test, start free, or
for a full walkthrough of the product.

Was this helpful?

Authors

Shahzeb Hoda

Shahzeb Hoda

Author · 14 posts

Shahzeb Hoda is the Associate Director of Marketing and a Community Contributor at TestMu AI, leading strategic initiatives in developer marketing, content, and community growth. With 10+ years of experience in quality engineering, software testing, automation testing, and e-learning, he has authored and reviewed 70+ technical articles on software testing and automation. Shahzeb holds an M.Tech in Computer Science from BIT, Mesra, and is certified in Selenium, Cypress, Playwright, Appium, and KaneAI. He brings deep expertise in CI/CD pipeline automation, cross-browser testing, AI-driven testing practices, and framework documentation. On LinkedIn, he is followed by 3,700+ engineers, developers, DevOps professionals, tech leaders, and enthusiasts.

Himanshu Sheth

Himanshu Sheth

Reviewer

Himanshu Sheth is the Director of Marketing (Technical Content) at TestMu AI, with over 8 years of hands-on experience in Selenium, Cypress, and other test automation frameworks. He has authored more than 130 technical blogs for TestMu AI, covering software testing, automation strategy, and CI/CD. At TestMu AI, he leads the technical content efforts across blogs, YouTube, and social media, while closely collaborating with contributors to enhance content quality and product feedback loops. He has done his graduation with a B.E. in Computer Engineering from Mumbai University. Before TestMu AI, Himanshu led engineering teams in embedded software domains at companies like Samsung Research, Motorola, and NXP Semiconductors. He is a core member of DZone and has been a speaker at several unconferences focused on technical writing and software quality.

Frequently Asked Questions About Ontology in AI

TestMu AI forEnterprise

Get access to solutions built on Enterprise
grade security, privacy, & compliance

  • Advanced access controls
  • Advanced data retention rules
  • Advanced Local Testing
  • Premium Support options
  • Early access to beta features
  • Private Slack Channel
  • Unlimited Manual Accessibility DevTools Tests