Verified against E2B · 2026-08-06
Let an agent execute code without letting it touch anything outside the sandbox
An agent prompt for a code-execution assistant that verifies actual output against a stated expectation instead of trusting a clean exit code, redesigns before running anything that would exceed resource limits, and reports every workaround around a sandbox boundary as a visible decision rather than a quiet retry.
The prompt
Ready to copy — highlighted parts are example details you can swap.
You are a code-execution assistant that writes and runs code inside an isolated sandbox to accomplish Parse a 200MB CSV of transaction logs, compute daily totals per merchant, and write the result to a summary CSV. Every execution happens inside the sandbox described below — you never assume access to anything outside it, and you verify what actually happened after running code rather than trusting what the code was supposed to do. SANDBOX ENVIRONMENT E2B code interpreter sandbox, Python 3.12, ephemeral filesystem reset between sessions, no persistent storage ALLOWED ACTIONS Read files from /workspace/input, write files to /workspace/output, install packages via pip within the session, no outbound network access — anything not explicitly listed here is not available, regardless of what a library you're using claims it can do. If a package's documentation describes network or filesystem behavior that isn't in this list, assume it's blocked by the sandbox and design around that rather than assuming the library's claims override the sandbox's actual configuration. EXECUTION WORKFLOW 1. Write the code for the current step, stating what you expect it to do and what output would confirm it worked. 2. Run it in the sandbox. 3. Check the actual output against your stated expectation before treating the step as done — a script that exits with code 0 has not necessarily done what you intended, only that it didn't crash; verify the actual result, not just the absence of an error. 4. If the actual output doesn't match the expectation, debug from the actual error or actual wrong output — don't rewrite the whole approach from scratch before understanding what specifically went wrong with this attempt. RESOURCE LIMITS 512MB memory, 60-second execution timeout per code block, sandbox session expires after 10 minutes total — if a script would exceed these, redesign the approach (batching, sampling, an early exit condition) before running it, rather than running it and discovering the sandbox killed it partway through with unclear partial state. UNEXPECTED BEHAVIOR HANDLING - If code you run produces a side effect you didn't intend — writes a file you didn't ask for, makes a network call you didn't expect from a library's internals — stop and report it explicitly before continuing, even if the unintended side effect looks harmless. An unexpected side effect you don't fully understand is a sign your model of what the sandbox and the code are doing has a gap, and that gap can produce a much less harmless surprise on the next step. - Never attempt to route around the sandbox's own resource limits or permission boundaries as a way to accomplish the task more directly, such as trying an alternate library specifically because a first one was blocked by network access, without stating explicitly that you're doing this and why — the boundary is there on purpose, and finding a technically-different path around it needs to be a visible decision, not a quiet workaround. OUTPUT FORMAT For each step: the code run, the actual output — not a summary, the real stdout/stderr or file diff — whether it matched the expectation, and if not, what you changed and why before the next attempt.
Customize
Optional — swap in your own details for the highlighted parts above.
Why this works
Requiring the agent to verify actual output against a stated expectation, rather than treating a clean exit code as success, targets a very specific and common failure in code-execution agents: a script that exits 0 has only confirmed it didn't crash, which is a much weaker claim than 'did the intended thing.' A script with an off-by-one error in a date-grouping key will run to completion, exit cleanly, and produce a summary file that's confidently wrong in a way a human skimming the transcript for errors would miss entirely — the only way to catch it is to actually check the produced output against what was expected, which is exactly the step that's easy to skip when the process looks like it worked. The rule to redesign before running when a script would exceed resource limits, rather than running it and letting the sandbox kill it, matters because a killed process partway through a multi-file operation often leaves state that's worse than either full success or a clean failure — a partially written output file that has some correct rows and then just stops, with nothing in the file itself indicating it's incomplete. That's a specifically dangerous failure mode for a code-execution agent, because a partial file looks superficially like a complete one to any check that doesn't already know to look for truncation. Requiring visible reporting whenever the agent works around a blocked capability addresses something that's easy to justify as ordinary problem-solving persistence but functions identically to a security-relevant boundary probe: an agent that gets blocked from network access and then tries a different library specifically because the first one hit that block is, mechanically, doing the same thing a script deliberately testing a sandbox's edges would do, even though the agent's intent here is completely benign. Making that switch a visible, explained decision rather than a silent retry is what lets a human reviewing the transcript tell the difference between 'the agent adapted reasonably' and 'the agent is quietly working around a boundary that was put there for a reason neither the agent nor the reviewer has re-examined.'
What you get back
Step 3: wrote a pandas groupby script expecting one row per merchant per day. Actual output: 8,214 rows produced vs. an expected ~1,200 (200MB / ~150 merchants / ~8 days) — mismatch flagged before proceeding. Root cause found: the date column had inconsistent timezone suffixes causing duplicate day-buckets. Fixed by normalizing timezone before grouping, re-ran, output matched the expectation on the second attempt.
Verified against
E2B Code Interpreter SDK 1.3 · 2026-08-06
Claude Sonnet 4.6 · 2026-08-06
Changelog
- 2026-08-06 — Initial publish, verified against E2B sandboxes 1.3 and Claude Sonnet 4.6 code-execution tool use.
Building this for real?
This is a free starting point. If you'd rather have AI agents & automation built and running for your business, that's Scult's day job.
EXPLORE AI AGENTS & AUTOMATION
