|
| 1 | +--- |
| 2 | +title: Quickstart |
| 3 | +description: Create your first sandbox agent with an isolated workspace, filesystem tools, shell commands, and sandbox session state. |
| 4 | +--- |
| 5 | + |
| 6 | +import { Aside, Code } from '@astrojs/starlight/components'; |
| 7 | +import basicExample from '../../../../../examples/docs/sandbox-agents/basic.ts?raw'; |
| 8 | + |
| 9 | +<Aside type="caution" title="Beta feature"> |
| 10 | + Sandbox agents are in beta. API details, defaults, and supported capabilities |
| 11 | + may change before general availability, and more advanced features are |
| 12 | + expected over time. |
| 13 | +</Aside> |
| 14 | + |
| 15 | +Modern agents work best when they can operate on real files in a filesystem. **Sandbox Agents** in the Agents SDK give the model a persistent workspace where it can search large document sets, edit files, run commands, generate artifacts, and pick work back up from saved sandbox state. |
| 16 | + |
| 17 | +The SDK gives you that execution harness without making you wire together file staging, filesystem tools, shell access, sandbox lifecycle, snapshots, and provider-specific glue yourself. You keep the normal `Agent` and `Runner` flow, then add a `Manifest` for the workspace, capabilities for sandbox-native tools, and the `sandbox` run option for where the work runs. |
| 18 | + |
| 19 | +## Prerequisites |
| 20 | + |
| 21 | +- Node.js 22 or higher. |
| 22 | +- Basic familiarity with the OpenAI Agents SDK. |
| 23 | +- A sandbox client. For local development, start with `UnixLocalSandboxClient`. |
| 24 | + |
| 25 | +## Installation |
| 26 | + |
| 27 | +If you have not already installed the SDK: |
| 28 | + |
| 29 | +```bash |
| 30 | +npm install @openai/agents |
| 31 | +``` |
| 32 | + |
| 33 | +For Docker-backed sandboxes, install Docker locally and use `DockerSandboxClient` from `@openai/agents/sandbox/local`. |
| 34 | + |
| 35 | +If you use interactive local PTY sessions with `tty: true`, the process running the SDK also needs Python 3 available as `python3`, or through `OPENAI_AGENTS_PYTHON`. Non-PTY shell commands do not require Python. |
| 36 | + |
| 37 | +## Create a local sandbox agent |
| 38 | + |
| 39 | +This example stages a local repo under `repo/`, loads local skills lazily, and lets the runner create a Unix-local sandbox session for the run. |
| 40 | + |
| 41 | +<Code |
| 42 | + lang="typescript" |
| 43 | + code={basicExample} |
| 44 | + title="Create a local sandbox agent" |
| 45 | +/> |
| 46 | + |
| 47 | +The example is intentionally shaped like the Python SDK quickstart: the agent definition owns the manifest and capabilities, while the run config only chooses the sandbox client for this run. |
| 48 | + |
| 49 | +## Key choices |
| 50 | + |
| 51 | +Once the basic run works, the choices most people reach for next are: |
| 52 | + |
| 53 | +- `defaultManifest`: the files, repos, directories, and mounts for fresh sandbox sessions. |
| 54 | +- `instructions`: short workflow rules that should apply across prompts. |
| 55 | +- `baseInstructions`: an advanced escape hatch for replacing the SDK sandbox prompt. |
| 56 | +- `capabilities`: sandbox-native tools such as filesystem editing/image inspection, shell, skills, memory, and compaction. |
| 57 | +- `runAs`: the sandbox user identity for model-facing tools. |
| 58 | +- `sandbox.client`: the sandbox backend. |
| 59 | +- `sandbox.session`, `sandbox.sessionState`, or `sandbox.snapshot`: how later runs reconnect to prior work. |
| 60 | + |
| 61 | +## Where to go next |
| 62 | + |
| 63 | +- [Concepts](/openai-agents-js/guides/sandbox-agents/concepts): understand manifests, capabilities, permissions, snapshots, run config, and composition patterns. |
| 64 | +- [Sandbox clients](/openai-agents-js/guides/sandbox-agents/clients): choose Unix-local, Docker, hosted providers, and mount strategies. |
| 65 | +- [Agent memory](/openai-agents-js/guides/sandbox-agents/memory): preserve and reuse lessons from previous sandbox runs. |
| 66 | + |
| 67 | +If shell access is only one occasional tool, start with hosted shell in the [Tools guide](/openai-agents-js/guides/tools). Reach for sandbox agents when workspace isolation, sandbox client choice, or sandbox-session resume behavior are part of the design. |
0 commit comments