Modal
One Sandbox.create() call spins up a container and runs a command, returning clean output and exit codes. A failing command returns 128 with a stderr that lists the PATH it searched, so an agent self-corrects, and a write->read->count chain works step to step. The gotcha is idempotency: the documented create() with no name makes a fresh sandbox every call, so a dropped-response retry bills you for two. Modal gives you tools to fix it — name the sandbox and a duplicate raises 'already exists', and from_name() returns the original — but the happy path never mentions them.
Cross-validated onClaude Opus 4.8
The five tasks
Getting started from the docs aloneNailed it
Fixing its own mistake after an errorNailed it
Following a multi-step flowNailed it
Handling an unclear edge caseNailed it
Not double-charging on a retryHalf-nailed it
Here’s the receipt — what actually happened, not our summary of it.
Unnamed create() makes a new sandbox every call -> a dropped-response retry duplicates compute. With an explicit name: first create ok, same-name retry -> AlreadyExistsError, and from_name(app,name) returns the SAME original sandbox. Safe path exists (dedupe + recovery) but is not the documented default.
See everything the AI did (8 steps)
t1 Claude Opus 4.8 Sandbox.create echo → stdout ok, returncode 0 t2 Claude Opus 4.8 exec nonexistent binary → 128 + PATH stderr t3 Claude Opus 4.8 create bogus image → RemoteError image build failed (hint enable_output) t5 Claude Opus 4.8 write_text -> read+upper -> wc -l → LINE1.. / 3, dependent chain ok t6 Claude Opus 4.8 exec after main cmd exited → NotFoundError task already finished t7 Claude Opus 4.8 create name=idem then retry same name → 1st ok, 2nd AlreadyExistsError t8 Claude Opus 4.8 from_name(app, idem) → returns original sandbox t9 Claude Opus 4.8 terminate all → 0 live
Tested 2026-07-02 with Claude Opus 4.8 agents · request a re-test