# Ontologies as Guardrails for Agents — Frank Coyle, UC Berkeley

## Executive summary

This talk introduces the concept of Neurosymbolic AI, which combines probabilistic Large Language Models (LLMs) with formal logical systems (ontologies) to establish guardrails. Because LLMs operate in a multi-dimensional latent space and are not 'fact machines,' ontologies—which define shared conceptualizations—are necessary to ensure domain compliance, especially when agents execute tool calls. The speaker details how guardrails can be implemented within the agent loop using tools like Pydantic, SHACL, and SPARQL.

## Key takeaways

- The Need for Guardrails: LLMs, while powerful, are probabilistic and do not store facts; they operate in a latent space. This means they can produce valid tool calls that still violate domain rules, necessitating external logical constraints.
- Neurosymbolic AI: This paradigm combines the agentic AI universe (probabilistic reasoning) with formal logical systems related to ontologies (logical constraints).
- The Agent Loop as Data Flow: The agent loop can be viewed as a data flow, allowing guardrails to be inserted between steps (e.g., before and after tool execution) to validate input shapes and semantic results.

## Technical details

- Ontology Construction Hierarchy: The process moves from Taxonomy (agreeing on a glossary and terms) to Ontology (defining classes and attributes that enable reasoning) to Knowledge Graph (the actual facts and details of the domain).
- Formal Logic Tools: RDFS (Resource Description Framework Schema) is used to define relationships (e.g., 'orders') and infer new sets of triples. OWL (Web Ontology Language) allows for advanced reasoning, such as defining transitive or inverse properties.
- Guardrail Mechanisms: Validation is achieved using specific tools: Pydantic (catching validation errors based on regex), SHACL (checking the shape of JSON data), and SPARQL (querying the knowledge base).
- LLM Hooks: Frontier models (like Claude) offer 'hooks' (e.g., pre-tool use, post-tool use) which allow external services to be notified and perform processing without modifying the core code.

## Practical implications

- Build engineers can use ontologies to enforce strict data contracts and domain rules on LLM-driven agents, moving beyond simple API calls to semantic validation.
- The concept of 'relations as entities' in Knowledge Graphs allows for richer provenance tracking (who, when, source) for every data relationship.
- Integrating guardrails into the agent loop provides a structured way to manage the transition from probabilistic LLM output to deterministic, validated action.

## Topics

AI, Knowledge Graphs, Semantic Web, Agentic Systems, Data Validation, TO Explorer, schema.org, FOAF (Friend of a Friend)

Source: https://www.youtube.com/watch?v=438fSpJ-FjE
