Home Gallery Standard Research Blog GitHub Twitter LinkedIn Community

e2b-cookbook system prompt

Category: Coding agents. Audited against the AISPA standard.

What is in e2b-cookbook's system prompt?

e2b-cookbook's full system prompt: 1 version, 8,854 characters. 1 instruction flagged, worst on tool/action safety.

The full text of 1 prompt is reproduced below, 8,854 characters in all, each read instruction by instruction against the eight AISPA dimensions. 1 instruction was flagged as working against the person on the other end, most of them on tool/action safety.

1 Prompts on record
1 Flagged instructions
AI audit Audit source
D4 · Tool/Action Safety

e2b-cookbook - examples anthropic managed agents javascript IM...

8854 characters · 1 flagged

# Functions to Implement This is the implementation checklist for wiring Anthropic Managed Agents self-hosted environments to E2B in JavaScript or TypeScript. The local example implements these functions under [`src/`](./src/). ## 1. Load Runtime Configuration Implement `loadSettings()`. It should load local environment variables and return a typed settings object with: | Setting | Required for | | --- | --- | | `ANTHROPIC_API_KEY` | Creating agents, creating environments, sending sessions, updating environment metadata. | | `ANTHROPIC_AGENT_ID` | Sending a session message. | | `ANTHROPIC_ENVIRONMENT_ID` | Starting workers, sending sessions, metadata lookup. | | `ANTHROPIC_ENVIRONMENT_KEY` | Running the self-hosted environment worker. | | `ANTHROPIC_WEBHOOK_SIGNING_KEY` | Verifying real webhook deliveries. | The example reads the repository root `.env` first, then the example-local `.env`. ## 2. Create the Anthropic Environment Implement `createSelfHostedEnvironment({ apiKey, name })`. It should call: ```ts client.beta.environments.create({ name, config: { type: "self_hosted" }, }); ``` Print the returned `environment.id` as `ANTHROPIC_ENVIRONMENT_ID`, then send the user to [Anthropic Environments](https://platform.claude.com/workspaces/default/environments) to generate `ANTHROPIC_ENVIRONMENT_KEY`. ## 3. Create the Managed Agent Implement `createAgent({ apiKey, name, model })`. It should create a Managed Agent with: - the target model - a system prompt that says `/mnt/session` is the sandbox workdir - Anthropic's `agent_toolset_20260401` - enabled tools: `bash`, `read`, `write`, `edit`, `glob`, `grep`, `web_fetch`, `web_search` For this cookbook example, the tool permission policy is `always_allow` so the smoke flow can run without an approval UI. ## 4. Build the E2B Template Implement `template` and `buildTemplate(templateName)`. The template should: - start from Node.js - install shell utilities used by the Anthropic toolset - install `@anthropic-ai/sdk`, `tsx`, and `typescript` - copy the worker and webhook runtime files into `/opt/anthropic-managed-agents-js/src` - create writable `/mnt/session` - set `/mnt/session` as the default workdir `buildTemplate(templateName)` should call E2B's `Template.build(...)` with that template. ## 5. Start an Orchestrator Worker Sandbox Implement `startWorkerSandbox(settings, options)`. It should: 1. Require `ANTHROPIC_ENVIRONMENT_ID` and `ANTHROPIC_ENVIRONMENT_KEY`. 2. Connect to `options.sandboxId` if provided, otherwise create a new E2B sandbox from `templateName`. 3. Upload or refresh the worker runtime files. 4. Start the worker process as an E2B background command in `/mnt/session`. 5. Write the worker pid to `/opt/anthropic-managed-agents-js/worker.pid`. 6. Write logs to `/opt/anthropic-managed-agents-js/worker.log`. 7. Disconnect from the E2B background command handle so the local CLI can exit. 8. Update Anthropic environment metadata: ```text e2b_worker_sandbox_id=<sandbox id> e2b_worker_sandbox_ids=["<sandbox id>", ...] ``` The process environment passed to the worker must include: ```text ANTHROPIC_ENVIRONMENT_ID ANTHROPIC_ENVIRONMENT_KEY WORKER_MAX_IDLE_SECONDS LOG_LEVEL ``` ## 6. Run the Worker Inside E2B Implement the worker runtime entrypoint. It should run Anthropic's SDK worker: ```ts const client = new Anthropic({ authToken: environmentKey, logger: console, logLevel: "info", }); await client.beta.environments.work .worker({ environmentId, environmentKey, workdir: "/mnt/session", maxIdleMs, }) .run(); ``` This is the core handoff. Anthropic's SDK owns polling, claiming work, heartbeating, dispatching tool calls, and sending tool results back to the session. Leaving `unrestrictedPaths` unset keeps file tools constrained to the worker `workdir`. Use a short default idle timeout, such as 30 seconds, so a completed or quiet session does not keep the single example worker from polling later work for several minutes. For webhook-driven sandboxes, start a bounded worker process on each `session.status_run_started` delivery instead of treating one PID as the whole queue. Cap concurrency, and give each worker a runtime guard so an idle event stream cannot block later sessions indefinitely. If all worker slots are full, keep a small retry counter so that skipped webhook deliveries start a worker once capacity opens again. ## 7. Start an Auto-Resume Webhook Sandbox Implement `startWebhookServerSandbox(settings, options)`. It should: 1. Require `ANTHROPIC_ENVIRONMENT_ID` and `ANTHROPIC_ENVIRONMENT_KEY`. 2. Connect to `options.sandboxId` if provided, otherwise create an E2B sandbox with: ```ts lifecycle: { onTimeout: "pause", autoResume: true } ``` 3. Upload or refresh the worker and webhook runtime files. 4. Start the webhook server as an E2B background command. 5. Print `https://<sandbox-host>/webhook`. 6. Disconnect from the E2B background command handle so the local CLI can exit. 7. Update Anthropic environment metadata: ```text e2b_webhook_sandbox_id=<sandbox id> e2b_webhook_sandbox_ids=["<sandbox id>", ...] ``` ## 8. Verify Webhooks and Start the Worker Implement the `/webhook` handler. It should: 1. Return `503` when `ANTHROPIC_WEBHOOK_SIGNING_KEY` is not configured. 2. Read the raw request body. 3. Verify the payload with: ```ts const event = client.beta.webhooks.unwrap(body, { headers, key: process.env.ANTHROPIC_WEBHOOK_SIGNING_KEY, }); ``` 4. If `event.data.type === "session.status_run_started"`, start the worker process if it is not already running. 5. Return `204` for accepted webhook deliveries. Also implement `/health` so setup can confirm the webhook sandbox is serving HTTP. ## 9. App-Owned Webhook Routing Implement `app-webhook-server.ts` when webhooks should land on your application instead of inside an E2B sandbox. It should: 1. Receive `POST /webhook` in the app process. 2. Verify the raw Anthropic webhook payload with `client.beta.webhooks.unwrap(...)`. 3. Wake an app-side drain of the self-hosted environment work queue. 4. For each claimed session work item, compute the sandbox routing key from `APP_SANDBOX_ROUTING_SCOPE`. 5. Reconnect to that key's sandbox and start `worker.handleItem()` with the claimed work id, or create a fresh worker sandbox when the assignment is missing or stale. This keeps webhook policy, routing, observability, and sandbox replacement under app control while still using the same E2B worker runtime. Add `GET /sandboxes` so operators can inspect the current session-to-sandbox assignments behind an app-owned bearer token. Do not start a normal environment-polling worker inside the session sandbox; it can claim a different queued session. ## 10. Send a Session Message Implement `streamMessage({ apiKey, agentId, environmentId, message })`. It should: 1. Create a session with `agent` and `environment_id`. 2. Open a session event stream. 3. Send a `user.message`. 4. Print streamed events. 5. Stop when the stream reaches `session.status_idle` with `stop_reason.type === "end_turn"`. ## 11. Upload Files into the E2B Worker Sandbox Anthropic session `resources` are not available for self-hosted environments. For this E2B pattern, upload files through E2B before sending the session message: ```ts import { readFile } from "node:fs/promises"; import { Sandbox } from "e2b"; export async function uploadFileToSandbox({ sandboxId, localPath, remotePath, }: { sandboxId: string; localPath: string; remotePath: string; }) { const sandbox = await Sandbox.connect(sandboxId); const data = await readFile(localPath); const arrayBuffer = data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength); await sandbox.files.write(remotePath, arrayBuffer); return remotePath; } ``` Then ask the agent to read the remote path, for example `/mnt/session/uploads/example-input.txt`. ## 12. Look Up and Clean Up Sandbox Metadata Implement: - `retrieveEnvironment({ apiKey, environmentId })` - `updateEnvironmentMetadata({ apiKey, environmentId, metadata })` - `clearMatchingSandboxMetadata({ apiKey, environmentId, sandboxId })` - `uploadFileToSandbox({ sandboxId, localPath, remotePath })` - `show-environment` `show-environment` should print: ```text ANTHROPIC_ENVIRONMENT_ID=... name=... e2b_worker_sandbox_id=... e2b_worker_sandbox_ids=... e2b_webhook_sandbox_id=... e2b_webhook_sandbox_ids=... ``` `stopWorkerSandbox(settings, sandboxId)` should kill the E2B sandbox and clear `e2b_worker_sandbox_id` or `e2b_webhook_sandbox_id` only when the stored value matches the sandbox being stopped. It should also remove the sandbox id from the matching JSON metadata list. That gives another process a simple lookup path: ```text ANTHROPIC_ENVIRONMENT_ID -> environment.metadata.e2b_*_sandbox_ids -> E2B sandbox ids ```

Instructions flagged against the user

D4 · Tool/Action Safety
“For this cookbook example, the tool permission policy is `always_allow` so the smoke flow can run without an approval UI.”
The prompt explicitly sets the tool permission policy to 'always_allow' so that the agent can run without an approval UI, bypassing any human-in-the-loop safety checks. It enables powerful tools including bash execution, file read/write/edit, web fetch, and web search with no restrictions or validation requirements. Additionally, leaving 'unrestrictedPaths' unset is framed as a constraint, but the overall design prioritizes convenience over safety by removing approval gates for potentially dangerous operations.

Questions about e2b-cookbook's system prompt

Does e2b-cookbook's system prompt contain instructions that work against the user?

Yes. 1 instruction in e2b-cookbook's system prompt was flagged as working against the person the product is talking to, most of them under tool/action safety. Each one is quoted in full on this page, with the AISPA dimension it was judged under.

How long is e2b-cookbook's system prompt?

8,854 characters across 1 prompt on this page. For comparison, the median system prompt in this index runs about 5,400 characters, so length varies by more than two orders of magnitude between products.

How many versions of e2b-cookbook's system prompt are on record?

1. Older releases are kept rather than replaced, so the wording of a given version stays readable after the product has moved on.

Where did this e2b-cookbook system prompt come from?

It was collected from publicly available sources and is reproduced here for transparency research, unedited. This site does not extract prompts from products itself.

How was e2b-cookbook's system prompt audited?

Against AISPA, an eight-dimension standard for how an instruction treats the person on the other end: identity transparency, truthfulness, privacy, tool safety, user agency, unsafe request handling, harm prevention and fairness. This audit was ai audit. The method is described in the paper behind the standard.

How this page was made

The prompt text above is reproduced verbatim from a public source. Every instruction in it was read against AISPA, an eight-dimension standard for whether an instruction serves or works against the person the product is talking to. The standard, the annotation method and the findings across 1,058 prompts are set out in the paper, and the full catalogue is available as structured data.

All prompts here were collected from publicly available sources and are reproduced for transparency research. Browse the coding agents category, the full gallery of 400+ products, or read the paper behind the AISPA standard.