Skip to main content
The OpenAI Agents SDK is OpenAI’s framework for building agents with tool-use loops. Expose sandbox.commands.run as a function tool so every command the agent generates runs in an isolated VM instead of on your machine.

Setup

The agent loop runs on your machine, so the OpenAI Agents SDK reads OPENAI_API_KEY from your local environment. Only the commands that the agent runs go to the sandbox.

Wire the sandbox into the agent

The highlighted block defines a bash tool backed by the sandbox. Everything else is standard OpenAI Agents SDK usage.
Add equivalent tools for file reads/writes the same way; see Run commands and Read & write files.