Full-Code · Agent SDKsactive

OpenAI Agents SDK

Type: full-code  ·  Vendor: OpenAI  ·  Language: Python, TypeScript  ·  License: MIT  ·  Status: active  ·  Status in practice: mature  ·  First released: 2025-03-04

Links: homepage docs repo

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.

Agent loop shape. 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

Key concepts

  • Agent tool-use (docs)LLM configured with instructions, tools, optional output_type, handoffs, guardrails.
  • Runner step-budget (docs)Runs the agent loop via Runner.run / run_sync / run_streamed; capped by max_turns, raises MaxTurnsExceeded.
  • Handoffs handoff (docs)Sub-agent delegation exposed as transfer_to_<agent> tools; handoff() customises tool name, description, on_handoff callback, input_filter.
  • Guardrails input-output-guardrails (docs)Input guardrails run on the first agent's input; output guardrails on the last agent's final output. Input guardrails can run in parallel or block.
  • Sessions agent-resumption (docs)Built-in session memory (SQLiteSession default) that prepends history before each run and stores new items afterwards; supports resumption after approval pauses.
  • MCP transports mcp (docs)MCPServerStdio (subprocess), MCPServerSse (HTTP+SSE), MCPServerStreamableHttp (self-managed connection); tools exposed identically to function tools.
  • output_type structured-output (docs)Optional Pydantic / typed output declaration that switches the model into structured-outputs mode.

Patterns this full-code implements

Neighbourhood

Click any neighbour to follow the lineage. Scroll to zoom, drag to pan.