Urgent.News

What's breaking now, across hundreds of outlets.

AI

OpenAI Agents SDK tutorial (Python): first agent, tools, handoffs, MCP

OpenAI Agents SDK tutorial for Python Checked against the official docs: Nov 4, 2026 The OpenAI Agents SDK ( openai-agents on PyPI) is OpenAI's open-source Python framework for building agents: a model with instructions, tools it can call, and the option to hand a conversation to another agent. This tutorial goes from an empty folder to an agent that uses your own Python functions, routes…

OpenAI's Agents SDK for Python provides a framework for building agents with models, instructions, tools, and the capability to pass conversations to other agents. This tutorial walks you through creating an agent that uses your own Python functions, routes questions between specialists, remembers earlier turns, and calls an MCP server.

To get started, ensure you have Python 3.10 or newer installed. Create a project folder with its own virtual environment to keep the SDK and its dependencies separate from your system Python. Install the openai-agents package using pip install openai-agents. Set the OPENAI_API_KEY environment variable in your terminal to authenticate with the OpenAI service.

The basic structure of an agent involves creating a model with instructions and tools. You can run the agent using the Runner.run() function in async code, which is suitable for web servers and running multiple agents simultaneously. Runner.run_sync() is an alternative for plain scripts, but it won't work inside an already running event loop.

Agents can utilize function tools, which are ordinary Python functions that the model can decide to call. These tools are defined using the @tool decorator from the agents.decorators module. The SDK also supports hosted tools like WebSearchTool() and FileSearchTool(), which you can add to the tools list in the same way.

One of the key features of the Agents SDK is the ability to hand off conversations between agents. This allows for more specialized responses to complex queries. Each specialist agent should have a handoff_description to indicate when to route the conversation.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in AI

Data audit: which AI chat apps demand a face scan or ID (verified Dec 1, 2026)

Data audit time. Between October and November 2026, biometric age verification went from compliance rumor to a daily login wall on the biggest AI character-chat apps.

  • Biometric age verification required on popular AI chat apps in Oct-Nov 2026
  • Character.AI, Chai AI, Janitor AI implemented ID and facial verification
  • Ouba platform conducted audit, no biometric or ID checks required

Should You Buy Anthropic Right Now?

Anthropic stock has been all over the place since its IPO.

  • Anthropic IPO valued at $1.5 trillion on November 18
  • Company reported $17B revenue, $104B loss in Q3 2026
  • 20% revenue from two large customers, lockup period ends Dec 15

More from Tuesday, 1 December 2026 →