OpenAI Agents SDK
Provide a lightweight, production-ready Python and TypeScript framework for building multi-agent workflows around four primitives: Agents, handoffs, guardrails, and sessions, with built-in tracing for the entire run.
Description
The OpenAI Agents SDK is the MIT-licensed successor to Swarm, shipped in March 2025. Its agent loop is small and explicit: Runner.run(agent, input) calls the LLM, executes any tool calls, follows any handoffs, and re-runs until the agent emits a final_output or max_turns is exceeded (MaxTurnsExceeded). Agents are LLMs configured with instructions, tools, optional output_type, handoffs, and guardrails. Handoffs are exposed to the model as transfer_to_<agent> tools with optional input_filter to reshape the conversation history. MCP support ships with three transports (Stdio, SSE, Streamable HTTP). SQLiteSession is the default session-memory backing store and supports run resumption across pauses.
Solution
Runner.run loop: call LLM -> if final_output, return; if handoff, swap current agent and re-run; if tool calls, execute and append results then re-run. Loop is capped by max_turns (None disables). Sessions automatically prepend prior history before each run and store new items afterwards.
Primary use cases
- multi-agent workflows where specialised agents hand off control
- agents that call MCP servers alongside Python function tools
- agents with input/output guardrails and Pydantic-typed outputs
- production agents that need built-in tracing and session memory
- TypeScript agents sharing the same primitive set as the Python SDK
Open the full interactive page →
Diagram, neighbourhood map, code examples, related patterns and full provenance.