OpenAI Agents SDK Tutorial
Last updated 2026-07-31What's new
- AI tools (like OpenClaw, a personal assistant app) can sometimes appear to work fine while actually failing to remember important information, a problem called "silent success."
- The "harness" (the system managing the AI) is crucial for reliable AI performance, not just the AI model (the "engine") itself, as it handles tasks like state management and ordering.
- AI systems should have clear ownership and replay paths for every fact they use, ensuring that information is stored and can be retrieved correctly for future use.
- With more event sources and action surfaces, AI failures can be easier to trigger and harder to explain, making a robust harness even more important.
- Anthropic released Opus 5, a new AI model that's better than Fable in most areas and costs half as much, making it great for knowledge work and coding tasks.
- Anthropic and OpenAI both launched voice features, allowing users to control their AI tools (like Codex and Claude) with their voice in real time.
- Opus 5 can be tested in the Claude desktop app, and it's particularly good at creating detailed presentations, though it may take a long time to complete tasks.
- The new voice mode in the Claude iOS app lets you interact with Opus 5 and even edit Notion documents using your voice.
- Buzz is a new app that lets you add AI agents (like digital coworkers) to your team, similar to how you'd use Slack or GitHub, but with more advanced AI capabilities.
- You can run Buzz on your own server (a computer you control) using self-hosted software, which keeps your messages private and secure.
- Buzz uses AI models (like Claude Code and Codex, which are AI tools that can write and understand code) to create AI agents that can join channels, read history, and work together in real-time.
- You can create and customize your own AI agents (like a researcher named Bumble or a thinking partner named Honey) to help you with specific tasks, like building a website or analyzing data.
- Forward Deployed Engineers (FDEs) (specialists who customize AI tools for specific companies) are in high demand, with some earning millions annually, and you can become one in 30 days.
- AI intelligence is becoming widely available, so the competitive edge lies in how companies deploy and customize it for their unique needs.
- Palanteer (a company that helps businesses use AI) popularized the FDE role, sending specialists on-site to create tailored solutions using their customizable software platform.
- Gemini K3, a new open weights model, is now number one on a coding leaderboard, beating models like Claude Fable 5 and GPT, and it's designed to be faster and more efficient (open weights means anyone can download and use the model's code).
- Gemini K3 uses special techniques like Delta attention and attention residuals to speed up processing and improve efficiency, making it up to 6.3 times faster in handling large amounts of data.
- The model comes in different versions for specific tasks, like K3 Max for general use, K3 Small Max for large jobs, and Kimi for coding, which is tuned for reliable long context work.
- While Gemini K3 is leading in some benchmarks, it's not perfect and may not always outperform other models in real-world coding tasks, but its persistence in problem-solving makes it a strong contender.
- Primed and Loaded has introduced new open-source tools, Verifiers and Primed RL libraries, to help improve AI models after they're initially trained (post-training).
- They've created a global marketplace of data centers with over 10,000 GPUs (powerful computer chips) to support large-scale AI model training.
- The company is working on making it easier for anyone to train and customize AI models for their specific needs, not just using existing models.
- They've also introduced a new platform called Lab, which combines various tools to make AI research and model training more accessible and efficient.
- ChatGPT has a new feature called ChatGPT Work (previously Codex), which lets you assign tasks and get finished work like spreadsheets or reports without constant supervision.
- ChatGPT Work is now available as a desktop app (Mac and Windows) and on the web, allowing AI to access and use files and folders on your computer for better task completion.
- To use ChatGPT Work effectively, create dedicated folders for specific tasks to avoid overwhelming the AI with unrelated files, and choose the right AI model (Sol for complex tasks, Luna for simple searches).
- ChatGPT Work offers different effort levels (light to ultra) and speed options (standard or fast) to tailor the AI's performance to your task's complexity and urgency.
- Hermes Agent (a powerful AI tool that can act like a full-time employee) works best with the Opus model (a specific AI model that's very reliable but expensive), but ChatGPT (a popular AI chat service) and GLM 5.2 (a cheaper AI model) are also options.
- To avoid downtime, run at least two Hermes agents simultaneously, using different AI models or accounts, so they can monitor and fix each other if one fails.
- You can create new Hermes agents (called "profiles") either by asking an existing agent to set one up for you or by using the Hermes dashboard.
- If you're running a serious business, consider investing in the Opus model for Hermes Agent, as it's the most reliable for completing tasks.
- OpenAI's recent report shows they use AI agents (specialized AI tools for specific tasks) 99% of the time, not chatbots (general AI conversation tools like ChatGPT), with Codex (OpenAI's advanced AI agent) being their primary tool.
- OpenAI employees have unlimited access to advanced AI models (like GPT 5.6 or 5.7), which are more capable than publicly available versions (like GPT 5.5).
- To become AI-native, companies should remove four roadblocks: easy employee access to AI tools, AI access to real work and systems, AI permissions to take action, and sharing AI capabilities across teams.
- Companies should invest in AI tools, providing all employees with strong access and minimal usage restraints to reduce friction and maximize AI benefits.
- Bots (automated software) now make up 57% of web traffic, outnumbering humans (43%), with a new kind of bot growing faster than expected.
- Google's AI overviews (AI-generated answers at the top of search results) have cut website traffic, hurting businesses like Business Insider and Chegg.
- A German court ruled that Google can be held responsible for false information in its AI overviews, as they're considered Google's own statements.
- Cloudflare introduced "payer crawl," a system that charges AI crawlers (bots that gather data for AI) for accessing website content, using an old, unused web code (402).
- OpenAI is upgrading ChatGPT to be more than a chatbot, aiming to turn it into a full AI super app with coding tools, image generation, and task-completing agents (AI helpers that do work for you).
- Codex, OpenAI's programming tool, is being integrated deeply into ChatGPT, allowing it to handle software control, coding tasks, and workflow automation for everyone, not just developers.
- ChatGPT's interface will change to guide users toward coding tools, image generation, and third-party applications, with Codex potentially handling tasks automatically in the future.
- OpenAI's GPT 5.5 model is better at long-term multi-step tasks, giving Codex more confidence to execute work with less manual guidance, making it more trustworthy for developers.
- Hermes Agent (a personal AI assistant) can now run entirely on your own computer, making it private, free, and independent of internet access.
- Local AI (AI running on your personal devices) is the future, with experts like Nvidia's CEO predicting it will become as essential as smartphones are today.
- Hermes has a new desktop app that simplifies the process of running the AI locally, giving you full control over your data and no monthly bills.
- While local AI models may be slightly behind the cutting-edge, they offer significant advantages in privacy, cost, and independence.
- OpenAI is merging Codex (an AI that can control your computer) with ChatGPT (their popular chatbot) into one unified app so you don’t have to pick which tool to use.
- Your AI “agents” (smart programs that work for you) will soon run constantly in the cloud, completing goals like preparing reports even while you sleep.
- New features like the `/goal` command let you tell the AI a final result you want, and it will keep working on its own until that goal is done.
- Your AI can now access your email, calendar, and messages to understand your goals, then start helpful tasks in the background that may surprise you with their usefulness.
Key points
What it is
- The OpenAI Agents SDK is a software toolkit that lets you control AI agents (AI programs that can plan actions, use tools, search the web, and more) within your own Python application.
- It gives you control over the agent loop (the cycle where the AI thinks, uses a tool, gets a result, and thinks again), allowing your application to manage tool execution, approvals, state, and traces (logs).
How to use it
- Install the correct Python package by running `pip install openai-agents` (not the outdated "agents" package).
- Create a setup check in a file like `setup.py` to verify your API key is loaded and the SDK is on your path.
- Build an agent by creating a file like `lib/agent.ts`, importing `ToolLoopAgent`, specifying your model, and providing the agent with its first tool (a function the agent can call).
Watch out for
- Using the wrong package name (must be `openai-agents`), or having the key file present but not loaded because `load_dotenv` is missing.
- Forgetting to pass extra context or parameters into the model request when defining a tool.
- Focus on getting the setup script running before adding complexity.
Tools named
- OpenAI Agents SDK (a toolkit for controlling AI agents in Python applications).
Lesson 1: What is OpenAI Agents SDK Tutorial and why it matters
The OpenAI Agents SDK is a software development kit that lets you control how AI agents run inside your own Python application. An "agent" here is an AI program that can plan actions, use tools, search the web, keep a conversation going across multiple turns, and correct itself. The SDK matters because it hands you the control panel for the agent loop — the cycle where the model thinks, calls a tool, gets a result, and thinks again. Without the SDK, you are just sending a message to a model and printing the reply. With the SDK, your application owns tool execution (running those external functions), approvals (allowing or blocking actions), state (remembering what happened), and traces (logs you can inspect). For example, a later lesson in the tutorial will look up orders and route hard cases using code you write, not just a chat response.
The SDK works best when you install the correct package. The right Python package is `openai-agents`, not `agents`. Setup also requires your API key to be loaded from a `.env` file using `load_dotenv`. When you see the machine is ready before the agent enters the story, that boring status is good — it means the foundation is solid. OpenAI also offers built-in tools like web search and file search, where you drop in a file and OpenAI handles embedding and indexing automatically. The SDK gives you a lightweight framework without a whole bunch of ceremony, making it practical for building real agents that do more than chat.
Sources
- 2026-05-05 — Build Your First AI Agent From Scratch with OpenAI Agents SDK Part 1
- 2026-05-12 — Give Your Agent a Computer Nico Albanese, Vercel
- 2026-05-25 — I Built 1 AI Agent That Runs on Claude, GPT, AND Gemini
- 2026-05-09 — Codex Super App, OpenAI Chaos Drama, Gemini 3.2 Pro In Arena, GPT-Realtime-2, & NotebookLM Update!
- 2026-02-10 — GPT-5.3 makes every other AI look ancient #AI #comparison
- 2026-05-31 — Self-improving AI, Opus 4.8, Nvidia bangers, game-ready 3D models, juggling robots AI NEWS
- 2025-12-03 — OpenAI Just Leveled Up n8n AI Agents (here's how it works)
- 2026-05-14 — Ship Real Agents Hands-On Evals for Agentic Applications Laurie Voss, Arize
- 2026-05-10 — Hermes Agent NEW Desktop App - The 247 Self-Evolving AI Agent!
- 2026-02-07 — AI NEWS - GPT-5.3-Codex Crushes Terminal-Bench, But Claude Opus 4.6 Has One Massive Advantage
- 2026-04-05 — Andrej Karpathy Just 10x’d Everyone’s Claude Code
- 2026-05-22 — 6 Hermes Agent use cases I promise will change your life
- 2026-05-30 — Google Remy, Grok 5, Mythos 1, New Atlas Robot, ASI and More AI News This Month!
Lesson 2: How to use OpenAI Agents SDK Tutorial: step-by-step
Start by installing the correct package: run `pip install openai-agents` (not the outdated "agents" package). The SDK is designed for orchestration (coordinating multi-step tasks) in your Python app, not just sending a single message. It lets your code own tool execution, approvals, state, and traces.
Create a minimal setup check in a file like `setup.py`. Import `load_dotenv` to make your local `.env` file visible, then use `os.getenv("OPENAI_API_KEY")` to verify your key is loaded. Import the `agents` package to confirm the SDK is on your path. Use `sys.exit(1)` to stop immediately if any check fails. The expected output should be "boring" — just confirmation messages.
To build an agent, create a file like `lib/agent.ts`. Import `ToolLoopAgent` and specify your model. If you want to use OpenAI, import the OpenAI provider. The SDK lets you augment context (extra information you pass into each request) and provide the agent with its first tool (a function the agent can call). For a practical starter, the agent can search the web, maintain conversation across turns, and call tools you define.
Common setup errors: using the wrong package name (must be `openai-agents`), or having the key file present but not loaded because `load_dotenv` is missing. The SDK supports streaming, where the API returns many events until a final output. For a beginner, focus on getting the setup script running before adding complexity. The SDK gives you control over the agent loop from your Python code, enabling you to route hard cases, look up data, and approve actions programmatically.
Sources
- 2026-05-12 — Give Your Agent a Computer Nico Albanese, Vercel
- 2026-05-05 — Build Your First AI Agent From Scratch with OpenAI Agents SDK Part 1
- 2026-05-07 — Vibe Engineering Effect Apps Michael Arnaldi, Effectful
- 2026-05-19 — I Built a Company of 147 AI Agents (Heres How)
- 2026-05-10 — Hermes Agent NEW Desktop App - The 247 Self-Evolving AI Agent!
- 2026-05-25 — I Built 1 AI Agent That Runs on Claude, GPT, AND Gemini
- 2026-05-12 — The 1M+ Solo AI Agent Business (Full Course)
- 2026-05-14 — Ship Real Agents Hands-On Evals for Agentic Applications Laurie Voss, Arize
- 2026-05-07 — Everything You Need To Know About Agent Observability Danny Gollapalli & Zubin Koticha, Raindrop
- 2026-05-14 — Make your own event-sourced agent harness using stream processors Jonas Templestein, Iterate
- 2025-12-03 — Building n8n Agents Just Got So Much Easier with OpenAI
- 2026-02-25 — I Can Actually Watch My AI Agents Work Now
Lesson 3: Best practices and pitfalls
When starting with the OpenAI Agents SDK, beginners often hit two specific setup mistakes. First, running `pip install agents` installs the wrong package. The correct command is `pip install openai-agents`. Second, even if your API key file exists, it won’t load if you forget the `load_dotenv()` call. Use a small setup verifier script that checks each condition in order: confirm `load_dotenv()` ran, then `os.getenv("OPENAI_API_KEY")` returns a value, then `import agents` succeeds. If any check fails, call `sys.exit(1)` to stop immediately. This prevents guessing about downstream errors.
A common pitfall when building agents is forgetting to pass extra context or parameters into the model request. When you define a tool, the additional parameters you set on the agent side may not automatically forward to the OpenAI API call unless you explicitly include them in the tool definition. Double-check that your context augmentation is wired into the actual request payload.
Best practices include using the SDK when your application needs to own tool execution, approvals, state management, and tracing (recording agent steps). The SDK is designed for orchestration inside your Python app, not just sending a message and printing a reply. Also, consider separating your agent logic by responsibility. For example, one agent can look up orders, and another route hard cases in code. This mirrors the pattern of agent teams (multiple instances coordinating on tasks) seen in larger implementations. Finally, test your setup with a boring, silent pass — it means the machine is ready before the agent enters the story.
Sources
- 2026-05-05 — Build Your First AI Agent From Scratch with OpenAI Agents SDK Part 1
- 2026-05-12 — Give Your Agent a Computer Nico Albanese, Vercel
- 2026-02-25 — I Can Actually Watch My AI Agents Work Now
- 2026-05-10 — Hermes Agent NEW Desktop App - The 247 Self-Evolving AI Agent!
- 2026-03-12 — Build & Sell with Claude Code (10+ Hour Course)
- 2026-05-25 — I Built 1 AI Agent That Runs on Claude, GPT, AND Gemini
- 2026-05-07 — Vibe Engineering Effect Apps Michael Arnaldi, Effectful
- 2026-02-07 — AI NEWS - GPT-5.3-Codex Crushes Terminal-Bench, But Claude Opus 4.6 Has One Massive Advantage
- 2026-05-03 — Google Just Dropped COSMO Then Mysteriously Pulled It
- 2026-05-19 — I Built a Company of 147 AI Agents (Heres How)
- 2026-02-25 — I Can Actually Watch My AI Agents Work Now
- 2026-05-06 — MCP UI Extending the frontier Liad Yosef and Ido Salomon, MCP Apps