Seven runnable notebooks for building agentic pipelines with the OpenAI Agents SDK. The running example throughout is historical letter analysis: extracting people, places, dates, and evidence from archival texts. Each notebook introduces one new concept layer and is fully self-contained.
-
notebooks/01_single_agent_foundations.ipynb- What an agent is
- Instructions, tools, and task scope
- Structured output and reproducibility
-
notebooks/02_multi_agent_handoffs.ipynb- Agents as tools
- Specialized roles
- Handoffs between agents
- Coordinating a small pipeline
-
notebooks/03_guardrails_and_human_in_the_loop.ipynb- Input and output guardrails
- Confidence and uncertainty
- Interactive human review checkpoints
-
notebooks/04_end_to_end_pipeline.ipynb- Single-agent extraction
- Agents as tools and handoffs
- Guardrails in one workflow
-
notebooks/05_evaluation.ipynb- Gold-standard annotations
- Precision, recall, and F1
- Scoring extractions across a document collection
-
notebooks/06_retrieval_and_tools.ipynb- Retrieval-Augmented Generation over local files
- API tools with no authentication (Wikipedia, Nominatim)
- Multi-tool agents and responsible API use
-
notebooks/07_state_management.ipynb- Accumulating results across multiple agent runs
- Provenance tracking
- Cross-document queries and co-occurrence analysis
uv sync
uv run jupyter labTo isolate notebook kernels:
uv run python -m ipykernel install --user --name agentic-example- Copy
.env.exampleto.env. - Add your
OPENAI_API_KEYvalue to.env. - Reopen the notebook or restart the kernel.
The notebooks load .env automatically when run locally.
- Create a new notebook in Google Colab.
- Run:
!git clone https://github.com/<your-user>/agentic_example.git
%cd agentic_example
!pip install openai-agents pandas jupyterlab ipykernel ipywidgets- Set your API key using Colab Secrets (recommended):
- Click the key icon in the left sidebar (or go to Tools → Secrets).
- Add a secret named
OPENAI_API_KEYwith your key as the value. - Enable notebook access for that secret.
- Load it in a code cell:
from google.colab import userdata
import os
os.environ["OPENAI_API_KEY"] = userdata.get("OPENAI_API_KEY")Using Secrets keeps your key out of the notebook file and out of version control. Never paste a live API key directly into a cell — Colab autosaves notebooks and the key would be stored in plain text.
- Open the notebook files in the
notebooks/folder and run cells top to bottom.
Alternatively, copy the code cells into a single Colab notebook and install the same packages with pip.