Back to Workshops
Workshop Free

Building Safe AI Agents with Guardrails

January 6, 2026 Alexey Grigorev
ai-agents llm-engineering agent-safety tooling-architecture async-control

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:

The notebook you will build

By the end, you wrap a tool-using FAQ agent in guardrails:

flowchart LR USER["User question"] INPUT["Input topic guardrail"] FAQ["FAQ assistant agent"] SEARCH["search_faq tool minsearch index"] OUTPUT["Output safety guardrail"] ANSWER["User-facing answer"] OPENAI["OpenAI model calls"] USER --> INPUT INPUT -->|passes| FAQ INPUT -->|trips| ANSWER FAQ --> SEARCH FAQ --> OPENAI INPUT --> OPENAI OUTPUT --> OPENAI FAQ --> OUTPUT OUTPUT -->|passes| ANSWER OUTPUT -->|trips| ANSWER

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.