Learning resourcesReviewed · E2B

E2B sandboxes with the OpenAI Agents SDK

This guide teaches Python developers to run OpenAI agents in E2B sandboxes, but its advanced examples require configuration and definitions that the page does not supply. It covers workspace inspection, app variants with live previews, research tools connected through MCP, and separate code review workers.

Researched 25 Nov 2026

In short.

This guide helps Python developers give OpenAI agents an E2B environment for commands and files, but its advanced examples are incomplete on their own. The basic script shows session creation, agent execution and cleanup. Later examples cover Vite app variants, Browserbase and Exa research through MCP, and coordinated code review. Missing starter-file contents and gateway configuration limit direct reuse, and the displayed review calls run sequentially despite the parallel-worker description. Package compatibility, costs, licensing and runtime behavior are not established.

Researched and written by an AI model and checked by a second AI model. How it works

Covers the entire selected documentation page at [https://docs.e2b.dev/agents/openai-agents-sdk.md], including its basic example, app variants, MCP research, review workers and reference links. Linked pages, the documentation index, repository files and third-party services are excluded. No explicit licensing or deprecation notice appears in the supplied page. No code was executed; compatibility, isolation, tool behavior, generated output and live previews remain untested.

The overview

Identity

The resource is E2B's OpenAI Agents SDK documentation page [https://docs.e2b.dev/agents/openai-agents-sdk.md]. It explains how to use E2B as the sandbox backend for SandboxAgent instances in the Python OpenAI Agents SDK.

Its central integration connects an E2BSandboxClient session to an agent run through SandboxRunConfig and RunConfig. The page combines introductory instructions with larger application and research examples.

Assessment

The guide provides a concrete starting point for developers whose agents need a workspace where they can inspect files, edit code and run commands. Its strongest introductory example includes imports, asynchronous execution and cleanup in a finally block.

The advanced sections are useful implementation outlines, but require additional work. The app example omits starter-file contents, the MCP example assumes gateway connection values, and the review example does not demonstrate concurrent scheduling. None of the examples was executed for this report.

Users

The intended readers are Python developers building agents that work with files, terminals or external tools. Concrete uses include inspecting a project, generating multiple versions of a web app, gathering research through search and browser tools, and assigning specialized code reviews.

Beginners receive a basic session lifecycle example, but need familiarity with Python packages, environment variables and asynchronous functions. The app and research sections additionally assume knowledge of Vite, npm, service credentials and MCP, a protocol for connecting agents to tools.

Capabilities

The page documents agent access to files, terminal commands and networking inside an E2B sandbox. It shows explicit ApplyPatch and Shell capabilities for editing and running a Vite app.

A Manifest supplies starter files as bytes so separate sessions can begin with the same project. The app example exposes port 4173 and resolves it to an HTTP preview URL.

Additional examples configure Browserbase and Exa through an MCP gateway, and pass separate reviewers' final outputs to a coordinator agent. These are documented workflows; their output quality and reliability are not demonstrated by results on the page.

Using it

Requirements

The stated installation is pip install openai-agents[e2b]. Basic use requires OPENAI_API_KEY and E2B_API_KEY. The page does not specify a Python version, a compatible SDK release or a dependency lockfile.

The Vite workflow uses npm inside the sandbox, enables internet access and exposes port 4173. Its PACKAGE_JSON, INDEX_HTML, VITE_CONFIG_JS, MAIN_TSX and APP_TSX constants must be supplied separately.

The research configuration references BROWSERBASE_API_KEY, GEMINI_API_KEY, BROWSERBASE_PROJECT_ID and EXA_API_KEY. It also requires an MCP gateway URL and bearer token, whose acquisition is not explained on this page.

Mechanism

E2BSandboxClient creates the execution session. SandboxAgent defines the model, instructions and optional capabilities. Runner.run receives the session through RunConfig(sandbox=SandboxRunConfig(session=session)), and result.final_output supplies the agent's final response.

For research, MCPServerStreamableHttp connects to the sandbox gateway with an Authorization bearer header. Passing that connection through mcp_servers makes the configured tools available to the agent.

For coordinated reviews, each reviewer uses its own session and the coordinator receives the reviewers' final outputs as text. The displayed code awaits the frontend review and then the backend review, so it does not demonstrate concurrent execution.

Setup

The basic setup installs the E2B extra, sets the two API keys, creates an E2BSandboxClient session, defines a SandboxAgent and passes the session into Runner.run. The full basic script wraps execution in try/finally and calls session.shutdown() to release resources.

The app workflow additionally builds a Manifest, creates and starts a session, enables internet access and exposes the preview port. It then runs the agent, invokes npm installation and starts a Vite server before resolving the preview URL.

The basic script explicitly shuts down the session even though pause_on_exit=True is set. The larger app and research examples do not show equivalent cleanup; readers need to decide when their sessions and previews should end.

Example

The Workspace Inspector example creates a session, asks a SandboxAgent to inspect the workspace and summarize its files, prints result.final_output, and shuts the session down in a finally block. It specifies gpt-5.4 and ModelSettings(tool_choice="required"). No example output is included.

The run_version helper illustrates a larger use case: seed a sandbox with a Vite starter, use gpt-5.4-mini with ApplyPatch and Shell to modify it, start a preview server, and return a summary and preview URL. Calling the helper for different versions is the proposed way to obtain separate workspaces.

The helper depends on starter constants absent from the page. Successful app generation, dependency installation and preview availability remain untested.

Assessment & evidence

Limitations

The advanced snippets have missing dependencies beyond package installation. The app starter constants are undefined, and the MCP full example assumes an initialized client, os, mcp_url and mcp_token. The review example assumes frontend_session and backend_session already exist.

The page describes isolated, secure execution but does not explain the isolation design, data retention, preview URL access controls or CPU and memory limits. Security properties are not independently established by the supplied material.

The preview command launches a background server, but the snippet shows no readiness check before returning its URL. The review code uses sequential awaits. No execution results, performance measurements or failure-recovery tests are supplied.

Fit and tradeoffs

The integration is most relevant when an agent's task requires changing files, installing dependencies or running tools in a separate workspace. The Manifest mechanism gives app variants a common starting point, while separate sessions keep their working files apart.

MCP extends the available research tools, and specialized reviewers divide a larger task into focused assignments. These patterns introduce more credentials, sessions and lifecycle decisions. The page does not demonstrate that they improve accuracy, speed or cost.

A reader can assess whether the architecture fits a project from these examples, but deployment readiness depends on compatibility, configuration and operational behavior that remain unassessed.

Alternatives

The documented patterns include a single workspace agent, separate app-generation sessions, MCP-connected research and specialized review agents with a coordinator. The simplest workspace example has fewer configuration dependencies than the research and app workflows.

The page provides no comparison with other sandbox providers, agent frameworks or local execution. Relative pricing, performance, portability and security are unknown.

Evidence

The evidence is the complete documentation page at [https://docs.e2b.dev/agents/openai-agents-sdk.md]. It contains installation instructions, Python snippets and links to repository examples.

The page supports descriptions of the documented APIs and intended workflows. It supplies no observed agent outputs, successful-run logs, benchmarks or security evaluation results. The linked notebooks, Python files, package pages and external service documentation are outside the evidence considered here.

Access & freshness

Costs

Costs are unknown. The page provides no prices, free allowances, billing units or total-cost examples for OpenAI, E2B or the optional research services.

The examples involve model requests, sandbox sessions and potentially Browserbase, Exa and Gemini-related usage. Their applicable charges require separate confirmation. Timeout and pause settings do not establish billable duration, storage charges or the cost of keeping previews available.

Rights

The captured page contains no explicit license or redistribution grant for its prose or code examples. Permission to redistribute the page or reuse substantial example code is therefore not established by this evidence.

The applicable SDK license, E2B service terms and third-party service terms are also unknown here. Links to repository examples do not establish the terms governing those files.

Freshness

The supplied page was captured on 25 November 2026 at 22:22:40.697 UTC. That establishes the capture time; the page supplies no publication date, last-update date or compatible SDK release.

The snippets name gpt-5.4 and gpt-5.4-mini and link to repository files on the main branch. No model availability information or release-pinned compatibility matrix is provided. Present-day API compatibility remains unknown.

Next steps

Begin with the Workspace Inspector example after confirming the required Python and SDK versions, model access, API credentials and service costs. Keep its try/finally cleanup pattern when adapting it.

For app variants, supply the missing starter-file contents, define session cleanup and confirm server readiness before relying on a preview URL. For research, obtain the gateway URL and token and configure the additional service credentials.

If concurrent reviews are required, add concurrent scheduling to the displayed sequential calls and define how each session is created and closed. Confirm applicable licenses and service terms before redistributing material or adopting the integration.

Evidence for this report

selected-page.txtselected · checked 2026-11-25