Back to Workshops
Workshop Free

Building an Agent with Guardrails

May 26, 2026
ai-agents guardrails agent-safety data-engineering python

AI agents are useful because they can call tools and act on user requests. That same flexibility makes them easy to steer off topic. In this workshop, we build a Data Engineering Zoomcamp FAQ agent and add guardrails around it.

flowchart LR USER["User question"] INPUT["Input guardrail"] AGENT["FAQ agent"] SEARCH["search tool Data Engineering Zoomcamp FAQ"] OUTPUT["Output guardrail"] ANSWER["User-facing answer"] USER --> INPUT INPUT -->|passes| AGENT INPUT -->|blocks| ANSWER AGENT --> SEARCH AGENT --> OUTPUT OUTPUT -->|passes| ANSWER OUTPUT -->|blocks| ANSWER

The live training starts with the FAQ bot context. We cover what data it uses, what questions it should answer, and where a normal RAG pipeline stops. From there, we turn the RAG pipeline into an agent with one search tool and add guardrails layer by layer.

Workshop flow

The examples use Python, Pydantic, minsearch, and the plain OpenAI Python SDK.

We build the workshop in this order:

  • The Data Engineering Zoomcamp FAQ JSON data.
  • A RAG baseline with keyword search.
  • A framework-neutral agent loop with one search tool.
  • Input checks for topic and intent.
  • An async runner that can cancel the FAQ agent.
  • Output checks for unsafe promises or policy violations.
  • Multiple guardrails with clear responsibilities.
  • Concurrent guardrail checks that keep latency low.

We implement the agent loop ourselves so the guardrail pattern isn't tied to a specific agent framework.

The guardrail ideas are inspired by the OpenAI Agents SDK guardrails. We implement them directly because not every framework has the same built-in support. If your agent framework doesn't provide input and output guardrails, you can still use the pattern from this workshop.

Prerequisites

Before the workshop, make sure you have:

  • Python 3.10 or newer.
  • uv for the Python environment.
  • Jupyter Notebook.
  • An OpenAI API key, or another model provider you can call from Python.

Links

Resources mentioned in the live training: