Guardrails for AI Agents

From WFM Labs
The four rungs
1. Taxonomy
Names, synonyms and a hierarchy
2. Ontology
Kinds of thing and their relationships
3. Knowledge Graph
Recorded facts, each with a source
4. Guardrails for AI Agents
Checks on what an AI agent may do
Standards and software: Ontology Tools and Standards

Guardrails for AI agents, as the term is used in this series, are deterministic checks, run by ordinary software, that decide whether something an AI agent proposes is allowed to proceed. Some agent frameworks also use the word for checks performed by a second language model; those are outside the scope of this page. They are the fourth rung of a four-rung ladder: a taxonomy agrees the names, an ontology states what the named things are, a knowledge graph records the facts, and guardrails test an agent's proposals against all three. The principle is a division of labour, summarized as: the agent proposes and the ontology permits. A language model can read a situation and suggest an action but cannot guarantee that the action respects a rule, so the guarantee is moved to a layer that gives the same answer every time. "Ontology" in that summary is shorthand for the whole stack. Strictly, the permitting is done by validation rules and queries written in the ontology's terms.[1] On this page "AI agent" always means software, and "agent" on its own means a contact-centre staff member. In workforce management (WFM) the rules in question are familiar ones: an agent may not be moved to a queue without the skill for it, a schedule change may not breach a working-time limit, and a reported occupancy must say which definition it uses.

The agent loop

An AI agent, in the sense used here, is a language model run in a loop with access to tools: functions that read data or change something in another system. The loop, in the general form of interleaved reasoning and acting described in the research literature, can be set out in four steps that repeat until the task is finished.[2]

  1. The model reads the goal and everything gathered so far.
  2. The model proposes a tool call: a tool name and a set of arguments.
  3. The surrounding program, often called the harness, runs the tool.
  4. The tool's result is added to what the model reads on the next turn.

The model never acts directly. Every effect on the outside world passes through step 3, which is ordinary code. That is where checks are placed. The kinds of agent this applies to in a planning function are described in Real-Time Agents, Scheduling Agents and AI Agent Teams for Workforce Management.

Where checks sit

A loop offers four positions for a check. The two around the tool call carry most of the weight.

Position Runs Tests Can prevent the action
Input check Before the model sees a request Whether the request is in scope Yes
Pre-action gate After the model proposes a tool call, before the tool runs Whether the proposed action is well-formed and permitted Yes
Post-action gate After the tool runs, before its result is passed on Whether the result is well-formed and consistent with what is known No. The tool has already run
Output check Before the final answer is released Whether claims in the answer are supported Only the answer, not actions already taken

Agent frameworks expose the two gates under different names. One documents a hook that runs before a tool call and can deny it, and a separate hook that runs after the call succeeds and can only react to the result.[3] Another documents tool guardrails that run before a tool executes and can skip the call, and guardrails that run afterwards and can replace the output.[4] The mechanism is the same in both.

Check before the action when the tool has side effects

The choice between the two gates depends on what the tool does.

  • A read-only tool, such as a query for current queue statistics, changes nothing. A check after it runs is adequate: a bad result is discarded and nothing is lost.
  • A tool with side effects, such as one that changes a schedule, moves agents between queues, approves leave or sends a message, must be checked before it runs. A check that runs afterwards can report that a rule was broken. It cannot unpublish the schedule.

A design that validates only tool results is therefore suited only to AI agents that read. An AI agent that writes needs the policy check at the pre-action gate, on the proposed arguments, with the post-action gate kept as a second check on what came back.

Three layers of check

A proposal is tested in three layers, each answering a different question with a different tool. The standards are compared in Ontology Tools and Standards.

Layer Question Typical tool Example failure
1. Shape of the call Are the arguments the right fields and types? A schema validator for structured data: JSON Schema, or a library such as Zod or Pydantic The interval is given as text where a timestamp is required
2. Shape of the proposal as data Does the proposed action, expressed in the ontology's terms, satisfy the constraints on that kind of thing? SHACL A queue move with no end time; an occupancy figure with no variant stated
3. Agreement with recorded facts Does the knowledge graph support or contradict the proposal? SPARQL queries The agent named in the move is not recorded as holding the target queue's skill

The layers are not interchangeable. The Shapes Constraint Language (SHACL) is defined as a language for validating RDF graphs.[5] It does not validate the JSON arguments of a tool call, which is the job of a JSON schema validator. A proposal therefore passes layer 1 as JSON, is converted into RDF statements using the ontology's terms, and only then meets layers 2 and 3.

Validation and inference

Two different operations are often both called "applying the ontology", and a guardrail depends on keeping them apart.

Inference adds facts. A reasoner working from RDFS or OWL statements derives what follows from the data and does not reject individual records. If a property's range is Agent and a proposal uses a queue in that position, the reasoner concludes that the queue is an agent. The behaviours are set out in Ontology. At most a reasoner reports that a set of statements is inconsistent; it does not produce a record-by-record validation report.[6] Used as a guardrail, inference would accept a malformed proposal and add wrong conclusions to the graph.

Validation tests data against stated conditions and reports each failure. A SHACL validator returns a report that either conforms or lists results, each naming the node at fault, the constraint broken and a severity of violation, warning or information.[5] This is the operation a gate needs.

The two cannot be substituted for each other, and their order matters. A proposal from an AI agent is validated as it was stated, before any inference is applied to it. If inference runs first, the range example above defeats the check: the queue is inferred to be an agent, and a rule requiring an agent then passes. Inference is applied only to data that has already been validated, and validation is run again if inferred facts feed later checks.

Reading the answer: permit, refuse or escalate

A check against a knowledge graph tests a proposal against what the graph records, not against the world. The tools themselves take the data as given. A SHACL shape that requires a value reports a violation when the value is missing, and a SPARQL ASK query returns true if a matching pattern exists and false if none is found.[7] That false means "not found in this graph". It is not proof that the fact is untrue, and RDF and OWL are built on the reading that a missing statement is unknown.[6] How a gate treats a missing fact is therefore a design decision, made rule by rule. A fact the proposal itself must carry belongs in a shape, where absence is a violation. A fact looked up in a graph that may be incomplete belongs in a query whose empty result is handled separately.

A gate therefore needs three outcomes, not two.

What the checks find Outcome Example
The proposal conforms and the graph supports it Permit The agent is recorded as holding the skill; the move is within the allowed duration
A recorded fact or a constraint contradicts the proposal Refuse, and return the reason to the model so that it can revise The move would take the source queue below its recorded minimum staffing
The graph neither supports nor contradicts the proposal Escalate to a person, or refuse by default No skill record exists for the agent in either direction

Which default applies to the third row is a policy decision that depends on the action. Where the graph is known to be complete for a kind of fact, absence can safely be read as "no": a skills register that is the authoritative source for skills is one such case, and Source of Truth Register is where that authority is recorded. Where completeness is not known, treating absence as permission is the more dangerous error for any tool with side effects.

Escalation to a person

Escalation is one of the gate's three outcomes. The gate passes to a named human role the proposal, the check that could not be settled and the facts consulted. Three conditions trigger it:

  • the checks are inconclusive, as above;
  • the action is above the authority delegated to software, whatever the checks say; or
  • the same proposal has been refused repeatedly and the AI agent is not converging.

The second condition is set outside the ontology. Decision Authority Tiers in Workforce Operations covers the tiers of authority for operational decisions, Human Gates and Number Grades the points at which a person must sign off, and Human AI Supervision and Escalation Frameworks the design of supervision and escalation paths. A guardrail encodes those tiers as constraints, so that "moves of more than ten agents require approval" is a rule the gate enforces and not a line in a policy document the model may or may not follow.

Every decision of the gate, whether permit, refuse or escalate, is itself a fact worth recording with its provenance: which proposal, which checks, which version of the rules, which outcome. The W3C Provenance Ontology provides the vocabulary.[8]

Worked example

A real-time AI agent observes a rising queue and proposes to move six agents from the billing queue to the sales queue for two hours.

  1. Shape of the call. The arguments are checked against the tool's schema: six agent identifiers, two queue identifiers, a start and an end timestamp. One identifier is malformed. The call is refused and the model corrects it.
  2. Shape of the proposal. The corrected proposal is converted to RDF and validated together with the ontology and the controlled list of reason codes. The shapes require every queue move to have a start time, an end time and a stated reason code from the controlled list. It conforms.
  3. Agreement with the graph. Queries test the length of the move against the four-hour limit, each agent against the sales queue's required skill, and the billing queue's staffing after the move against its recorded minimum. The move is within the limit and billing stays above its minimum. Five agents hold the skill. For the sixth, no skill record exists. The skill test is a query and not a shape because the skills data may be incomplete.
  4. Outcome. Nothing contradicts the proposal, but one fact is missing. The skills feed is not registered as complete for new starters, so the gate does not read the gap as "no". It permits nothing yet and escalates: the real-time analyst sees the proposal, the five confirmed agents and the one open question, and approves a move of five.
  5. Record. The proposal, the three checks, the escalation and the analyst's decision are stored with their provenance.

The same structure applies to what an AI agent says. An AI agent that reports "occupancy was 84%" is making a claim that can be checked at the output position: a shape requires a measurement to name its variant, and the taxonomy records that a platform's occupancy is a close match, not an exact match, to the function's own (see Taxonomy). A rule written to use that mapping can fail a statement that compares the two as if they were one measure. Such a check works only on claims that arrive as structured data. Turning free text into checkable statements needs an extraction step, usually performed by a model, which is outside the deterministic scope of this page.

Limits

Guardrails of this kind enforce only what has been written down. A rule that is missing from the ontology is not enforced, and a fact that is wrong in the graph is trusted. They are deterministic checks on structure, authority and recorded fact. They do not judge whether a permitted action is wise, and they do not replace the monitoring and governance described in AI Workforce Governance Frameworks and Generative AI Governance for Workforce Systems. Facts can also change between the check and the action: staffing or skills recorded at the gate may differ by the time the tool runs, so a tool that changes something repeats the critical checks at execution. Guardrails also add latency and maintenance: every rule in the gate is a rule someone must keep current through Definitions and Source-of-Truth Change Control (generic process).

Maturity Model Position

The placement below is an interpretation of the model and is not taken from the model's own text. In the WFM Labs Maturity Model™, guardrails become relevant at Level 3, when automation first takes actions without a person initiating each one. At that level the usual form is schema validation of tool calls and a small set of pre-action checks. At Levels 4 and 5, where software agents plan and act across the operation, the gate, the ontology behind it and the escalation paths are part of the operating model, and The Agentic Handover Gate covers the gate applied before work is handed to an AI agent at all.

See Also

References

  1. ↑ The framing of an ontology as a logical guardrail around an agent loop was presented by Frank Coyle in the conference talk "Why Agentic Systems Need Ontologies" (AI Engineer, 2026). https://ai.engineer/talks/ontologies-for-agentic-systems The treatment on this page is drawn from the primary sources cited below.
  2. ↑ Yao, S., Zhao, J., Yu, D., Du, N., Shafran, I., Narasimhan, K. & Cao, Y. (2023). "ReAct: Synergizing Reasoning and Acting in Language Models". International Conference on Learning Representations (ICLR). https://arxiv.org/abs/2210.03629
  3. ↑ Anthropic. Hooks reference, Claude Code documentation. https://code.claude.com/docs/en/hooks
  4. ↑ OpenAI. Guardrails, OpenAI Agents SDK documentation. https://openai.github.io/openai-agents-python/guardrails/
  5. ↑ 5.0 5.1 Knublauch, H. & Kontokostas, D. (eds.) (20 July 2017). Shapes Constraint Language (SHACL). W3C Recommendation. https://www.w3.org/TR/shacl/
  6. ↑ 6.0 6.1 Hitzler, P., Krötzsch, M., Parsia, B., Patel-Schneider, P. F. & Rudolph, S. (eds.) (11 December 2012). OWL 2 Web Ontology Language Primer (Second Edition). W3C Recommendation. https://www.w3.org/TR/owl2-primer/
  7. ↑ Harris, S. & Seaborne, A. (eds.) (21 March 2013). SPARQL 1.1 Query Language. W3C Recommendation. https://www.w3.org/TR/sparql11-query/
  8. ↑ Lebo, T., Sahoo, S. & McGuinness, D. (eds.) (30 April 2013). PROV-O: The PROV Ontology. W3C Recommendation. https://www.w3.org/TR/prov-o/