Guardrails for AI Agents
Published by Pearson
Make AI Agents Safe and Reliable with Built‑In Safety Checks
Course Outcomes:
- Practical, code-first approach using real-world FAQ assistant example.
- Framework-agnostic patterns that work with any agent framework.
- Covers both built-in guardrails and DIY implementation strategies.
AI agents are powerful, but they can be tricked into harmful behavior, drift off-topic, or make inappropriate promises. This workshop teaches you how to implement guardrails--safety checks that run before (input) or after (output) your agent executes. You’ll build a complete FAQ assistant agent with tools, then add layers of protection. Learn to block irrelevant questions before the agent sees them, prevent inappropriate promises, and catch hallucinated responses before they reach users. The course covers input guardrails, output guardrails, streaming with guardrails, and framework-agnostic implementations that work with any agent system.
What you’ll learn and how you can apply it
- Build and deploy input guardrails that block off-topic or harmful queries before your agent processes them.
- Implement output guardrails that catch inappropriate promises, offensive content, or policy violations.
- Run guardrails concurrently with agents to add zero latency while maintaining safety.
- Apply guardrail patterns to any agent framework including OpenAI Agents SDK, PydanticAI, LangChain, or custom implementations.
This live event is for you because...
- You are an AI engineer, software developer, or data scientist building AI agents and need to ensure their systems are safe, reliable, and on-topic.
- You’re working on customer support bots, teaching assistants, or any agent that interacts with users, and you want to prevent it from being tricked or drifting off-topic.
Prerequisites
- Basic experience with Python is recommended. The course includes a brief introduction to LLM agents, so having some prior familiarity with the concept will be helpful.
- Python 3.10+ installed
- OpenAI API key (free tier account works) or alternative
- Familiarity with Jupyter notebooks for running exercises
Course Set-up
- Install uv and dependencies: pip insatll uv
- Set up OpenAI API key in .env file: OPENAI_API_KEY='your-key'
- Launch Jupyter: jupyter notebook
Recommended Preparation
- Read: Building Agentic AI: Workflows, Fine-Tuning, Optimization, and Deployment by Sinan Ozdemir (book)
- Attend: Getting Started with LLM Agents using LangGraph by Lucas Soares (live online training course)
- Watch: Asynchronous Python Programming with Asyncio and Async/await: Learn to Write Robust and Modern Asynchronous Code by Coen de Groot (video)
Recommended Follow-up
- Read: AI Agents: The Definitive Guide by Nicole Koenigstein (book)
- Watch: Agentic AI Systems in Production by Robert Barton & Jerome Henry (video)
Schedule
The time frames are only estimates and may vary according to how the class is progressing.
Segment 1: Introduction to Agents (30 minutes)
- What are AI agents and how do they work?
- Agents vs standalone LLM calls
- Tool calling: giving agents capabilities
- When do you need an agent?
- Brief overview of agent frameworks
- Q&A (5 minutes)
Segment 2: Building a Complete Agent (35 minutes)
- Setting up the environment and dependencies
- Creating a FAQ search tool
- Building the agent with instructions
- Running the agent and observing its behavior
- Exercise: Run the agent and test with various questions to see how it responds (5 minutes)
- Q&A (5 minutes)
- Break (5 minutes)
Segment 3: Input Guardrails (40 minutes)
- What are input guardrails and when to use them
- Defining guardrail output structure with Pydantic
- Creating a topic guardrail agent
- Implementing input guardrail functions
- Attaching guardrails to your agent
- Handling guardrail failures
- Exercise: Implement and test a topic guardrail that blocks off-topic questions (5 minutes)
- Q&A (5 minutes)
Segment 4: Output Guardrails (35 minutes)
- What are output guardrails and when to use them
- Defining safety checks for agent responses
- Creating a safety guardrail agent
- Attaching both input and output guardrails
- Testing with edge cases (promises, inappropriate requests)
- Exercise: Build a safety guardrail that blocks deadline extension promises (5 minutes)
- Q&A (5 minutes)
- Break (5 minutes)
Segment 5: Multiple Guardrails (30 minutes)
- Chaining multiple guardrails together
- Academic integrity guardrail example
- Streaming responses with guardrails
- Zero-latency concurrent execution
- Framework-agnostic approaches
- Exercise: Test fully-guarded agent with streaming enabled (5 minutes)
- Q&A (5 minutes)
Course wrap-up and next steps (15 minutes)
- Summary of key takeaways
- When to use each guardrail type
- Further reading and resources
- Final Q&A
Your Instructor
Alexey Grigorev
Alexey Grigorev works as a principal data scientist at OLX. He runs DataTalks.Club — a community for data enthusiasts. Alexey has written books about machine learning including his most recent, Machine Learning Bookcamp, which is a book for software engineers who want to get into machine learning. He lives in Berlin with his wife and son.