Use this file to discover all available pages before exploring further.
The OpenAI Agents SDK is a framework for building agentic workflows. E2B provides a native integration that lets you run SandboxAgent instances inside isolated E2B sandboxes — giving your agents full filesystem, terminal, and network access in a secure environment.To use E2B as the sandbox backend:
Create a sandbox session with E2BSandboxClient.
Build a SandboxAgent with your instructions and model.
Run the agent and pass the sandbox session through RunConfig.
Create an E2BSandboxClient, start a session, and run a SandboxAgent inside it. The agent gets full access to the sandbox environment — it can run commands, read and write files, and inspect the workspace.
Initialize the E2BSandboxClient and create a sandbox session. The pause_on_exit option keeps the sandbox available after the script finishes so you can inspect its state.
Define a SandboxAgent with a name, model, and instructions, then run it against the sandbox session using Runner.run. The result contains the agent’s final output.
from agents import ModelSettings, Runnerfrom agents.run import RunConfigfrom agents.sandbox import SandboxAgent, SandboxRunConfigagent = SandboxAgent( name="Workspace Inspector", model="gpt-5.4", instructions=( "Inspect the workspace, explain what files exist, and summarize the project." ), model_settings=ModelSettings(tool_choice="required"),)result = await Runner.run( agent, "Look around the workspace and summarize what you find.", run_config=RunConfig(sandbox=SandboxRunConfig(session=session)),)print(result.final_output)
A common pattern is to start from the same starter app and create multiple versions in separate sandboxes — useful when comparing a first pass with a polished revision, or generating live preview URLs for each version.Based on the homepage_vite_basic_updated.ipynb notebook from the Agents SDK repo.
A Manifest describes the starter files your agent will work with. Each entry is a File with its content encoded as bytes. This lets you seed multiple sandboxes from the same baseline — useful when comparing different versions of an app.
Build a SandboxAgent with capabilities like ApplyPatch and Shell, then run it against the sandbox session.
from agents import ModelSettings, Runnerfrom agents.run import RunConfigfrom agents.sandbox import SandboxAgent, SandboxRunConfigfrom agents.sandbox.capabilities import ApplyPatch, Shellagent = SandboxAgent( name="E2B Vite Builder", model="gpt-5.4-mini", instructions="Update the Vite app in the sandbox workspace and return a concise summary.", default_manifest=build_manifest(), capabilities=[ApplyPatch(), Shell()], model_settings=ModelSettings(tool_choice="required"),)result = await Runner.run( agent, "Make the basic version now.", run_config=RunConfig(sandbox=SandboxRunConfig(session=session)),)
The complete run_version() helper ties all the steps above together. Call it once per version to get isolated sandboxes with their own preview URLs. Based on the homepage_vite_basic_updated.ipynb notebook from the Agents SDK repo.
from agents import ModelSettings, Runnerfrom agents.run import RunConfigfrom agents.sandbox import Manifest, SandboxAgent, SandboxRunConfigfrom agents.sandbox.capabilities import ApplyPatch, Shellfrom agents.sandbox.entries import Filefrom agents.extensions.sandbox import ( E2BSandboxClient, E2BSandboxClientOptions, E2BSandboxType,)def build_manifest() -> Manifest: return Manifest( entries={ "package.json": File(content=PACKAGE_JSON.encode()), "index.html": File(content=INDEX_HTML.encode()), "vite.config.js": File(content=VITE_CONFIG_JS.encode()), "src/main.tsx": File(content=MAIN_TSX.encode()), "src/App.tsx": File(content=APP_TSX.encode()), } )async def run_version(version_name: str, version_prompt: str) -> dict[str, str]: session = await E2BSandboxClient().create( manifest=build_manifest(), options=E2BSandboxClientOptions( sandbox_type=E2BSandboxType.E2B, timeout=1800, exposed_ports=(4173,), allow_internet_access=True, pause_on_exit=True, ), ) await session.start() agent = SandboxAgent( name=f"E2B Vite {version_name.title()} Builder", model="gpt-5.4-mini", instructions=( "Update the Vite app in the sandbox workspace and return a concise summary." ), developer_instructions=( f"Version goal: {version_prompt}\n" "Start from the tiny Vite starter. You may create src/styles.css if you want." ), default_manifest=build_manifest(), capabilities=[ApplyPatch(), Shell()], model_settings=ModelSettings(tool_choice="required"), ) result = await Runner.run( agent, f"Make the {version_name} version now.", run_config=RunConfig(sandbox=SandboxRunConfig(session=session)), ) await session.exec( "sh", "-lc", ( "npm install >/tmp/e2b-demo-npm-install.log 2>&1 && " "nohup npm run dev -- --host 0.0.0.0 --port 4173 " ">/tmp/e2b-demo-vite.log 2>&1 &" ), shell=False, timeout=120, ) preview_url = (await session.resolve_exposed_port(4173)).url_for("http") return { "summary": str(result.final_output), "preview_url": preview_url, }
You can create sandboxes with MCP servers enabled, then connect the Agents SDK to the sandbox’s MCP gateway. This gives you an agent that can discover sources with search-oriented MCP servers, verify pages in a browser, and keep all of that execution inside the sandbox.The Agents SDK repo includes a concrete example in deep_research_mcp.py.
Use one coordinator agent to launch multiple specialized review or analysis lanes across separate sandboxes. Each lane runs in its own isolated environment, and the coordinator synthesizes the results into a single summary.The Agents SDK repo includes a concrete example in fullstack_code_review_parallel.py. That example uses separate E2B-backed lanes for frontend review, backend review, and git tree review.
Create specialized SandboxAgent instances for each review lane, plus a regular Agent as the coordinator that will synthesize the results.
from agents import Agentfrom agents.sandbox import SandboxAgentfrontend_agent = SandboxAgent( name="Frontend Reviewer", model="gpt-5.4", instructions="Review the rendered frontend and identify UX and code risks.",)backend_agent = SandboxAgent( name="Backend Reviewer", model="gpt-5.4", instructions="Review the API implementation and identify validation and auth risks.",)coordinator = Agent( name="Review Coordinator", model="gpt-5.4", instructions=( "Run the available review lanes, compare their evidence, and produce a single summary." ),)