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.
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.
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
python my-agents/lab0_setup.pyBuild-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.
| Concept | How it works |
|---|---|
| create_deep_agent() | Factory: model + (optional) tools / system_prompt → a ready agent. |
| invoke() | Pass {"messages":[...]} + a thread_id; get messages back. |
| thread_id | Scopes a conversation — different IDs are separate conversations. |
| gpt-4o-mini | Cheap, high rate-limit default — ideal for student keys. |