◉GEMINI LABJP
●CLI 0.71 — Gemini CLI v0.71.0 is out as a preview. The stable release is still v0.70.0●TOOL RETR — Tool retrieval (Preview) lets the model load tool definitions only when it needs them●2.5 ROUTE — From 12/1, gemini-2.5-pro routes to 3.8 Flash and 2.5-flash to 3.5 Flash-Lite, billed at the new rates (9 days left)●OAUTH — Users report a stored MCP OAuth token being sent to a repointed server URL without asking●PICK — Choosing a daily Gemini 4 model gets easier when you weigh reasoning, long context and price●AG NEON — Antigravity App v2.34.0 adds Gemini 4 Neon for Gemini API keys●CLI 0.71 — Gemini CLI v0.71.0 is out as a preview. The stable release is still v0.70.0●TOOL RETR — Tool retrieval (Preview) lets the model load tool definitions only when it needs them●2.5 ROUTE — From 12/1, gemini-2.5-pro routes to 3.8 Flash and 2.5-flash to 3.5 Flash-Lite, billed at the new rates (9 days left)●OAUTH — Users report a stored MCP OAuth token being sent to a repointed server URL without asking●PICK — Choosing a daily Gemini 4 model gets easier when you weigh reasoning, long context and price●AG NEON — Antigravity App v2.34.0 adds Gemini 4 Neon for Gemini API keys
Articles/Dev Tools
⟐ Dev Tools/2026-06-18Advanced

Keeping Nightly Batches Alive After the Gemini CLI Stops Responding: A google-genai SDK Fallback

On June 18 the Gemini CLI stops answering requests. Here is a small fallback harness that probes whether the CLI can still respond and quietly reroutes unattended batch jobs to the google-genai SDK, built from my own automation.

Gemini CLI12fallback3automation55google-genai8production140

✦ Premium Article

On June 18, the Gemini CLI stops answering requests on the host side. As an indie developer running several sites that publish on a nightly schedule, I only realized how deeply that one command was wired into my pipeline once I started preparing for the cutover. I assumed gemini -p "..." was only doing article generation, but the same command was quietly buried in screenshot caption work and in pre-publish title proofreading too.

The tricky part is that the gemini binary is still found by which gemini after June 18. What stops is the host response, not the local command. So if you judge liveness by "does the binary exist," you mistake a dead CLI for a live one, and your batch builds a mountain of timeouts. I wrote my first probe with --version, which passed in testing but left only the production nightly batch hanging.

This is not a migration inventory. Rather than the broad plan of finding every place you depend on the CLI, I want to go deep on a single piece after that audit is done: a small harness that keeps work moving even when the CLI goes silent.

Which work to reroute to the SDK, and which to keep on the CLI

Moving everything to the SDK is the safe choice, but you give up the interactive completions and project-context loading that make the CLI pleasant to use. I sorted my work into three buckets before touching any code.

Nature of the workDestinationWhy
Unattended nightly batch generationSDK directlyNo interaction needed; must run independently of the CLI
Interactive local experimentationAntigravity CLIKeep context retention and the conversational feel
One-shot calls inside CISDK directlyPrefer reproducibility and an audit trail

The more unattended a job is, the more it belongs on the SDK. Only work where a person is in front of the screen stays on the CLI (the Antigravity CLI after migration); everything else escapes to the API. The code below is narrowed to one goal: keeping unattended batches alive.

Checking whether the CLI can respond right now

The key to the check is not whether the binary exists, but whether one real response comes back. Send a short prompt; if it times out or exits non-zero, treat the CLI as unusable.

import shutil
import subprocess
 
def cli_available(timeout_sec: int = 12) -> bool:
    """Check whether the gemini CLI can answer right now.
    The point is to try one real generation instead of --version.
    The binary can remain while the host side no longer responds."""
    if shutil.which("gemini") is None:
        return False
    try:
        result = subprocess.run(
            ["gemini", "-p", "ping"],
            capture_output=True,
            text=True,
            timeout=timeout_sec,
        )
    except subprocess.TimeoutExpired:
        return False
    return result.returncode == 0 and bool(result.stdout.strip())

I keep timeout_sec short, at 12 seconds, because waiting minutes on a probe defeats the purpose. A shut-down CLI never returns a response, so the longer you wait, the more you waste. A probe should knock lightly and give up fast.

✦

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
✦Detect the state where the gemini binary still exists but no longer answers, using a real one-shot generation instead of --version
✦Collapse CLI-first and SDK-fallback into a single generate() with exponential backoff, so calls survive the shutdown
✦Add a 16-character idempotency key to nightly jobs to stop duplicate publishing on re-runs
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 $10 for lifetime access
View Membership →

Related Articles

⟐ Dev Tools2026-10-29
Before You Install gemini-api: It Is Not Gemini CLI, and Where I Decided It Belongs
The Gemini API CLI (gemini-api, beta) that appeared on 10/27 is not a successor to Gemini CLI. Here is where I placed it after reading the README, what to check with --dry-run before any billing, and how to pin it in CI.
⟐ Dev Tools2026-10-24
The More MCP Servers You Add, the Closer You Get to a 400 — Trimming Gemini CLI Tools Per Task
Reports say Gemini CLI can stop with a 400 once enough MCP tools are loaded. The exact limit isn't confirmed, but deciding what each task carries with includeTools makes the failure easier to isolate and to prevent.
⟐ Dev Tools2026-10-19
I Set the MCP Timeout to 10 Minutes and It Still Cuts Off at 1 — Tracing Which Layer Decides the Value
You raised an MCP server's timeout in Gemini CLI and it still ends early. A small script lists the value from every config layer, catching unit slips and extension overrides, plus the order I check things in.