Back to Openai Agents Python

Sandbox examples

examples/sandbox/README.md

0.15.33.9 KB
Original Source

Sandbox examples

These examples show how to run agents with an isolated workspace. Start with the small API examples when you want the smallest surface area, or use the tutorial scaffold when you want the shared layout for guided sandbox tutorials.

Most examples call a model through Runner, so set OPENAI_API_KEY in the repository-root .env file, in the example's .env file when it has one, or in your shell environment.

Small API examples

ExampleRunWhat it shows
basic.pyuv run python examples/sandbox/basic.pyCreates a sandbox session from a manifest, runs a SandboxAgent, and streams the result.
handoffs.pyuv run python examples/sandbox/handoffs.pyUses handoffs with sandbox-backed agents.
sandbox_agent_capabilities.pyuv run python examples/sandbox/sandbox_agent_capabilities.pyConfigures a sandbox agent with workspace capabilities.
sandbox_agent_with_tools.pyuv run python examples/sandbox/sandbox_agent_with_tools.pyCombines sandbox capabilities with host-defined tools.
sandbox_agents_as_tools.pyuv run python examples/sandbox/sandbox_agents_as_tools.pyExposes sandbox agents as tools for another agent.
sandbox_agent_with_remote_snapshot.pyuv run python examples/sandbox/sandbox_agent_with_remote_snapshot.pyStarts from a remote sandbox snapshot.
memory.pyuv run python examples/sandbox/memory.pyRuns one sandbox agent twice across a snapshot resume so it can read and write its own memory.
memory_s3.pysource ~/.s3.env && uv run python examples/sandbox/memory_s3.pyRuns sandbox memory across two fresh Docker sandboxes with S3-backed memory storage.
memory_multi_agent_multiturn.pyuv run python examples/sandbox/memory_multi_agent_multiturn.pyShows separate memory layouts for two agents sharing one sandbox workspace.
unix_local_pty.pyuv run python examples/sandbox/unix_local_pty.pyExercises an interactive pseudo-terminal in a Unix-local sandbox.
unix_local_runner.pyuv run python examples/sandbox/unix_local_runner.pyRuns against the Unix-local sandbox backend directly.

Cloud backend examples

Cloud-provider examples live under extensions/. They cover E2B, Modal, and Daytona sandbox backends and require provider-specific credentials in addition to OPENAI_API_KEY.

Tutorial scaffold

tutorials/ contains the shared helper code, Docker image, and folder conventions for guided sandbox tutorials. Tutorial folders are added in separate focused changes.

Tutorials

ExampleWhat it does
sandbox_resumeEdits a workspace app and reuses a sandbox snapshot.
dataroom_qaAnswers questions over a mounted dataroom with source-backed responses.
dataroom_metric_extractExtracts structured financial metrics to CSV/JSONL.
repo_code_reviewReviews a sample repo and writes finding, report, and patch artifacts.
vision_website_cloneUses vision and a browser-review loop to clone a reference static website.

Workflow examples

ExampleWhat it does
healthcare_supportRuns a synthetic healthcare support workflow with a standard orchestrator, sandbox policy agent, memory, and human approvals.

Shared files

  • docker/ contains Docker-specific helper examples.
  • misc/ contains reusable support code and tiny reference tools used by several sandbox examples.