# Ontologies as Guardrails for Agents — Frank Coyle, UC Berkeley
<!--
ref: @content/youtube/aie/2026-11-29-ontologies-as-guardrails-for-agents-frank-coyle-uc-berkeley
version: 2
updated_at: 2026-12-01T02:12:33.153Z
-->
**[Watch on YouTube](https://www.youtube.com/watch?v=438fSpJ-FjE)**
*Synthesized from Frank Coyle's talk on AI Engineer, 2026-11-29.*
Frank Coyle of UC Berkeley presents this conference talk solo; there is no host.
## Core Thesis
Frank Coyle argues that AI has developed along two historical lines: probabilistic, agent-based systems (today's LLMs) and formal, logical ontologies. Because LLMs are probabilistic "brains in a box" that do not store facts, they need symbolic constraints. His neurosymbolic recipe is "probabilistic reasoning on the inside, logical constraints on the outside." An agent loop can be treated as a data flow, with ontology-backed validation inserted between its steps. He proposes building that structure as a ladder: taxonomy, then ontology, then knowledge graph, then guardrails. Teams should start from existing vocabularies rather than a blank page.
## Key Insights
- **LLMs aren't databases.** Coyle explains that an LLM compresses the internet, books and documents into a latent space defined by embeddings, which he gives as 4,096 numbers per point. Hallucination is therefore not a defect but a built-in consequence of probabilistic generation. He compares it to human imagination about things that aren't yet real.
- **Why loops make agents powerful and worrying.** Coyle recalls the old language wars between COBOL, Fortran and Lisp. He points to the classic structured-program proof that sequence, conditionals and loops are enough for Turing-complete computation. Giving LLMs the ability to run loops gives them that same open-ended computational reach. He notes that agent builders now describe their job as writing and designing these loops.
- **Anatomy of the agent loop.** Python code turns the user's prompt into tokens and sends it to the LLM along with a list of available tools. The LLM picks a tool, for example "Use tool B, and here are the settings," because it cannot act on its own. The code runs the tool and feeds the result back. The LLM then turns that result into a polished answer.
- **Loop as data-flow diagram.** If you redraw the while-loop as a data-flow diagram (a modeling technique dating to the 1960s), you get explicit points between steps where guardrails can sit.
- **Stop reasons are control points.** Coyle lists three ways an LLM call ends:
- it finished the task;
- it ran out of tokens;
- it requested a tool call.
On a tool-use stop, you can validate the shape of the tool's input before execution. After execution, you can check that the output matches the semantics of the domain.
- **Hooks as built-in guardrails.** Claude (Anthropic) and other frontier models expose hooks that fire on lifecycle events, so guardrails don't have to live in the agent's code. The events Coyle names are:
- session start and session end;
- user prompt submission;
- permission request;
- pre-tool-use;
- post-tool-use.
He cautions that Anthropic changes these over time.
- **Ontology definition.** Coyle uses Gruber's definition: an ontology is "a formal specification of a shared conceptualization."
- **"Is a hot dog a sandwich?"** Coyle uses this question to show that the hardest part is getting an organization to agree on definitions. He tells the story of a couple whose barbecue argument started when the husband put hot dogs between slices of bread because he'd forgotten the buns.
- **The four-rung ladder:**
1. **Taxonomy:** agree on a glossary, the terms your organization uses, and their synonyms.
2. **Ontology:** define classes and attributes that support reasoning.
3. **Knowledge graph:** record the actual facts of your domain.
4. **Guardrails:** enforce constraints and rules on top.
- **Expertise doesn't need to scale.** Coyle says expert systems faded because they didn't scale. In an organization, though, the expertise already exists in-house. You can gather it top-down by hiring an expert to define terms, or bottom-up by mining the terms customers actually use.
- **"Pick-and-roll ontology."** Coyle's basketball analogy: pick terms from established ontologies, then roll to the hoop. The vocabularies he recommends borrowing from:
- **schema.org**, which covers orders, customers and other standard business concepts;
- **FOAF** ("friend of a friend"), built for social knowledge;
- **SKOS** (transcribed as "SCO"), for defining and organizing concepts;
- a **provenance** vocabulary built on three ideas: entities, the activities that generate them, and the agents (human or computer) that verify them.
- **Coyle's Onto Explorer tool.** The tool (transcribed as "TO/Anto Explorer") is on his site, Code Supreme AI, named as a tribute to John Coltrane's *A Love Supreme*. You enter a domain description, pick a sample domain or upload documents. It then lists relevant existing ontologies, each with a short description and its matching terms. In his example, FOAF matched 12 terms.
- **Hierarchies.** Ontology class hierarchies work much like object-oriented subclassing. For example, an elite client is a type of client, and a client is a type of person.
- **RDFS inference.** Declaring a domain and range for a property lets the system infer new facts. If "orders" has domain Customer and range Product, then any "X orders Y" statement implies X is a customer and Y is a product. These inferred triples build out the knowledge graph.
- **OWL property types:**
- **Transitive:** Denver is in Colorado and Colorado is in the US, so Denver is in the US.
- **Inverse:** "Anna orders a mug" also yields "mug ordered by Anna," so queries work in both directions.
- **Functional:** the property allows only one value. If two names appear, `owl:sameAs` merges them into one entity.
- **Relationships are first-class.** In relational entity-relationship diagrams, a relationship just connects two things. In a knowledge graph, a relationship such as "orders" is itself an entity that can carry properties: author, creation time and source. This gives you provenance on every connection.
- **Guardrail tool stack:**
- **Pydantic:** is the data well-formed? For example, a refund field must match a regex, and LLM output that doesn't match is caught as a validation error.
- **SHACL** (transcribed "Shackle"): does the data fit the shape? It enforces min/max counts and required fields.
- **SPARQL** (transcribed "Sparkle"): is a statement true? It queries the knowledge base.
- **SWRL** (transcribed "Swirl"): encodes logical rules and policies.
- **ODRL** (policy) and **PROV-O** (provenance): for governance.
## Actionable Takeaways
1. Model your agent's while-loop as a data-flow diagram and mark each step boundary as a candidate guardrail point.
2. In the loop, branch on the stop reason. When it's tool use, validate the tool's input shape before execution and the output's semantics after.
3. Where available, use model hooks such as Claude's pre-tool-use, post-tool-use, user-prompt-submit and permission-request events. They enforce checks without changing agent code. Recheck the current hook list, because it changes.
4. Climb the ladder in order: agree on a glossary and synonyms (taxonomy) → define classes and attributes (ontology) → load facts (knowledge graph) → add constraints and rules (guardrails).
5. Don't start from scratch. Borrow terms from schema.org, FOAF, SKOS and provenance vocabularies. Onto Explorer on Code Supreme AI can map a domain description or documents to relevant ontologies.
6. Source terms top-down from an expert, bottom-up from the language your customers use, or both.
7. Add RDFS domain/range declarations so facts can be inferred. Use OWL transitive, inverse and functional properties, plus `owl:sameAs`, to enrich the graph and deduplicate entities.
8. Attach author, timestamp and source to relationships so every connection carries provenance.
9. Layer the validators: Pydantic for well-formedness, SHACL for shape and cardinality, SPARQL for truth queries, and SWRL for policy rules. Add ODRL and PROV-O for governance.
## Notable Quotes
> "Probabilistic reasoning on the inside, logical constraints on the outside." — Frank Coyle
> "Hallucinations are not a defect. They are part of the system because they are probabilistic." — Frank Coyle
> "LLMs are just brains in a box." — Frank Coyle
> "Think of the hook as a possibility for a guardrail." — Frank Coyle
> "When you eat a hot dog, think about ontology." — Frank Coyle
---
*You're reading a protocol on [protocol.supply](https://protocol.supply) — hosted, searchable knowledge for AI agents. Think Agent Skills, as an API: bootstrap once (`curl -sL https://api.protocol.supply/bootstrap`), search (`/search?q=…`), fetch (`/@repo/slug`).*
*Any skill can become a protocol, and any protocol installs as a local skill — tell your agent "install this as a skill" or see [`@protocol/protocol-to-skill`](https://api.protocol.supply/@protocol/protocol-to-skill).*