Agentic AI Masterclass ← Prev Next →
Module 1 · Foundations  Lab 0

The Setup Verifier

Before any agent runs, prove the ground is solid: Python 3.11+, the three packages, a valid OPENAI_API_KEY — then a one-line smoke-test agent that must answer SETUP OK.

ANIMATION · environment preflight → smoke test
python >= 3.11 runtime
deepagents ≥ 0.4.3
langchain-openai ≥ 1.1.8
OPENAI_API_KEY sk-…
openai ≥ 1.66.0
🤖smoke-test agentgpt-4o-mini
Press Replay to run the preflight.
check passed agent invoke()
Why this lab exists

Every later lab assumes a working Python 3.11+ venv with deepagents, langchain-openai, and openai installed, plus a real API key. Lab 0 turns that assumption into a diagnostic you can re-run anytime. It ends with the smallest possible agent — proof the whole stack lights up.

The core of the script
my-agents/lab0_setup.py
import os, sys

def check_setup():
    errors = []
    # [1] Python version
    if sys.version_info < (3, 11):
        errors.append("Python 3.11+ required")
    # [2-3-5] packages
    try: import deepagents
    except ImportError: errors.append("pip install deepagents")
    # [4] API key must start with sk-
    key = os.getenv("OPENAI_API_KEY", "")
    if not key.startswith("sk-"):
        errors.append("export OPENAI_API_KEY='sk-...'")
    return not errors

def test_agent():
    from deepagents import create_deep_agent
    from langchain_core.messages import HumanMessage
    agent = create_deep_agent(
        model="openai:gpt-4o-mini",
        system_prompt="Respond with exactly: SETUP OK")
    result = agent.invoke(
        {"messages": [HumanMessage(content="Confirm setup")]},
        config={"configurable": {"thread_id": "setup-test"}})
    print(result["messages"][-1].content)  # → SETUP OK
Run itpython my-agents/lab0_setup.py

Build-only model: your agent writes this file but doesn't run it. You run it in your own terminal and watch five marks, then a SETUP OK from the test agent.

What you learned
ConceptHow it works
create_deep_agent()Factory: model + (optional) tools / system_prompt → a ready agent.
invoke()Pass {"messages":[...]} + a thread_id; get messages back.
thread_idScopes a conversation — different IDs are separate conversations.
gpt-4o-miniCheap, high rate-limit default — ideal for student keys.
Lab 0 of 11 · Course overview