Learning resourcesReviewed · E2B

Running Prime Agent in an E2B sandbox (E2B guide)

This is E2B's documentation guide for developers who want to run Prime Intellect's open-source Prime Agent coding agent inside an isolated E2B cloud sandbox, and its main catch is that Prime Agent has no approval prompts while sandboxes can reach the internet by default. The page covers the pre-built prime template, the prime-agent command, headless and JSON streaming modes, session resume, and building a custom template with the TypeScript or Python SDK.

Researched 15 Nov 2026

In short.

This is E2B's documentation page on running Prime Intellect's open-source Prime Agent coding and research agent inside an E2B sandbox. It is for developers who want to run an agent that executes model-written code without approval prompts, away from their own machine. The main catch is that the sandbox protects your host but not the sandbox's network access: internet is on by default, so you must set outbound rules and manage API keys and tokens yourself. The page describes a pre-built E2B template named prime with Prime Agent installed, a prime-agent command, headless mode (-p), a JSON event stream (--mode json), an RPC mode, session resume flags, and a way to extend the template. It gives TypeScript and Python SDK examples. Nothing here was run or tested. Costs, licence terms, versions and release dates are not stated on the page.

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

Covers exactly the complete page at [https://docs.e2b.dev/agents/prime.md] as captured on 15 November 2026. Pages it links to are excluded: the Prime Agent GitHub repository, the E2B CLI guide, the network and internet access guide, the sandbox persistence guide, the SSH access guide and the documentation index. No licence or notice file was captured, so rights are reported as unstated. Nothing described was executed, so all behaviour (commands, flags, JSON events, session resume, template builds, network rules, credential retention) is as documented, not verified. Costs, versions and release dates are not given on the page and are reported as unknown.

The overview

What this resource is

This is a single documentation page at [https://docs.e2b.dev/agents/prime.md] titled Prime Agent. It says it shows how to run Prime Agent in a secure E2B sandbox with full filesystem, terminal and git access.

The page describes Prime Agent [https://github.com/PrimeIntellect-ai/prime-agent] as Prime Intellect's open-source coding and research agent for general and long-running work, built around a persistent IPython kernel and recursive subagents. E2B provides a pre-built template called prime that already has Prime Agent installed. The page is a how-to guide, not the agent's own documentation. The author of the page is E2B. The page does not name a version of Prime Agent, the template or the E2B SDK.

Overall assessment

For its narrow purpose the page is practical and fairly complete. It covers interactive use, one-shot headless runs, a streaming event format, session continuation and template customisation, with matching TypeScript and Python examples. It is also direct about the main risk: Prime Agent has no approval prompts and no auto-approve flag, and runs model-generated Python and project commands with the permissions of the user it runs as.

Its weak points are what it leaves out. It gives no costs, no licence statement, no version numbers and no troubleshooting. Some snippets also depend on setup shown only elsewhere on the page (see example and limitations). This assessment comes from reading the page only. None of the commands or code were run, so the page's claims about behaviour are unverified.

Who it is for

The page suits developers who already use, or plan to use, E2B sandboxes and want to run Prime Agent unattended or in automation, for example inside a backend job, a CI-like pipeline or a service that hands tasks to an agent. The SDK examples assume you can write basic TypeScript or Python and are comfortable with environment variables and API keys.

A beginner can follow the CLI route (create a sandbox, start prime-agent, log in). The SDK, JSON streaming and template sections assume more experience. The page does not say who should avoid this setup, but anyone who cannot manage outbound network rules and secrets carefully should treat the catch described under limitations as important.

What the page shows you how to do

Interactive use: create a sandbox from the prime template with the E2B CLI, then start prime-agent inside it.

Headless use: run prime-agent -p with a prompt to print the response and exit. The page says you choose a model provider and model with --provider and --model.

Streaming: --mode json produces a JSONL event stream. The page lists a session header followed by events named agent_start, turn_start, message_start, message_update, message_end, tool_execution_start, tool_execution_end, turn_end and agent_end. --mode rpc is described as exposing the same session over stdin/stdout for bidirectional integrations.

Sessions: sessions are saved to disk and run behind a background daemon. -c continues the most recent session, -r with a path or id resumes a specific one, and prime-agent agents and prime-agent attach list and reattach to agents still running in the sandbox.

Customisation: build your own template on top of the prime template to pre-install dependencies or add config files, with the example setting 2 CPUs and 2048 MB of memory.

Using it

Requirements

Stated or clearly implied by the page: an E2B account and access to either the E2B CLI, for which the page links to a guide at [https://docs.e2b.dev/cli.md], or the e2b SDK for TypeScript or Python; and a way for Prime Agent to reach a model. For models, either run /login on first launch to pick a subscription (Claude Pro/Max, ChatGPT Plus/Pro, GitHub Copilot) or an API-key provider, or set provider environment variables such as ANTHROPIC_API_KEY, OPENAI_API_KEY, GEMINI_API_KEY, XAI_API_KEY or OPENROUTER_API_KEY, or PRIME_API_KEY for Prime Inference.

The repository-cloning example also needs a GITHUB_TOKEN and a repository you can access. The examples read keys from the calling machine's environment. Node.js tooling is implied by the npx tsx build.ts command, and Python by python build.py. Minimum versions of these tools, how E2B authenticates the CLI or SDK, and account or plan requirements are not stated on the page.

How it works

E2B runs an isolated sandbox from a template. The prime template has Prime Agent preinstalled. Your code (or the CLI) creates the sandbox, optionally passes environment variables such as a provider API key, and runs shell commands inside it. In the SDK examples that is sandbox.commands.run with a prime-agent command, followed by sandbox.kill() to end the sandbox.

Inside the sandbox, Prime Agent talks to the chosen model provider and executes model-generated Python (through its persistent IPython kernel) and project commands as the sandbox user. The page says the sandbox keeps this away from your host machine, local files and credentials. It also says sandboxes can reach the open internet by default, and that you can limit this with outbound network rules (allowInternetAccess, plus allow and deny lists by CIDR or hostname). Hostname rules apply to HTTP(S) traffic only, so CIDR rules are needed for other protocols.

Prime Agent runs behind a background daemon and saves sessions to disk, which is how follow-up commands with -c or -r can pick up earlier work in the same long-lived sandbox. How the daemon, the kernel and the subagents work internally is not covered here; that would be in the Prime Agent repository, which this page only links to.

Setup

CLI route as written on the page: run e2b sbx create prime to create a sandbox, then run prime-agent inside it. On first launch, run /login to choose a subscription or an API-key provider.

SDK route: install the e2b package for your language, call Sandbox.create with the template name prime and an envs object holding the provider key, then call commands.run with a prime-agent command. The page does not show the install commands for the SDK or CLI, nor how to authenticate to E2B.

Custom template route: write a template file that starts from the prime template (fromTemplate in TypeScript, from_template in Python), then a build script that calls Template.build with a new name such as my-prime, plus CPU and memory settings and a build logger. Run it with npx tsx build.ts or python build.py. The page does not show how to add dependencies or config files beyond saying that this is the purpose, so those steps are unknown from this page.

Worked example from the page

The cloned-repository example creates a sandbox from prime with ANTHROPIC_API_KEY set and a 600-second timeout (timeoutMs 600_000 in TypeScript, timeout=600 in Python). It clones a repository with git clone --depth 1 using a GitHub token supplied only for that command, then runs prime-agent -p with the prompt Add error handling to all API endpoints, streams the output, runs git diff to show what changed, and finally kills the sandbox. This makes the diff the way you review the agent's work.

Two points the page does not spell out. First, the streaming JSON and session examples run cd /home/user/repo, but only the clone example creates that directory, so you would need to set it up first. Second, the example includes GITHUB_TOKEN in the clone URL. Whether the token remains in repository configuration or other files is unknown from this page; credential retention was not tested. Consider a token with the narrowest access you can use, and think about whether the agent should be able to see it.

The JSON streaming examples parse each stdout chunk as whole JSON lines. If a chunk ends partway through a line, the parsing would fail, so a production integration would probably need to buffer by line. This is an observation from reading the code, not a tested result.

Assessment & evidence

Limitations and risks

The most important point on the page is that Prime Agent has no auto-approve flag: it runs model-generated Python and project commands with the permissions of its user, without approval prompts. The sandbox protects your host machine, local files and credentials. It does not stop the agent from using anything placed inside the sandbox: API keys passed as environment variables, a GitHub token, repository contents, or open network access. Internet access is on by default, so an unattended agent can send data out unless you set outbound rules. Hostname rules cover HTTP(S) only.

The page does not describe what protects secrets inside the sandbox or how to scope tokens. The repository-cloning and session examples explicitly set 600-second timeouts and finish with sandbox.kill(). The page does not explain data retention, recovery or timeout behaviour. They display git diff, but do not document a complete artifact-export procedure. The related guide on sandbox persistence [https://docs.e2b.dev/sandbox/persistence.md] is linked but not covered here.

Other gaps: no versions, no error handling, no limits on usage, no detail on the supported provider and model names beyond the flags, and no troubleshooting. The page was captured as one snapshot and nothing was run, so the commands, flags and event names are as documented, not verified.

Reasoning behind this assessment

The page is a vendor's integration guide, so it is a good source for how to launch and drive the agent in E2B but not for judging how well Prime Agent codes or researches. It offers no benchmarks, comparisons or results, so none are claimed here.

The risk statements are taken directly from the page, which is candid that the agent runs commands without approval and that internet access is open by default. The notes on the repository path and chunked JSON parsing are inferences from reading the code. They are flagged as such and are not tested. Whether the GitHub token included in the clone URL remains in repository configuration or other files is reported as unknown, because the page does not say and credential retention was not tested.

Alternatives

The page does not compare Prime Agent or E2B with anything, so no specific alternatives are assessed from this evidence. Options in general terms: run Prime Agent on your own machine or in your own container setup (the page says upstream recommends a sandbox because there are no approvals); use a different sandbox or container provider; or use a coding agent that asks for approval before running commands. How these compare on cost, isolation, speed or output quality is not assessed here.

Evidence used

One retained file: the full text of [https://docs.e2b.dev/agents/prime.md] (evidence_479013e2-9a7c-4d0b-8209-2d983c0f0e34), 9,961 bytes, captured 15 November 2026. It includes the prose, CLI commands and the TypeScript and Python code examples. Every statement in this report comes from that page, except where marked as an inference from reading the code shown. No linked page, the Prime Agent repository, release notes or a licence file was read, and no commands were run.

Access & freshness

Costs

The page states no prices. It does not say what E2B sandboxes cost, whether the prime template is free, or what a long-running session would use. Those costs are unknown from this evidence.

Model costs are also unstated. The page says /login can use subscriptions (Claude Pro/Max, ChatGPT Plus/Pro, GitHub Copilot) or an API-key provider, and mentions PRIME_API_KEY for Prime Inference. Billing for each of these, and whether a subscription login can be used in an unattended sandbox under its provider's terms, is not covered. Because the agent can run long and recursive tasks, usage could be significant, but the page gives no figures. Check E2B's and your model provider's current pricing before relying on it.

Rights and licence

The page calls Prime Agent open source but does not state a licence for Prime Agent, the prime template, the E2B SDK examples or the documentation itself. Reuse, redistribution and commercial-use terms are therefore unknown from this evidence. Check the licence in the Prime Agent repository [https://github.com/PrimeIntellect-ai/prime-agent] and E2B's terms before copying code, redistributing the template or using it commercially. Using model providers through /login or API keys also falls under those providers' own terms, which the page does not cover.

Freshness

The snapshot was taken on 15 November 2026. The page shows no publication or last-updated date and names no versions for Prime Agent, the prime template, the E2B CLI or the e2b SDK. How current the commands, flags (-p, -c, -r, --mode json, --mode rpc, --provider, --model), environment variables and SDK calls are is therefore unknown. Because the agent and the template can change independently, compare the page against the current Prime Agent repository and E2B documentation before depending on any specific flag or event name.

Suggested next steps

Before you try it: read the Prime Agent repository and its licence, E2B's pricing, and E2B's network rules guide at [https://docs.e2b.dev/network/internet-access.md]. Decide how outbound traffic should be limited, and use a provider key and GitHub token with the narrowest scope and a spending cap if one is available.

To evaluate: start with a throwaway repository and the CLI route, review git diff after each run, then move to headless runs and the SDK. If you build an integration on --mode json, buffer stdout by line before parsing. If you need work to persist across sandbox lifetimes, read the persistence guide first, and build a custom template once you know which dependencies the agent needs.

Evidence for this report

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