# Ontologies as Guardrails for Agents

Frank Coyle, UC Berkeley | AI Engineer CODE 2026 | 26:37

Source: https://www.youtube.com/watch?v=438fSpJ-FjE
Channel: AI Engineer (https://www.youtube.com/@aiDotEngineer). Summarised by AIE Talks.
Page: https://aietalks.com/talks/ontologies-as-guardrails-for-agents
Published: 2026-11-29
Tags: guardrails, tool-use

## TL;DR
- Agent loops make language models able to control sequences of computable actions, which creates a place for checks around tool calls.
- Ontologies add logical constraints and shared definitions around the probabilistic reasoning of an LLM.
- Pydantic, SHACL, SPARQL, policy languages, and provenance vocabularies can validate inputs, outputs, relationships, and rules.

## Summary
Frank Coyle explains why an agent can make a valid tool call and still do something that violates the rules of a domain. Large language models generate probable continuations from embeddings, so they do not look up facts in a database and can hallucinate as part of their normal operation. Agent loops give them the ability to select tools, run code, inspect results, and continue. Coyle treats that loop as a data flow with places for checks before and after tool execution. Ontologies provide the shared terms, class hierarchies, properties, and rules needed for those checks. He walks through reusing vocabularies such as schema.org and FOAF, then describes RDFS and OWL reasoning, knowledge graphs, provenance, Pydantic validation, SHACL shapes, SPARQL queries, and policy languages. He also shows how Claude Code hooks can expose events around prompts and tool calls without changing the application loop.

## Key ideas
### Agent loops give language models control over actions
[05:31](https://www.youtube.com/watch?v=438fSpJ-FjE&t=331s)
Coyle says the concern with language models is that they can loop. The Böhm and Jacopini result says a language with sequence, conditionals, and loops can compute anything that is computable. When an LLM controls such loops, it can select actions and repeat them through an agent system. Coyle connects this to Boris Cherny's description of his job as writing loops and Peter Steinberger's work designing loops that prompt agents. The issue is therefore larger than a model producing one response. The model can participate in a program that keeps taking actions.

### The tool loop has checks before and after execution
[07:44](https://www.youtube.com/watch?v=438fSpJ-FjE&t=464s)
Coyle describes the agent as a brain in a box surrounded by Python code. The code sends the user request and the available tools to the LLM. The model chooses a tool and supplies parameters, while the surrounding code executes the call and sends the result back. The loop exposes several checks. Before execution, the application can validate the shape of the input. After execution, it can inspect whether the result matches the intended semantics. Coyle presents the loop as a data flow, which makes it possible to place guardrails between its steps.

### Claude Code hooks expose guardrail points without changing the loop
[11:31](https://www.youtube.com/watch?v=438fSpJ-FjE&t=691s)
Coyle describes hooks in Claude as events that can trigger processing around agent activity. Session start and session end events cover the overall interaction. A user prompt submission creates another opportunity to inspect or transform data. Permission requests can also be handled. Pre-tool-use events fire when a tool is about to run, and post-tool-use events fire after it has run. These hooks let developers attach checks to the agent's behavior without inserting each check directly into the main application code. Coyle notes that the available events can change over time.

### An ontology starts with definitions that people agree on
[13:33](https://www.youtube.com/watch?v=438fSpJ-FjE&t=813s)
Coyle uses the question 'Is a hot dog a sandwich?' to show why domain terms need agreement before an ontology is built. Different people may use the same words with different meanings, and organizations may have multiple terms for the same thing. His proposed ladder starts with a glossary and synonyms, then moves to a taxonomy, an ontology of classes and attributes, a knowledge graph of facts, and rules that enforce constraints. The definitions are practical. A customer, product, and order need meanings that the organization accepts before software can reason over them.

### Existing vocabularies can provide a starting point
[16:21](https://www.youtube.com/watch?v=438fSpJ-FjE&t=981s)
Coyle advises teams to reuse terms from established ontologies instead of naming everything from scratch. He mentions schema.org for concepts such as orders and customers, FOAF for social-network knowledge, and SKOS for concepts and their organization. Teams can work from expert knowledge or from the language customers already use. He calls this approach the 'ontology pick and roll': pick established terms, then use them in the organization's own model. His OntoExplorer tool accepts a domain description or documents and returns related ontologies and terms that can help with naming.

### RDFS and OWL let relationships produce additional facts
[20:28](https://www.youtube.com/watch?v=438fSpJ-FjE&t=1228s)
Coyle explains that an ontology defines class hierarchies and properties. With RDFS, a relationship such as 'customer orders product' can declare that the subject is a customer and the object is a product. Those declarations support inference and add triples to a knowledge graph. OWL can describe richer property behavior. Coyle gives transitive properties as an example: if Denver is in Colorado and Colorado is in the USA, the system can infer that Denver is in the USA. Inverse properties allow 'orders' to be queried as 'ordered by', while functional properties can express that only one value is expected.

### Validation tools check different parts of an agent's work
[24:16](https://www.youtube.com/watch?v=438fSpJ-FjE&t=1456s)
Coyle assigns different jobs to several tools. Pydantic can catch data-format errors, such as a refund field that must match a regular expression. SHACL checks whether data fits a declared shape, including minimum and maximum counts. SPARQL queries relationships and asks questions of the knowledge base. A rule language can express policies. Coyle also points to provenance, where an entity, the activity that generated it, and the human or computer agent associated with it can be recorded. Relations in a knowledge graph can have their own source, creator, and creation time.

## Notable quotes
- "Probabilistic reasoning on the inside, logical constraints on the outside." (02:34)
- "Hallucinations are not a flaw. They're part of the system because they're probabilistic." (04:28)
- "You can check, you validate the shape of the input going into the tool and then when the tool does its work, you can examine the output and see if it matches the semantics of what you're doing and validate the result." (11:09)
- "So the reason this is significant is because when you're trying to build an ontology, a knowledge base, get the definitions in place and have everybody agree on the definitions." (14:43)
- "Nothing is a mistake. There's no win and no fail, only make." (25:36)

## Tools & references mentioned
- John McCarthy
- Marvin Minsky
- Willard Van Orman Quine
- Thomas Gruber
- Böhm and Jacopini
- Boris Cherny
- Peter Steinberger
- Claude
- Anthropic
- OntoExplorer
- schema.org
- FOAF
- SKOS
- RDFS
- OWL
- Pydantic
- SHACL
- SPARQL
- ODRL
- PROV-O
- Sister Corita Kent
- John Cage

## Who should watch
- You are building an agent that can call tools and need checks around tool inputs, permissions, or outputs.
- Your team uses domain terms inconsistently and needs a path from a glossary to a knowledge graph and executable rules.
- You want to connect LLM applications with validation, ontology reasoning, provenance, or Claude Code hooks.

## Related talks

- [Why Agentic Systems Need Ontologies](https://aietalks.com/talks/why-agentic-systems-need-ontologies) (Frank Coyle, UC Berkeley, 21:18)
- [Why Your Agent's Brain Needs a Playbook: Practical Wins from Using Ontologies](https://aietalks.com/talks/why-your-agents-brain-needs-a-playbook-practical-wins-from-using-ontologies) (Jesús Barrasa, Neo4j, 13:54)
- [Paving the Road to Production: Governed Enterprise AI Agents](https://aietalks.com/talks/paving-the-road-to-production-governed-enterprise-ai-agents) (Harish Gaggar, Credit Karma, 29:27)
- [Building Applications with AI Agents](https://aietalks.com/talks/building-applications-with-ai-agents) (Michael Albada, Microsoft, 15:50)
- [Scaling Agents for Gen AI Products](https://aietalks.com/talks/scaling-agents-for-gen-ai-products) (Anju Kambadur, Bloomberg, 19:38)
