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 cancel wasted work when a guardrail fails. We first
use the OpenAI Agents SDK for its built-in guardrails. Then we rebuild the
same idea with tools and plain asyncio, so it works with other agent
frameworks.
Links
The external resources:
- Related course: AI Bootcamp: From RAG to Agents
- FAQ data used by the agent
- AI Hero email course for the docs.py loader
- OpenAI Agents SDK guardrails documentation
The notebook you will build
By the end, you wrap a tool-using FAQ agent in guardrails:
The base agent can already search the FAQ, but it tries to answer unrelated questions too. The input guardrail blocks questions outside the course domain. The output guardrail checks the agent response for policy problems. Examples are promising deadline extensions or writing homework for a student.
In the later parts we show the same checks as tools. We also build a small async runner that can cancel work when a guardrail trips.
Sign in to access this workshop
Tutorial pages
- Overview and setup
- Part 1: Load FAQ documents
- Part 2: Base FAQ agent
- Part 3: Input guardrail
- Part 4: Tripwire handling
- Part 5: Output guardrail
- Part 6: Multiple guardrails
- Part 7: Streaming with guardrails
- Part 8: Tool-based guardrails
- Q&A: side discussions
- Part 9: Async primer
- Part 10: Cancel on tripwire
- Part 11: DIY runner for the FAQ agent
- Summary and next steps
Watch the recording
Recording available with Free with sign-in.
Free with sign-in View code on GitHubRelated content
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 6, 2026
Build a Documentation RAG Agent with Search Tools
We build a RAG system over real documentation and evolve it into an agentic search flow. For the knowledge base we use the Evidently AI documentation, a real set of Markdown files…
May 04, 2026
Build a Coding Agent with Tools, Skills and PydanticAI
We build a coding agent from scratch, starting with tool calls and an agentic loop. We add a skills system that loads reusable instruction files on demand, and the final version r…
April 21, 2026