Published: 2026-11-29
Summary
Summary
Guardrails inside the agent loop: hooks, Pydantic, SHACL and SPARQL checks backed by an ontology
Chapters / key moments (click to jump — plays here on the page)
The talk's argument: models reason probabilistically, so put logical constraints around them. The agent loop gives natural places to do it.
Source video
"Ontologies as Guardrails for Agents — Frank Coyle, UC Berkeley" by AI Engineer — Watch on YouTube →
Step-by-Step Breakdown
- Find the check points. Split the loop into steps: model call, stop reason, tool call, result. Validate the shape of the tool input before the call and the meaning of the output after it.
- Use the harness's hooks where you can instead of editing the loop. The talk names session start and end, user prompt submit, permission request, pre-tool use and post-tool use.
- Agree a vocabulary first (taxonomy): your organisation's terms and synonyms.
- Add the ontology (classes, properties, rules for inference), then the knowledge graph of facts.
- Borrow existing terms: schema.org, FOAF, SKOS, and PROV-O for provenance.
- Add the guardrails that test agent inputs and outputs against all of that.
Commands & Code Shown
Which tool answers which question:
Pydantic is the data well formed? (field types, regular expressions)
SHACL does the data fit the required shape? (min and max counts, required fields)
SPARQL is the claim true in the knowledge graph?
SWRL rules that express policy
RDFS domain and range, so relationships imply types
OWL transitive, inverse and functional properties, owl:sameAs
Claude Code's hook events are documented in the hooks reference; a PreToolUse hook can block a call.
Gotchas & Caveats
- Settle definitions before modelling. The talk's example is whether a hot dog counts as a sandwich.
- Hook events change between releases, which the speaker also warns about.
- The talk is conceptual: it names the tools without showing a working pipeline.
- The speaker's ontology explorer tool is his own project.





