Building an Agent with Guardrails
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.
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
We write the examples in Python with 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
searchtool. - 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 approach 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 approach from this workshop.
Prerequisites
Before the workshop, make sure you have:
- Python 3.10 or newer.
uvfor 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:
- The Agentic Loop from Scratch - the loop this agent runs, built by hand.
- OpenAI function calling guide
- Data Engineering Zoomcamp repository
- Data Engineering Zoomcamp FAQ JSON
Tutorial pages
Sign in to access this workshop
This workshop is free — you just need an account. Sign in or create one in seconds.
Sign InBy creating an account, you agree to our Terms of Service and Privacy Policy.
By signing up free, you'll receive community updates. You can unsubscribe at any time.
Related content
The Agentic Loop: Building a Mini Agent Framework from Scratch
We start with a fixed RAG pipeline that searches a course FAQ once and passes the results to the model. That works until the search misses. A typo, a question phrased the wrong wa…
July 07, 2026
AI Hero: 7-Day AI Agents Crash-Course
Build a complete AI agent from data ingestion to deployment in 7 focused days. You will use a real GitHub repository as the source material, then build an assistant that can read …
Building Safe AI Agents with Guardrails
We start with a DataTalks.Club Data Engineering Zoomcamp FAQ assistant. Then we add checks that keep the agent on topic and block unsafe responses. The checks also show how to can…
January 06, 2026