GEMINI LABJP
ROBOTICS — The ER 1.6 preview that shut down on August 31 does have a successor. Gemini Robotics ER 2 is in public preview, in both standard and streaming variantsVIDEO — ER 2 judges success and failure from live video rather than still snapshots, which is what lets it catch spills, slips, and misalignments while a task is still runningDEADLINE — Next up is September 30, when gemini-omni-flash-preview is retired. The target is gemini-omni-1.1-flash, GA since August 27, and there are now under four weeks leftAPIKEY — Every remaining standard API key, restricted ones included, stops working during September. The replacement is an auth key bound to a Google Cloud service accountPRICE — Gemini 3.7 Flash keeps its introductory $0.75/$3.75 per 1M through December 31, then moves to $1.50/$7.50 on January 1, 2027. Any estimate crossing the year needs both figuresAUDIO — Gemini 3.5 Transcribe handles language detection across 85+ languages, speaker diarization, word-level timestamps, and custom vocabulary biasing of up to 1,000 termsROBOTICS — The ER 1.6 preview that shut down on August 31 does have a successor. Gemini Robotics ER 2 is in public preview, in both standard and streaming variantsVIDEO — ER 2 judges success and failure from live video rather than still snapshots, which is what lets it catch spills, slips, and misalignments while a task is still runningDEADLINE — Next up is September 30, when gemini-omni-flash-preview is retired. The target is gemini-omni-1.1-flash, GA since August 27, and there are now under four weeks leftAPIKEY — Every remaining standard API key, restricted ones included, stops working during September. The replacement is an auth key bound to a Google Cloud service accountPRICE — Gemini 3.7 Flash keeps its introductory $0.75/$3.75 per 1M through December 31, then moves to $1.50/$7.50 on January 1, 2027. Any estimate crossing the year needs both figuresAUDIO — Gemini 3.5 Transcribe handles language detection across 85+ languages, speaker diarization, word-level timestamps, and custom vocabulary biasing of up to 1,000 terms
Articles/API / SDK
API / SDK/2026-07-18Advanced

Keeping a Long-Running Managed Agent Alive Across Sandbox Recycling — Durable Checkpoints and Idempotent Resume

A Managed Agents sandbox can be recycled out from under you. Before 40 minutes of work resets to zero, we design a durable checkpoint that pushes progress outside the sandbox and an idempotent resume that never runs a side effect twice. With working SQLite code.

Gemini API229Managed Agents8Architecture10Idempotency3Operations11

Premium Article

One morning I opened the run log and my hand stopped over the trackpad.

The aggregation agent I had kicked off the night before had vanished 42 minutes in. Not an error. The run had simply ended partway through, and by morning a different sandbox was trying to start it over from step one.

Managed Agents spins up a Google-hosted, isolated Linux sandbox in a single API call and runs your agent autonomously inside it. For a solo developer with no servers of their own, that lightness is a gift. But lightness has an underside: the sandbox is not mine. Idle timeouts, platform maintenance, capacity reallocation. The runtime gets quietly rebuilt on a schedule that has nothing to do with my convenience.

What I had kept in inventory was progress that lived only inside the sandbox. Forty-two minutes of intermediate results disappeared when the environment did. Back to square one.

This article is about erasing that square one. A durable checkpoint that pushes progress outside the sandbox, and an idempotent resume that won't run a side effect twice. We'll build it up in order, all the way down to code you can run.

Why a Managed Agent disappears mid-run

Let's set the premise straight. Vanishing isn't an anomaly — it's a property that lives on the platform side.

A Managed Agents sandbox is, by design, largely ephemeral. It comes up for a single run and gets cleaned up when the run ends. Even mid-run, the environment can be rebuilt for reasons like these.

TriggerWhat happensHow it looks to you
Idle timeoutReclaimed after inactivity during an external wait (API response, etc.)The run disappears after a long wait
Maintenance / reallocationThe host moves the sandbox to another nodeNon-reproducible interruption; the reason rarely lands in your logs
Wall-clock ceilingYou hit the runtime boundary for a single runIt cuts off at a fixed duration, every time
Capacity pressureConcurrency or quota stops a lower-priority runMore likely to drop during busy windows

What they share is that you don't hold the initiative over the interruption. That settles the direction of the design. The goal isn't "don't fall over" — it's "keep going even after you fall over." The former assumes control over the environment, and that control isn't yours. The latter only requires that you keep the place where progress lives on your own side.

Handing long-running work to Managed Agents is a choice I reach for gladly. I want to let go of operations I can let go of. But the condition for letting go is this: keep progress outside the sandbox. I draw that line first, before anything else.

The core idea — push progress "outside"

The job fits in one sentence. Every time the agent takes a step, write that step to an external, durable store. When the sandbox disappears, the external store remains. The next run reads it and continues from where the last one stopped.

The important discipline is to externalize as little as possible. It's tempting to save the entire intermediate dataset, but that's heavy and fragile. Only two things need to leave the sandbox:

  1. How far you got — a step index, or the set of already-processed identifiers.
  2. The minimum state needed to resume — the position of the next input, a running counter, an external resource handle.

The intermediate artifacts themselves (summary text, images, partial aggregates) get written as a side effect into a "committed results" table in the external store, and the checkpoint only references them. That keeps the checkpoint light and makes re-reads on resume cheap.

Put differently: the checkpoint is a map, not the cargo. The cargo is dropped at each waypoint (committed results); the map only records how far you've traveled. That separation is what makes the idempotency that follows fall out cleanly.

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
A checkpoint that survives sandbox recycling by externalizing only the step index and the minimal resume state
Idempotent resume that never repeats a side effect: the claim-execute-commit phases, with complete working SQLite code
A checkpoint-granularity guide: the measured recovery-time vs cost trade-off between per-step and batched saves
Secure payment via Stripe · Cancel anytime

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Gemini Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $15 for lifetime access
View Membership →

Related Articles

API / SDK2026-08-08
A Timeout Was Never Evidence of Failure — Designing Around Blocking Function Calls
When a tool call cannot return until the real-world effect finishes, two habits reverse on you: parallel dispatch and generous timeouts. Measured numbers from a sandbox harness, plus the design that replaces retries with observation.
API / SDK2026-08-02
Measuring a Guard in environment hooks: 46 Microseconds to Decide, 23 Milliseconds to Start
A record of building a destructive-command guard for Managed Agents environment hooks. A regex denylist let 9 of 20 dangerous commands through; argv parsing reached 100 percent detection. The startup cost turned out to be 500 times the decision cost.
API / SDK2026-07-29
A 17% Drop in Output Tokens Sounded Big. Then I Decomposed the Bill
Output pricing fell 16.67% and output tokens fell about 17%. Adding those numbers does not give you the savings. Here is an exact price/volume/cross-term decomposition, plus a loop measurement where the savings rate went down instead of up.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →