AI & Agents

How to Build Multi-Agent Systems with the OpenAI Agents SDK

The OpenAI Agents SDK is the official Python framework for orchestrating multi-agent systems, replacing the experimental Swarm framework. This guide covers how to build agents that can hand off tasks, execute tools, and maintain persistent state and files across sessions.

Fast.io Editorial Team 8 min read
The OpenAI Agents SDK enables coordination between specialized AI agents.

What Is the OpenAI Agents SDK?

The OpenAI Agents SDK is a Python framework for building multi-agent systems with handoffs, guardrails, and tool integration on top of OpenAI models. Launched as the production-ready successor to the experimental Swarm framework, it provides the "glue" code needed to make multiple LLMs work together as a cohesive team. Unlike the Assistants API, which is a hosted service, the Agents SDK runs on your own infrastructure (or lightweight edge containers), giving you full control over the execution loop and state management. Its core primitive is the Handoff, allowing one agent to transfer a conversation and its context to another specialized agent. This shift from experimental to production-grade tools marks an important milestone in the AI engineering ecosystem. While Swarm was an excellent educational resource for understanding multi-agent patterns, the Agents SDK provides the reliability required for enterprise applications, including better error handling and more predictable routing logic. For developers, this solves the "God Bot" problem. Instead of a single prompt trying to do everything (research, coding, writing), you build small, specialized agents and define how they route tasks to each other.

Helpful references: Fast.io Workspaces, Fast.io Collaboration, and Fast.io AI.

Abstract representation of AI neural networks and agent logic

What to check before scaling openai agents sdk

The architecture of the Agents SDK relies on two main concepts: Agents and Handoffs. An Agent is a class that wraps a model configuration (like GPT-4o) and a set of tools (Python functions). A Handoff is a function that returns another Agent. When an agent determines it cannot fulfill a request, it calls a handoff tool. For example, a TriageAgent might analyze a user query and call transfer_to_support() or transfer_to_sales(). The SDK handles the context switch automatically, ensuring the new agent receives the relevant conversation history.

Why Handoffs Matter:

  • Specialization: You can use cheaper models (like GPT-4o-mini) for routing and stronger models for complex reasoning.
  • Context Management: Handoffs prevent context windows from overflowing by only passing necessary information.
  • Modularity: You can update the SalesAgent logic without breaking the SupportAgent.

The Missing Piece: Persistent File Storage

While the Agents SDK handles logic and conversation state well, it does not solve file persistence. If your ResearchAgent generates a PDF report, or your DataAgent creates a CSV, where does that file go? In a local demo, it saves to your laptop's disk. But in production, when running on serverless functions or containers, local disk is temporary. When the agent finishes or the container restarts, the files are lost.

The Fast.io Solution: Fast.io provides a dedicated Model Context Protocol (MCP) server that gives your agents instant, persistent cloud storage. By adding the Fast.io toolset to your agent, it can read, write, and search files in a secure cloud workspace that persists across sessions.

Fast.io features

Give Your AI Agents Persistent Storage

Stop losing data when your agent session ends. Get 50GB of free, persistent cloud storage for your OpenAI agents with Fast.io.

Tutorial: Building a Research Agent with File Storage

Let's build a simple multi-agent system with two agents: a Researcher that gathers data and saves it to a file, and a Reviewer that reads the file and provides feedback. We'll use Fast.io for the shared storage layer.

Step 1: Install Dependencies You will need the OpenAI Agents SDK and the Fast.io MCP adapter. ```bash pip install openai-agents-sdk fastio-mcp


**Step 2: Define the Tools**
We create a tool that the agents can use to save their work. Note how we don't need complex S3 credentials; Fast.io handles the authentication via the agent's environment. ```python
from fastio_mcp import FastIODrive

drive = FastIODrive()

def save_research_notes(filename: str, content: str):
    """Saves research findings to shared storage."""
    drive.write(f"/research/{filename}", content)
    return f"Saved notes to {filename}"

def read_research_notes(filename: str):
    """Reads research notes for review."""
    return drive.read(f"/research/{filename}")

Step 3: Define the Agents Now we wire up the agents. The Researcher has the write tool, and the Reviewer has the read tool. ```python from openai_agents import Agent, run

reviewer = Agent( name="Reviewer", instructions="Read the research notes and provide a critique.", tools=[read_research_notes] )

def transfer_to_reviewer(): """Hand off the task to the reviewer agent.""" return reviewer

researcher = Agent( name="Researcher", instructions="Research the topic, save notes to a file, then hand off to review.", tools=[save_research_notes, transfer_to_reviewer] ) ```

AI agent analyzing data and generating reports

Best Practices for Production Agents

Moving from a notebook to production requires attention to reliability and security. Here are the key practices for deploying OpenAI Agents:

  • Enable Tracing: The SDK has built-in OpenTelemetry support. Enable this to debug why an agent decided to hand off (or failed to). This is essential for understanding the "reasoning path" of complex multi-agent workflows.
  • Use File Locks: When multiple agents access the same Fast.io storage, use file locking tools to prevent race conditions. This ensures data integrity when several specialized agents work on the same project at once.
  • Sandboxing: Agents executing code should run in sandboxed environments. The Agents SDK supports running tool execution in isolated containers, which is an important security measure when agents can generate and run their own scripts.
  • Implement Multi-Layer Security: Beyond sandboxing, use a multi-layer security approach. This includes validating all tool outputs and ensuring that agents do not have excessive permissions to sensitive data. With the Fast.io API, you can control which directories an agent can access, ensuring a principle of least privilege throughout the automated workflow.
  • Human-in-the-Loop: For sensitive actions, configure a tool that requires human approval before execution. Fast.io's ownership transfer feature allows an agent to build a workspace and then transfer full control to a human admin for final review. This bridges the gap between automated efficiency and human accountability.
Multiple users and agents collaborating in a shared workspace

Frequently Asked Questions

What is the OpenAI Agents SDK?

The OpenAI Agents SDK is an open-source Python framework designed to simplify building, orchestrating, and deploying multi-agent AI systems. It replaces the experimental Swarm framework and provides standard patterns for agent handoffs and tool execution.

How does the Agents SDK differ from the Assistants API?

The Assistants API is a fully hosted service where OpenAI manages the message history and tool execution loop. The Agents SDK is a client-side framework that gives you full control over the orchestration logic, state management, and deployment environment.

Can OpenAI agents share files with each other?

Yes, but they need a shared storage layer. By default, agents are stateless. Using a tool like Fast.io allows agents to read and write files to a persistent cloud directory, enabling them to pass documents, data, and media between different agents in a workflow.

Is the OpenAI Agents SDK free?

The SDK itself is open-source and free to use. However, running the agents consumes tokens from the OpenAI API, which are billed based on usage. Additional tools like Fast.io offer free tiers (50GB storage) for agent developers.

Related Resources

Fast.io features

Give Your AI Agents Persistent Storage

Stop losing data when your agent session ends. Get 50GB of free, persistent cloud storage for your OpenAI agents with Fast.io.