Ontology for AI Agents
Learn to turn a messy business domain into a precise model an AI agent can reason over, act within, and share with other systems. No philosophy history, no unnecessary formalism.
What you should be able to do after this course
Model a domain
Identify entities, types, attributes, relations, roles, states, events, constraints and boundaries.
Design an agent world model
Separate facts, rules, tools, permissions and actions so an agent knows what exists and what it may do.
Spot weak models
Detect ambiguity, duplicated concepts, hidden assumptions and unstable identifiers before they become agent errors.
Build a first ontology
Produce a compact ontology for a real business process and test whether it is good enough to implement.
Ontology in one sentence
An ontology answers three practical questions:What exists? What kind of thing is it? How can things relate?
Ontology is not the same as a taxonomy
| Artifact | Main question | Example |
|---|---|---|
| Glossary | What do words mean? | “Customer” = legal or natural person buying from us. |
| Taxonomy | How do we classify things? | Product → Adhesive → Cyanoacrylate. |
| Database schema | How is data stored? | customer_id, credit_limit. |
| Ontology | What exists and how is it related? | A Customer owns Stores, places Orders, has Credit Terms, and may be under Delivery Stop. |
Minimal ontology pattern
TYPE: Customer INSTANCE: Acme Retail Ltd. ATTRIBUTE: credit_limit = 50,000 RELATION: Customer OWNS Store STATE: Customer HAS delivery_status = STOPPED EVENT: PaymentReceived RULE: PaymentReceived MAY_CHANGE delivery_status
Ask the tutor
Entities, types, instances and identity
Entity
A thing you need to reason about independently: Customer, Order, Invoice, Store.
Type
A class of things sharing rules or structure: Customer, Employee, Product.
Instance
One specific member: Order #A-1048.
Attributes vs entities
If something has its own identity, lifecycle, relations or history, it usually deserves to be an entity rather than a text field.
store = "Paris 17".Stronger:Store is an entity with address, opening date, manager, sales history and relation
OWNED_BY Customer.Identity is an operational decision
Every important entity needs an answer to:What makes this the same thing over time?
- A customer changes name: same customer if legal identity/tax ID is unchanged.
- A store moves: maybe same store if your business treats it as continuous; maybe new location entity if place matters independently.
- An employee changes role: same Person, different RoleAssignment.
Ask the tutor
Relations, roles, states, events and time
Relations carry meaning
Prefer explicit relation names that describe semantics, not vague links.
Weak
Customer — linked_to — ManagerStrong
Manager — RESPONSIBLE_FOR — CustomerAccountRole ≠ identity
A role is contextual and can change. “Approver,” “Sales Manager,” “Buyer” and “Account Owner” usually belong in role assignments, not as permanent types of person.
State ≠ event
| Concept | Meaning | Example |
|---|---|---|
| State | What is true during an interval | Delivery is STOPPED |
| Event | Something that happens | PaymentConfirmed |
| Process | Ordered activity over time | Credit Review |
Ask the tutor
Constraints, boundaries and model quality
Constraints turn a vocabulary into a usable model
Examples:
- Every Order belongs to exactly one Customer.
- A CreditLimit must have currency and effective date.
- A DeliveryStop may be released only by an authorized role.
- An Invoice can be overdue only after its due date.
Cardinality
Customer 1 — places — 0..N OrdersOrder 1 — belongs_to — 1 CustomerCardinality exposes missing assumptions that natural language hides.
Boundary discipline
Do not model the whole company. Model only what the agent needs to distinguish, reason about or act upon.
Five quality checks
- Uniqueness:can entities be identified reliably?
- Non-ambiguity:does each important term have one operational meaning?
- Completeness:are required decision concepts represented?
- Consistency:do constraints contradict each other?
- Minimality:did you avoid modeling irrelevant complexity?
Ask the tutor
Ontology as an agent’s world model
A prompt tells an agentwhat to do. An ontology tells itwhat the world contains and what its statements refer to.
Prompt
“Assess whether this customer’s credit limit should be increased.”
Ontology
Defines Customer, Account, CreditLimit, Turnover, Store, Order, ConditionChange, Evidence, Decision and their relations.
Agent reasoning loop
Observe data → map data to ontology concepts → construct current world state → detect missing facts → retrieve/call tools → apply rules/policies → choose allowed action → record outcome + explanation
Three layers to keep separate
| Layer | Example |
|---|---|
| World model / ontology | Invoice, due date, payment, customer, delivery stop |
| Decision policy | If overdue_days > 10, stop delivery unless exception is approved |
| Agent procedure | Fetch invoices → calculate overdue days → check exceptions → recommend action |
Ask the tutor
Connect ontology to data, tools, rules and actions
Map ontology concepts to real systems
| Ontology concept | Possible source/tool | Agent use |
|---|---|---|
| Customer | CRM / ERP | identity, hierarchy, account owner |
| Invoice | ERP | amount, due date, status |
| PaymentEvidence | bank feed / uploaded file | supports release decision |
| ApprovalAuthority | IAM / policy table | limits allowed actions |
Tool contracts should use ontology terms
get_data(id)Strong tool:
get_open_invoices(customer_id)returning Invoice objects with IDs, due dates, currencies and payment status.Actions need preconditions and consequences
ACTION: ReleaseDeliveryStop PRECONDITIONS: - DeliveryStop exists and is ACTIVE - actor has ReleaseAuthority - evidence satisfies current policy EFFECT: - DeliveryStop becomes RELEASED - Decision record is created - reason and evidence are linked
Ask the tutor
Memory, knowledge graphs and multi-agent systems
Memory should store facts about entities, not just text
Unstructured memory: “Acme had a discussion about delayed payment last month.”
Structured memory:PromiseToPay(customer=Acme, amount=25,000, promised_date=2026-08-25, source=email_184).
Knowledge graph = ontology + instances + relations
The ontology defines what the graphmay mean. The graph contains actual facts.
Acme → OWNS → Store_17Invoice_881 → ISSUED_TO → AcmePayment_402 → SETTLES → Invoice_881Multi-agent systems need shared semantics
If one agent uses “customer” to mean legal entity and another uses it to mean delivery location, handoffs will fail even when both models are individually capable.
Provenance is part of trustworthy memory
Important facts should retain source, timestamp, confidence/status and—when relevant—who asserted or approved them.
Ask the tutor
Build and test an ontology for an agent
The 9-step build method
- Define the agent’s decision/action scope.
- List the questions it must answer.
- Extract nouns → candidate entities/types.
- Extract verbs → candidate relations/actions.
- Separate attributes from independent entities.
- Define identity and time semantics.
- Add states, events, constraints and permissions.
- Map each important concept to a data source/tool.
- Test against real and adversarial cases.
Competency questions
An ontology is only useful if it can answer the questions the agent needs. Write these questionsbeforeover-modeling.
• What is the customer’s current approved credit limit?
• When did it become effective?
• What evidence explains the recent increase in orders?
• Is the requested action within the manager’s authority?
• Which unpaid invoices are causally relevant to the stop?
Adversarial tests
- Same name, different customer.
- One customer with multiple legal entities.
- Payment evidence exists but payment is not confirmed.
- Historical credit limit differs from current limit.
- Rule changed yesterday.
- Agent receives contradictory data from two systems.
Ask the tutor
Ontology Builder Canvas
Use this while taking the course. It saves automatically in your browser.
Final exam — 100 points
Scenario:A company wants an AI agent to review requests to temporarily release a delivery stop for customers with overdue payments. A manager submits a request with a reason and evidence. Evidence may be a bank payment confirmation, a copy of a payment order, a written promise to pay, or an agreement to pay on delivery. The agent may recommend release, refusal or escalation, but only authorized humans can execute the release.
Q1 — Domain model20 points
Define the minimum useful entities/types and the key relations between them. Explain any concept you deliberately keep as an attribute rather than an entity.
Q2 — Identity, states and time20 points
Define identity for Customer, Invoice and PaymentEvidence. Then define the important states/events and which facts must be time-aware.
Q3 — Ontology vs policy vs procedure20 points
Give at least 3 examples of ontology facts, 3 policy/rule statements and 3 procedural/tool steps. Keep the three layers clearly separated.
Q4 — Agent action design20 points
Design the actionRecommendReleaseDeliveryStop: inputs, preconditions, outputs, evidence/provenance requirements and failure/escalation conditions.
Q5 — Testing20 points
Give 5 adversarial test cases that could cause a weak ontology or agent to make the wrong recommendation. For each, state what modeling feature prevents the failure.
Local LLM connection
This course uses the same protected server-side LLM proxy as the Sales LLM Lab. No model endpoint, bearer token or API key is exposed in the browser.
/sales/api/ask_agent2.phpThe browser sends only
instructionsandinput. The existing PHP proxy forwards the request through your server-sidellm_config.php.
Agent Ontology Checklist
- What decisions/actions is the agent responsible for?
- What entities must exist for those decisions?
- How is each entity identified?
- Which distinctions are types, roles, attributes, states or events?
- Which relations matter?
- Which facts change over time?
- What constraints/cardinalities must always hold?
- Which statements are ontology vs business rules?
- Where does each fact come from?
- What tools expose those facts/actions?
- Who is allowed to execute which actions?
- What provenance must be retained?
- Can every competency question be answered?
- What adversarial cases break the model?