MCPcopy
hub / github.com/openai/openai-agents-python

github.com/openai/openai-agents-python @v0.17.7 sqlite

repository ↗ · DeepWiki ↗ · release v0.17.7 ↗
13,998 symbols 78,705 edges 783 files 3,527 documented · 25%
README

OpenAI Agents SDK PyPI

The OpenAI Agents SDK is a lightweight yet powerful framework for building multi-agent workflows. It is provider-agnostic, supporting the OpenAI Responses and Chat Completions APIs, as well as 100+ other LLMs.

Image of the Agents Tracing UI

[!NOTE] Looking for the JavaScript/TypeScript version? Check out Agents SDK JS/TS.

Core concepts:

  1. Agents: LLMs configured with instructions, tools, guardrails, and handoffs
  2. Sandbox Agents: Agents preconfigured to work with a container to perform work over long time horizons.
  3. Agents as tools / Handoffs: Delegating to other agents for specific tasks
  4. Tools: Various Tools let agents take actions (functions, MCP, hosted tools)
  5. Guardrails: Configurable safety checks for input and output validation
  6. Human in the loop: Built-in mechanisms for involving humans across agent runs
  7. Sessions: Automatic conversation history management across agent runs
  8. Tracing: Built-in tracking of agent runs, allowing you to view, debug and optimize your workflows
  9. Realtime Agents: Build powerful voice agents with gpt-realtime-2 and full agent features

Explore the examples directory to see the SDK in action, and read our documentation for more details.

Get started

To get started, set up your Python environment (Python 3.10 or newer required), and then install OpenAI Agents SDK package.

venv

python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
pip install openai-agents

For voice support, install with the optional voice group: pip install 'openai-agents[voice]'. For Redis session support, install with the optional redis group: pip install 'openai-agents[redis]'.

uv

If you're familiar with uv, installing the package would be even easier:

uv init
uv add openai-agents

For voice support, install with the optional voice group: uv add 'openai-agents[voice]'. For Redis session support, install with the optional redis group: uv add 'openai-agents[redis]'.

Run your first Sandbox Agent

Sandbox Agents are new in version 0.14.0. A sandbox agent is an agent that uses a computer environment to perform real work with a filesystem, in an environment you configure and control. Sandbox agents are useful when the agent needs to inspect files, run commands, apply patches, or carry workspace state across longer tasks.

from agents import Runner
from agents.run import RunConfig
from agents.sandbox import Manifest, SandboxAgent, SandboxRunConfig
from agents.sandbox.entries import GitRepo
from agents.sandbox.sandboxes import UnixLocalSandboxClient

agent = SandboxAgent(
    name="Workspace Assistant",
    instructions="Inspect the sandbox workspace before answering.",
    default_manifest=Manifest(
        entries={
            "repo": GitRepo(repo="openai/openai-agents-python", ref="main"),
        }
    ),
)

result = Runner.run_sync(
    agent,
    "Inspect the repo README and summarize what this project does.",
    # Run this agent on the local filesystem
    run_config=RunConfig(sandbox=SandboxRunConfig(client=UnixLocalSandboxClient())),
)
print(result.final_output)

# This project provides a Python SDK for building multi-agent workflows.

(If running this, ensure you set the OPENAI_API_KEY environment variable)

(For Jupyter notebook users, see hello_world_jupyter.ipynb)

Explore the examples directory to see the SDK in action, and read our documentation for more details.

Acknowledgements

We'd like to acknowledge the excellent work of the open-source community, especially:

This library has these optional dependencies:

We also rely on the following tools to manage the project:

We're committed to continuing to build the Agents SDK as an open source framework so others in the community can expand on our approach.

Core symbols most depended-on inside this repo

get
called by 824
src/agents/sandbox/session/dependencies.py
run
called by 419
tests/voice/fake_models.py
run
called by 282
examples/realtime/cli/demo.py
function_tool
called by 269
src/agents/tool.py
add_multiple_turn_outputs
called by 242
tests/fake_model.py
add
called by 218
src/agents/usage.py
set_next_output
called by 216
tests/fake_model.py
stream_events
called by 205
tests/fastapi/streaming_app.py

Shape

Function 6,387
Method 5,745
Class 1,742
Route 124

Languages

Python100%
TypeScript1%

Modules by API surface

tests/extensions/sandbox/test_blaxel.py371 symbols
tests/test_run_state.py279 symbols
tests/extensions/sandbox/test_runloop.py255 symbols
tests/sandbox/test_runtime.py254 symbols
tests/test_agent_runner.py229 symbols
tests/models/test_openai_responses.py213 symbols
tests/extensions/sandbox/test_modal.py184 symbols
tests/sandbox/test_docker.py183 symbols
tests/realtime/test_session.py183 symbols
tests/extensions/sandbox/test_e2b.py181 symbols
tests/test_run_step_execution.py160 symbols
tests/extensions/sandbox/test_daytona.py154 symbols

Dependencies from manifests, versioned

fastapi0.120.0 · 1×
openai2.2 · 1×

Datastores touched

(mongodb)Database · 1 repos
(mysql)Database · 1 repos

For agents

$ claude mcp add openai-agents-python \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact